Select to view content in your preferred language

Drawing line with lat and lon in array + Icon

4079
12
Jump to solution
03-19-2013 10:26 AM
AhmadMizan
Emerging Contributor
Sorry for asking this noob question, because I cant find in documentation . Im new in JavaScript..

My question is how to draw line with symbol or icon with lat and lon information using script. In documentation only show me to use drawing tool.. But I need script example, that could help me a lot.

for example my array in php store 10 lat and lon information and need to be drow on map.

Hope someone can help me on this.
0 Kudos
12 Replies
AhmadMizan
Emerging Contributor
so Derek, to make appear same like picture I attach before i have to add this line code?
http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/graphic.html

I added before, but nothing happened on map..

there any sample that can show me how to do this?.. it really help me with example..
0 Kudos
JohnGravois
Deactivated User
try this...

function init() {        var options = {         basemap : "gray",         center : [115.246, 5.25803],         zoom : 11        };        // Create map        map = new esri.Map("mapDiv", options);         var p1 = new esri.geometry.Point(115.246, 5.25803);        var p2 = new esri.geometry.Point(115.2462, 5.22964);           var line = new esri.geometry.Polyline();        line.addPath([p1, p2]);           var pointSym = new esri.symbol.SimpleMarkerSymbol();   var lineSym = new esri.symbol.SimpleLineSymbol().setColor(new dojo.Color("blue"));   var infoTemplate = new esri.InfoTemplate("title","content");           var gLayer = new esri.layers.GraphicsLayer({          "id" : "scratch"         });           // create a graphic        var pt1Graphic = new esri.Graphic(p1, pointSym);   var pt2Graphic = new esri.Graphic(p2, pointSym);      pt1Graphic.setInfoTemplate(infoTemplate);   pt2Graphic.setInfoTemplate(infoTemplate)      var lineGraphic = new esri.Graphic(line, lineSym);           // add it to the graphics layer   gLayer.add(lineGraphic);   gLayer.add(pt1Graphic);   gLayer.add(pt2Graphic);           // add the graphics layer to the map        map.addLayer(gLayer);       }
0 Kudos
AhmadMizan
Emerging Contributor
Thanks John,

I got better view to understand now.. thanks for sharing the code..:)
0 Kudos