PolylineSymbols are being added, but not displayed

723
3
Jump to solution
07-29-2013 07:34 AM
CameronMacNeil
New Contributor II
Hi everyone, I have a problem that I'm hoping one of you can help me with. I've got a bunch of PictureMarkerSymbols, and I want to draw lines between them and a single other PictureMarkerSymbol. I've got all of the necessary coordinates, and I'm not seeing any errors when I create the appropriate objects. However, none of the lines I'm creating are being displayed on the map. I'll post a part of the code below, please let me know if you have any idea what might be wrong!

var polylineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([204, 102, 51]), 4);  path = $.map(line.points, function(point) {           p = new esri.geometry.Point(point.lng, point.lat);           return p;          });  polyline = new esri.geometry.Polyline(map.spatialReference); polyline.addPath([path[0], path[1]]);  map.graphics.add(new esri.Graphic(polyline, polylineSymbol));


Thanks!
0 Kudos
1 Solution

Accepted Solutions
SteveCole
Frequent Contributor
You're defining your graphic polylines as having the map's spatial reference. Are you positive that the map's spatial reference is defined as geographic? If you're using ESRI's basemaps, the map's spatial reference is web mercator which means you will need to convert your coordinates from lat/long to web mercator.

Steve

View solution in original post

0 Kudos
3 Replies
SteveCole
Frequent Contributor
You're defining your graphic polylines as having the map's spatial reference. Are you positive that the map's spatial reference is defined as geographic? If you're using ESRI's basemaps, the map's spatial reference is web mercator which means you will need to convert your coordinates from lat/long to web mercator.

Steve
0 Kudos
CameronMacNeil
New Contributor II
That was the problem! I was defining the polyline with the basemap's spatial reference, but the points I was using were all using the default of 4326. Once I defined the polyline with that same reference, it worked. I don't understand spatial references very well, so I didn't realize that the two weren't compatible!

Thanks for the prompt reply and the good advice!
0 Kudos
SteveCole
Frequent Contributor
Awesome. Glad you got it worked out.
0 Kudos