AnsweredAssumed Answered

Adding points to a map problem

Question asked by sailitang on Sep 12, 2013
Latest reply on Sep 16, 2013 by sailitang

I have a problem on the code for adding points to my dynamic map. The following code will be run when map is loaded. This code is to add some points to the map. Please see the red and bold part of the code. For the testing, I define two points using constant coordinates, it works and I can see the two points on my map. But when I changed geometryService.project(points1, map.spatialReference, function (results) to geometryService.project(multipoint.points, map.spatialReference, function (results), it didnâ??t work and the points werenâ??t shown. strPoints value is from VB.NET code. I changed pointsâ?? coordinates to string in VB.NET, pass to javascript, changed back to pointsâ?? coordinates in js and add these points to multipoint. I believe that passing the values is successful but why I cannot show the points? I doubt that multipoint.points is not the same as points1? Thanks. code:
Dim jvscript As String = Nothing
Dim str As String = Nothing
str = "-66.653,45.967,-66.70,45.9"
jvscript = "DisplayMap('" & str & "');"
Page.ClientScript.RegisterStartupScript(Me.GetType, "TimeOutMessage", jvscript, True)

Javascript code:
function DisplayMap(strPoints) {

var map;
var i;
//var multipoint;

"esri/map", "esri/geometry/Point",
"esri/symbols/SimpleMarkerSymbol", "esri/graphic", "esri/tasks/GeometryService",
"dojo/_base/array", "dojo/dom-style", "dojo/_base/Color",
"esri/layers/ArcGISDynamicMapServiceLayer", "esri/geometry/Multipoint", "esri/SpatialReference", "dojo/domReady!"
], function (Map, Point, SimpleMarkerSymbol, Graphic, GeometryService, arrayUtiles,
domStyle, Color, ArcGISDynamicMapServiceLayer, Multipoint, SpatialReference
) {

var initialExtent = new esri.geometry.Extent({ "xmin": 2306896.79, "ymin": 7278537, "xmax": 2710915.5, "ymax": 7674860.5, "spatialReference": { "wkid": 2953} }); //102100, 2953

map = new Map("NBmap", {
extent: initialExtent
var basemaplayer = new ArcGISDynamicMapServiceLayer("");

map.on("load", mapLoaded);

function mapLoaded() {

var geometryService = new GeometryService("");

var arrycoord = strPoints.split(",");
var multipoint = new Multipoint(map.spatialReference);
for (i = 0; i < arrycoord.length; i = i + 2) {
var x = arrycoord[i];
var y = arrycoord[i + 1];
var point = new Point();
point.x = x;
point.y = y;

var points1 = [new Point([-66.653, 45.967]), new Point([-66.70, 45.97])];
// Project the points
geometryService.project(points1, map.spatialReference, function (results) {

var initColor = "#ce641d";
arrayUtiles.forEach(results, function (result) {
// add the projected point to the map
var graphic = new Graphic(result, createSymbol(initColor));;


function createSymbol(color) {
var markerSymbol = new esri.symbol.SimpleMarkerSymbol();
markerSymbol.setColor(new Color(color));
return markerSymbol;