skip to Main Content

I’m new to mapbox and need help about customizing the marker.

I have uploaded a csv file to my map through omnivore
using this code:
omnivore.csv('LL62AP0720.csv')
.addTo(map);

The csv contains 600 records.

How can I customize the marker to my own image?
I created the marker image in photoshop and how can I apply it to the map?

Thanks!

I tried writing these code:

omnivore.csv('LL62AP0720.csv')
.on('ready',function(layer) {  
this.eachLayer(function(marker){
marker.setIcon(L.mapbox.marker.icon({
'marker-color':'#ff8888',
}));
});

Is there a way to import the local image to the marker? I think I should add something after the ‘marker-color’ code, but I don’t know what is the right code.

2

Answers


  1. Try with this, see this example

     marker.setIcon(L.icon({
                "iconUrl": "/imageURL",
                "iconSize": [100, 100],
                "iconAnchor": [50, 50],
                "popupAnchor": [0, -55],
                "className": "dot"
            }));
    
    Login or Signup to reply.
  2. Use some external library, which could enable you to write HTML/CSS/JavaScript to fully customized marker just like implementing other parts of the page, like one navbar.

    http://easysublease.org/mapcoverjs/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search