Solved! Go to Solution.
var self = this; var xhrArgs = { url: "/Map/getalerts", handleAs: "json", load: function (track) { var point = new Point(track.Latitude, track.Longitude, new SpatialReference({ wkid: 4326 })); var simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 1), new Color([0, 255, 0, 0.25])); var graphic = new Graphic(webMercatorUtils.geographicToWebMercator(point), simpleMarkerSymbol, { 'title': track.FullName, 'content': 'ID: 2<br/>TimeStamp: Some Time<br/>Message Type: Alert' }, new InfoTemplate('${title}', '${content}')); self.map.graphics.add(graphic); }, error: function (error) { console.log("An unexpected error occurred: " + error); } }
var map = new Map(...); var xhrArgs = { url: "/Map/getalerts", handleAs: "json", load: function (track) { var point = new Point(track.Latitude, track.Longitude, new SpatialReference({ wkid: 4326 })); var simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 1), new Color([0, 255, 0, 0.25])); var graphic = new Graphic(webMercatorUtils.geographicToWebMercator(point), simpleMarkerSymbol, { 'title': track.FullName, 'content': 'ID: 2<br/>TimeStamp: Some Time<br/>Message Type: Alert' }, new InfoTemplate('${title}', '${content}')); // Removed the "this" keyword. map.graphics.add(graphic); }, error: function (error) { console.log("An unexpected error occurred: " + error); } } // Call the asynchronous xhrGet var deferred = xhr.get(xhrArgs); }
var self = this; var xhrArgs = { url: "/Map/getalerts", handleAs: "json", load: function (track) { var point = new Point(track.Latitude, track.Longitude, new SpatialReference({ wkid: 4326 })); var simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 1), new Color([0, 255, 0, 0.25])); var graphic = new Graphic(webMercatorUtils.geographicToWebMercator(point), simpleMarkerSymbol, { 'title': track.FullName, 'content': 'ID: 2<br/>TimeStamp: Some Time<br/>Message Type: Alert' }, new InfoTemplate('${title}', '${content}')); self.map.graphics.add(graphic); }, error: function (error) { console.log("An unexpected error occurred: " + error); } }