Custom icon for L.mapquest.textMarker

6 posts / 0 new
Last post
LavidSoftware
Custom icon for L.mapquest.textMarker

Hello again,

i am almost finish with the change-over from old to new mapquest api.

We use our own icons for markers. Is it possible to add a custom icon to L.mapquest.textMarker?

We cannot use L.marker, because we need the text attribute.

Thank you for your help.


MQBrianCoakley
The default icon can be
The default icon can be customized but it does not support external icons. yet. This has been forwarded on to the team as an enhancement request.

LavidSoftware
Thanks! Would be great if it

Thanks! Would be great if it is implemented.


MQBrianCoakley
Thanks for the suggestion!
Thanks for the suggestion!

jonhardison
Any word?

I've been digging around trying to figure out a solution to this issue and stumbled on this thread. Any word on? This would be GREAT!

 


jonhardison
temporary fix with CSS

I've resolved the issue in a way that will allow the use of a custom icon using CSS.
Have a look:

.leaflet-marker-pane img { //target the map pin class.
    display: block;-moz-box-sizing: border-box;
    box-sizing: border-box;
    background: url(YOUR-PIN.PNG) no-repeat;
    background-size: ??px ??px; //the total width and height of your pin graphic
    width: 54px !important; //the total width of your pin graphic
    height: 54px !important; //the total height of your pin graphic
    padding-left: ??px; // the total width of your pin graphic - This will push the default pin out of view so your background image shows.
    margin-left: -??px !important; // adjust the location of your pin graphic. If you want your graphic to center on the map location this value should be half your graphic's width. (example: Your pin is 50px wide and 80px tall. This to center the graphic over the pined map location this value should be -25px.)
margin-top: -??px !important; // adjust the location of your pin graphic. If you want your graphic to center on the map location this value should be half your graphic's height. (example: Your pin is 50px wide and 50px tall. This to center the graphic over the pined map location this value should be -40px.)
}

Hope this helps anyone that really needs this to work because MapQuest introduces a supported fix.