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>";
});