4

I'm writing a web app using ESRI's Javascript API and a map I created in ArcMap 10.1 hosted on ArcGIS online (Feature Service, not WebMap).

I have written the code necessary to print attributes in a stationary DIV instead of creating a popup. The only problem is, I now have to click twice every time I want to select a new feature.

So, I select a feature, the DIV updates with the new attributes. I click on a different feature, nothing happens. I click on the same feature again and the attributes update in the DIV.

What is going on here? I'm using map.infoWindow.on() to listen for "selection-change". My code is below and the website is live here.

popup = new Popup({popupWindow:false},domConstruct.create("div"));

map = new Map("Div1", { 
 basemap: "gray",
 center: [-86.14, 39.79],
 zoom: 11,
 infoWindow: popup,
});

featureLayer = new FeatureLayer("http://services1.arcgis.com/ROSiDsWkQXhsUAs0/arcgis/rest/services/Thesis.gdb-2015-01-19_(1)/FeatureServer/0",{
 mode: FeatureLayer.MODE_ONDEMAND,
 infoTemplate: popupTemplate,
 outFields: ["*"]
});

map.addLayer(featureLayer);

popup.on("selection-change", function(){
 var feature = popup.getSelectedFeature();
 var content_MED_dolla = feature.attributes["MED_dolla"];
 document.getElementById("popupDiv").innerHTML = "<p>Median mortgage value: $" + content_MED_dolla + ",000</p>";

});
1
  • Just curious, why does the "selection-change" event throw the error? I'm dealing with this situation as well but need to capture the navigation events in the Popup for multi-selected features. – user46299 Feb 10 '15 at 17:35
3

Change

popup.on("selection-change", function(){

to

popup.on("set-features", function(){    
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.