Dropping pins using X/Y

2043
2
08-08-2013 05:47 AM
SaaedBhatti
New Contributor
Hi,

I'm new to esri. I'm trying to figure out how to drop pin on a map using X/Y coordinates and when the pin is clicked, it needs to show the attribute information on that feature.

Can some one please point me in the right direction.

Thanks
0 Kudos
2 Replies
JasonZou
Occasional Contributor III
Sample code:
var pt = new esri.geometry.Point(x,y,map.spatialReference)
var pms = new new esri.symbols.PictureMarkerSymbol('/images/pin.png');
var attr = {"Xcoord":evt.mapPoint.x,"Ycoord":evt.mapPoint.y,"Plant":"Mesa Mint"};
var infoTemplate = new InfoTemplate("Vernal Pool Locations","Latitude: ${Ycoord} <br/>
    Longitude: ${Xcoord} <br/>
    Plant Name:${Plant}");
var graphic = new Graphic(pt,pms,attr,infoTemplate);
map.graphics.add(graphic)

where attr will be the attributes of the feature, and anything inside ${} is one of the field names in attr. I normally like to create a separate graphics layer so not to pollute map.graphics, and you will have more control over the graphics added.

Hope it helps.
0 Kudos
SaaedBhatti
New Contributor
Sample code:
var pt = new esri.geometry.Point(x,y,map.spatialReference)
var pms = new new esri.symbols.PictureMarkerSymbol('/images/pin.png');
var attr = {"Xcoord":evt.mapPoint.x,"Ycoord":evt.mapPoint.y,"Plant":"Mesa Mint"};
var infoTemplate = new InfoTemplate("Vernal Pool Locations","Latitude: ${Ycoord} <br/>
    Longitude: ${Xcoord} <br/>
    Plant Name:${Plant}");
var graphic = new Graphic(pt,pms,attr,infoTemplate);
map.graphics.add(graphic)

where attr will be the attributes of the feature, and anything inside ${} is one of the field names in attr. I normally like to create a separate graphics layer so not to pollute map.graphics, and you will have more control over the graphics added.

Hope it helps.


Thank you, I will give it a shot.
0 Kudos