Question

I'd like to position my custom marker on MapQuest, because location is poiting at the middle of the icon, not at the bottom of the icon (icon is a image of "pin").

var icon=new MQA.Icon("/images/market.png",30,70);
    locator.setIcon(icon);
    map.addShape(locator);

Thanks a lot in advance

Was it helpful?

Solution

Disclaimer: I work for MapQuest.

You can position custom icons using the setIconOffset method on your POI. Here's a quick example:

var myIcon=new MQA.Poi( {lat:39.739217, lng:-104.984861} );
myIcon.setIcon(new MQA.Icon('img/arrowicon.png', 72, 87));
myIcon.setIconOffset(new MQA.Point(-43,-72));

The first number you pass into MQA.Point is essentially the CSS left offset of the icon, while the second is the top.

If you need help, don't hesitate to comment back or check out the Forums on the MapQuest Developer Network.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top