|
POST
|
I put this code in and I get an error: Uncaught SyntaxError: Unexpected token if var infoHighwayCameras = new InfoTemplate();
infoHighwayCameras.setTitle("Highway Cameras");
infoHighwayCameras.setContent(getTextContent);
function getTextContent(graphic) {
return "<table>" +
"<tr><td id='tblTitle'>Highway Cameras</td><td id='tblTitle2'></td></tr>" +
"<tr><td id='tblTitleLine'></td><td id='tblTitleLine2'></td></tr>" +
"<tr><td></td><td></td></tr>" +
"<tr><td id='tblMainline1'>description</td><td id='tblSubline2'> " + graphic.attributes.descriptio + " </td></tr>" +
"<tr><td id='tblSubline2' colspan='2'><img src= " + graphic.attributes.image_url + "?t=" + new Date().getTime() + " /></td></tr>" +
//Notice my little time stamp change to the url above
"</table><hr>";
}
function onLayerUpdateEnd()
//when the layer is refereshed if the popup has a selected feature then
//force the popup to get the content again
if(map.infoWindow.count > 0){
var graphic = map.infoWindow.getSelectedFeature();
map.infoWindow.setFeatures([graphic]);
}
}
var HighwayCameras = new FeatureLayer("https://services.arcgis.com/DO4gTjwJVIJ7O9Ca/arcgis/rest/services/Camera_Location_VDOT/FeatureServer/0", {
mode: FeatureLayer.MODE_ONDEMAND,
visible: true,
opacity: .5,
outFields: ["*"],
infoTemplate: infoHighwayCameras,
refreshInterval: 0.1
});
legendLayers3.push({
layer: HighwayCameras,
title: 'Highway Cameras'
});
HighwayCameras.on('update-end', onLayerUpdateEnd);
... View more
12-03-2018
01:10 PM
|
0
|
2
|
1583
|
|
POST
|
If you click this link you can see that the popup image is replaced... takes about 5-10 seconds for a new image to be taken.
... View more
12-03-2018
12:22 PM
|
0
|
4
|
1583
|
|
POST
|
Yea they have a Service This service has a bunch of features in it. Each feature has a field called image_url This URL will NOT change...it will reference the SAME .png file every time. See Below This is how I think they do it. The database value for this field stays constant including the name of the image. The image is simply replaced on their server in the "thumbs" folder with a new image every few seconds via an upload from the cameras in the field. I just cant get the InfoTemplate to refresh with the new image.
... View more
12-03-2018
12:18 PM
|
0
|
5
|
1583
|
|
POST
|
OK I tried to strip out as much noise as I could... Index.html should be main file to point to in IIS. index.js file in the js folder Open the app Zoom out a bit to see Image Features Click the Information Tab on left Click a Feature Click a different Feature (wait couple minutes) Click the 1st feature notice this does not update.
... View more
12-03-2018
10:39 AM
|
0
|
7
|
2051
|
|
POST
|
This is what i am doing now.... I might be missing what you are saying...I apologize... just trying to nip this in the rear If you still have to patience can you please try to explain my options to get the InfoTemplate to refresh a new image. var infoHighwayCameras = new InfoTemplate();
infoHighwayCameras.setTitle("Highway Cameras");
infoHighwayCameras.setContent(getTextContent);
function getTextContent(graphic) {
return "<table>" +
"<tr><td id='tblTitle'>Highway Cameras</td><td id='tblTitle2'></td></tr>" +
"<tr><td id='tblTitleLine'></td><td id='tblTitleLine2'></td></tr>" +
"<tr><td id='tblMainline1'>description</td><td id='tblSubline2'> " + graphic.attributes.descriptio + " </td></tr>" +
"<tr><td id='tblMainline1'>image_url</td><td id='tblSubline2'><img src= " + graphic.attributes.image_url + " /></td></tr>" +
"</table><hr>";
}
var HighwayCameras = new FeatureLayer("https://services.arcgis.com/DO4gTjwJVIJ7O9Ca/arcgis/rest/services/Camera_Location_VDOT/FeatureServer/0", {
mode: FeatureLayer.MODE_ONDEMAND,
visible: false,
opacity: .5,
outFields:["*"],
infoTemplate: infoHighwayCameras
});
HighwayCameras.refreshInterval = 0.1;
legendLayers3.push({ layer: HighwayCameras, title: 'Highway Cameras' });
... View more
12-03-2018
09:01 AM
|
0
|
10
|
2051
|
|
POST
|
If you open this in a browser and keep refreshing the image changes...about every 10 seconds or so https://images.skyvdn.com/thumbs/RichmondCS64EB1729.flv.png But this does not happen when I have it in the InfoTemplate and click on the same Feature again and again.
... View more
12-03-2018
08:50 AM
|
0
|
12
|
2051
|
|
POST
|
The URL to the image is always the same....this does not change....only the image in the database on their side of the fence.... It refreshes in a popup window but not the InfoTemplate....hmmmmmm
... View more
12-03-2018
08:47 AM
|
0
|
13
|
2051
|
|
POST
|
I put a refresh interval on the layer and its still not refreshing in the InfoTemplate Still think its linked to the image being cached in the browser? So puzzled here...if I click a new feature the image changes but goes back to the original image on the first feature I clicked....it does not get updated in the InfoTemplate...but as I stated if I force to a popup and open a new window the image does refresh. var HighwayCameras = new FeatureLayer("https://services.arcgis.com/DO4gTjwJVIJ7O9Ca/arcgis/rest/services/Camera_Location_VDOT/FeatureServer/0", { mode: FeatureLayer.MODE_ONDEMAND, visible: false, opacity: .5, outFields:["*"], infoTemplate: infoHighwayCameras }); HighwayCameras.refreshInterval = 0.1;
... View more
12-03-2018
08:40 AM
|
0
|
1
|
1862
|
|
POST
|
No....do you set that along with the outfields and opacity? Not sure how this will effect the cached image as the image name does not change for a specific feature, this is why I was trying to put a date stamp at the end...hoping that it would reload the image. If I click another feature the image changes....but when I go back and click on the first image it still displays the original image. If I do this in a popup it changes the image each time I click on it. But I have to keep closing to window it opens in ...I want this a bit more streamlined where it refreshes the image in the InfoTemplate itself...Seems the InfoTemplate is not refreshing the image ...that make sense? I have been researching how to clear an image from the cache with a specific name in javascript so it forces it to reload a new image....no luck
... View more
12-03-2018
08:33 AM
|
0
|
17
|
1862
|
|
POST
|
So I can do this and it displays the image....I can forgo pushing to a new div or what ever using a function , but what I cannot get to work is a refresh of the image as these change every few seconds... It seems to be caching the image and when I click on the same feature it does not refresh because the name is the same. I tried to add a date time into the URL but thats not working either. If I can find a way to clear the cache for the image that was already viewed I think that would work....but not sure. The image in the InfoTemplate does not refresh var Image = graphic.attributes['image_url'];
var newdate = new Date()
var Image2 = Image + "?" + newdate "<tr><td id='tblMainline1'>image_url</td><td id='tblSubline2'><img src= " + Image2 + " /></td></tr>" +
... View more
12-03-2018
08:13 AM
|
0
|
19
|
1862
|
|
POST
|
I got the first two now working on the 3rd...created variables to set the values and then used that in the table var infoHighwayCameras = new InfoTemplate();
infoHighwayCameras.setTitle("Highway Cameras");
infoHighwayCameras.setContent(getTextContent);
function getTextContent(graphic) {
var Jurisdiction = graphic.attributes['jurisdicti'];
var Image = graphic.attributes['image_url'];
return "<table>" +
"<tr><td id='tblMainline1'>jurisdiction</td><td id='tblSubline2'> " + Jurisdiction + "</td></tr>" +
"<tr><td id='tblMainline1'>image_url</td><td id='tblSubline2'><img src= " + Image + " /></td></tr>" +
"<tr><td id='tblMainline1'>image_url</td><td id='tblSubline2'><i>TEST1 <a href='#' onclick='onclickFunction(' + graphic.attributes.image_url + ')'>Click Me!</a> </td></tr>" +
"</table><hr>";
}
... View more
12-03-2018
07:05 AM
|
0
|
21
|
1862
|
|
POST
|
Yea I am trying like your example but your example does not seem to work either...trying to look this up in help sections Trying to find examples or documentation on Functions within an InfoTemplate. infoHighwayCameras.setContent(getTextContent);
function getTextContent(graphic) {
return "<table>" +
"<tr><td id='tblTitle'>Highway Cameras</td><td id='tblTitle2'></td></tr>" +
"<tr><td id='tblTitleLine'></td><td id='tblTitleLine2'></td></tr>" +
"<tr><td></td><td></td></tr>" +
"<tr><td id='tblMainline1'>image_url</td><td id='tblSubline2'><i>TEST1 <a href='#' onclick='onclickFunction(" + graphic.attributes.image_url + ")'>Click Me!</a>." +
"</td></tr></table><hr>";
} Im trying for: one with simply attribute value one with image in the src that will update the image every feature click one with a click event to call a function to update a DIV or something with the image value I thought the click of the link (3rd one below) would bring my to the outside function that I can simply alert from to show I was there. Trying to get the syntax right...haven't found any documentation specific to this application of it yet. function onclickFunction(test){
alert("Here");
alert(test);
}
var infoHighwayCameras = new InfoTemplate();
infoHighwayCameras.setTitle("Highway Cameras");
infoHighwayCameras.setContent(getTextContent);
function getTextContent(graphic) {
return "<table>" +
"<tr><td id='tblMainline1'>jurisdiction</td><td id='tblSubline2'> ${graphic.attributes.jurisdicti} </td></tr>" +
"<tr><td id='tblMainline1'>image_url</td><td id='tblSubline2'><img src= ' + graphic.attributes.image_url + '/></td>"+
"<tr><td id='tblMainline1'>image_url</td><td id='tblSubline2'><i>TEST1 <a href='#' onclick='onclickFunction(' + graphic.attributes.image_url + ')'>Click Me!</a> </td></tr>" +
"</table><hr>";
... View more
12-03-2018
06:40 AM
|
0
|
23
|
1862
|
|
POST
|
OK So I am testing this for 2 scenarios : 1. The image simply appears in the template 2. There is an onclick even that calls a function to update the Div or what ever location you are specifying in my app I use the code below and it stops returning my attribute values for ${route} and ${status} nor does it find the ${image_url} to show the image in the template. So the image no longer appears in the template When I click the link for the 2nd scenario nothing happens. 1. I don't get either alert boxes but rather an error: SyntaxError: missing ) after argument list 2. If I remove the " " in this (" + graphic.attributes.image_url + ") becomes this (' + graphic.attributes.image_url + ') i get Error: Unexpected end of input Maybe your example is not designed for anything but a function call? Trying to get both scenarios working so I can ultimately decide which one to use but also a learning thing here. My question is can both scenarios work from within this Function? Or do I build the table and then create the function? function onclickFunction(test){
alert("Here");
alert(test);
}
var infoHighwayCameras = new InfoTemplate();
infoHighwayCameras.setTitle("Highway Cameras");
infoHighwayCameras.setContent(getTextContent);
function getTextContent(graphic) {
return "<table>" +
"<tr><td id='tblTitle'>Highway Cameras</td><td id='tblTitle2'></td></tr>" +
"<tr><td id='tblTitleLine'></td><td id='tblTitleLine2'></td></tr>" +
"<tr><td></td><td></td></tr>" +
"<tr><td id='tblMainline1'>route</td><td id='tblSubline2'>${route}</td></tr>" +
"<tr><td id='tblMainline1'>status</td><td id='tblSubline2'>${status}</td></tr>" +
"<tr><td id='tblMainline1'>image_url</td><td id='tblSubline2'><img src='${image_url}'/></td>"+
"<tr><td id='tblMainline1'>image_url</td><td id='tblSubline2'><i>TEST1 <a href='#' onclick='onclickFunction(" + graphic.attributes.image_url + ")'>Click Me!</a>. </td></tr>" +
"</table><hr>";
}
... View more
12-03-2018
05:22 AM
|
0
|
25
|
1862
|
|
POST
|
copied all the code I am using for this....sorry for the confusion......appreciate your help
... View more
11-30-2018
01:13 PM
|
0
|
27
|
2897
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-20-2018 11:09 AM | |
| 1 | 09-10-2018 06:26 AM | |
| 1 | 09-15-2022 11:02 AM | |
| 1 | 05-21-2021 07:35 AM | |
| 1 | 08-09-2022 12:39 PM |
| Online Status |
Offline
|
| Date Last Visited |
09-19-2022
09:23 PM
|