AnsweredAssumed Answered

Infowindow data is same for all point symbol, missing some loop

Question asked by mallareddy2271 on Jun 21, 2017
Latest reply on Jun 22, 2017 by thejus.kambi

//data from sql works fine, it binds to infowindow, but same data for all points, I think i'm missing something in the bold selected bottom lines

var map;
require([
"esri/map",
"esri/dijit/Scalebar",
"esri/InfoTemplate",
"esri/symbols/SimpleLineSymbol",
"esri/graphic",
"esri/symbols/SimpleMarkerSymbol",
"esri/Color",
"dojo/on",
"dojo/dom",
"esri/geometry/Point",
"esri/dijit/Search",
"dojo/domReady!"
], function (
Map, Scalebar, InfoTemplate, SimpleLineSymbol, Graphic, SimpleMarkerSymbol, Color, on, dom, Point, Search
) {
var markers = JSON.parse('<%=ConvertDataTabletoString() %>');
map = new Map("map", {
basemap: "osm",
center: [-120.7077, 47.2601],
zoom: 7
});

var scalebar = new Scalebar({
map: map,
// "dual" displays both miles and kilometers // "english" is the default, which displays miles // use "metric" for kilometers
scalebarUnit: "dual"
});
var search = new Search({
map: map
}, "City");
search.startup();
var infoTemplate = new InfoTemplate();
infoTemplate.setTitle("Population in ");
infoTemplate.setContent("<b>2007<br/>" );
map.on("click", addPoint);
function addPoint(evt) {
var lat = evt.mapPoint.getLatitude();
var long = evt.mapPoint.getLongitude();
document.getElementById("ContentPlaceHolder1_txtLat").value = lat;
document.getElementById("ContentPlaceHolder1_txtLng").value = long;
}

map.on("load", addQueryResult);
function addQueryResult() {
for (i = 0; i < markers.length; i++) {
var data = markers[i]
var lat = data.latitude;
var long = data.longitude;
var green = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 11,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([0, 128, 0]),2));
var yellow = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 11,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255, 255, 0]), 2));
var pt = new Point(long, lat);
var graphic = new Graphic();
if (data.PermitStatus == 'Active') {
var graphic = Graphic(pt, green);
}

else {
var graphic = Graphic(pt, yellow);
}

map.graphics.add(graphic);
map.on("click", Pointdata);
function Pointdata(evt) {
if (evt.graphic) {

var latitude = evt.mapPoint.getLatitude();
var longitude = evt.mapPoint.getLongitude();
map.infoWindow.setTitle("FacilityDetails");
map.infoWindow.setContent(select city, industry from location//example query//
);

map.infoWindow.show(evt.mapPoint, map.getInfoWindowAnchor(evt.screenPoint));


}
}
});thejus kambi 

Outcomes