This should be pretty easy. Use a function to actually populate the content of your infoWindow. First, create your infoTemplate: var theTemplate = new esri.InfoTemplate(); theTemplate.setContent(setPopupContent);Next, set up your dojo.connect for clicks on the features in your layer: //Listener event for feature selection and the popup info widow dojo.connect(theFeatureLayer,"onClick",function(evt){ //Listener event for feature selection and the popup info widow var query = new esri.tasks.Query(); query.geometry = pointToExtent(map,evt.mapPoint,15); var deferred = theFeatureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW); map.infoWindow.setFeatures([evt.graphic]); map.infoWindow.show(evt.mapPoint); });Lastly, create the function which will populate your template with the content you want: function setPopupContent(graphic) { attr = graphic.attributes; curState = attr.STATE; content = 'Create your content here'; //If The state clicked is ABC, append the special notation if (curState == "ABC") { content = content + "<br/><br/>(estimates based on State average)"; } return content; }Steve
var theTemplate = new esri.InfoTemplate(); theTemplate.setContent(setPopupContent);
//Listener event for feature selection and the popup info widow dojo.connect(theFeatureLayer,"onClick",function(evt){ //Listener event for feature selection and the popup info widow var query = new esri.tasks.Query(); query.geometry = pointToExtent(map,evt.mapPoint,15); var deferred = theFeatureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW); map.infoWindow.setFeatures([evt.graphic]); map.infoWindow.show(evt.mapPoint); });
function setPopupContent(graphic) { attr = graphic.attributes; curState = attr.STATE; content = 'Create your content here'; //If The state clicked is ABC, append the special notation if (curState == "ABC") { content = content + "<br/><br/>(estimates based on State average)"; } return content; }
for ( j = 0; j < newGeog.length; j++) { if (newGeog == "A" || newGeog == "B" || newGeog == "C") { resultContent = "<tr>" + indc + ": <td>${" + indv + ":formatNumber} (State average)</td></tr>"; } else { resultContent = "<tr>" + indc + ": <td>${" + indv + ":formatNumber}</td></tr>"; } }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.