Select to view content in your preferred language

simple (hopefully) offset marker pin

1506
4
07-08-2010 05:44 AM
AdrianMarsden
Honored Contributor
Hi

I'm using

var IDsymbol = new esri.symbol.PictureMarkerSymbol('URL', 20, 34);
var graphic = new esri.Graphic(evt.mapPoint, IDsymbol);
map.graphics.add(graphic);

to add a Pin marker (like a Google one) where an identify request is made - but I want to offset the image, so the point of the pin is where the click was - I've had some quick goes at changing this but can't get it.

Cheers

ACM
0 Kudos
4 Replies
AdamPfister
Esri Contributor
picturemarkersymbol is a subclass of markersymbol that has a "setOffset(x,y)" method.  i think that should work for you.

check the API docs:
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/markersymbol.htm
0 Kudos
AdrianMarsden
Honored Contributor
many thanks - one of those very easy when shown how things that novices like me struggle with. For future reference the line became

var IDsymbol = new esri.symbol.PictureMarkerSymbol('http://domain.co.uk/mapping/Mapmarker.png', 20, 34).setOffset(0,16);

makes all the difference

Cheers

ACM
0 Kudos
ReneRubalcava
Esri Frequent Contributor
Not sure I quite understand, but I usually set the offset to half the height, so that the bottom of the marker, usually a pointer or flag will be at the actual x/y of the graphic.

var pm_sym = new esri.symbol.PictureMarkerSymbol({
          url: "images/stop-sign_alt.png",
          height: 26,
          width: 24,
          yoffset: 26 / 2,
          type: "esriPMS"
        });
0 Kudos
RexBradford
Emerging Contributor
Not sure I quite understand, but I usually set the offset to half the height, so that the bottom of the marker, usually a pointer or flag will be at the actual x/y of the graphic.

var pm_sym = new esri.symbol.PictureMarkerSymbol({
          url: "images/stop-sign_alt.png",
          height: 26,
          width: 24,
          yoffset: 26 / 2,
          type: "esriPMS"
        });


When the marker is scaled, i.e. the width and height passed in to PictureMarkerSymbol is not the same as the source image's width and height, which is being "offsetted"?  To achieve the effect above, should I pass in yoffset = half the height being supplied, or half the height of the source png file?

Thanks,

Rex Bradford
Direct Relief International
0 Kudos