Drawing custom markers onto leaflet powered maps

During the life cycle of quite a number of web mapping projects, the GI user may want to deploy his or her custom markers or icons to symbolize points on the map.Our demonstration in this post will create a simple script where custom markers in svg format hosted on the web are added onto our leaflet powered map. Custom markers allows the map creator to enhance the cartographic visualization of the end user.


Lets create a simple leaflet map with base map tiles provided by Esri. Load point features in geojson file format and draw them to the map.

By default, the markers will appear in blue pin style on the map.

See source code of the map showing default markers




Next write out the var icon layer below the var points layer.

This will load custom markers on file or from the web.

Replace the previous L.geoJson(points… in the code with the one below.

Use the pointToLayer options to draw the new icons onto

the leaflet map.


var icon = L.icon({
iconSize: [30, 30]
L.geoJson(points, {
pointToLayer: function(feature, latlng){
marker = L.marker(latlng, {icon: icon})
marker.bindPopup(feature.properties.name_1 + ‘<br>’ + feature.properties.ph)
return marker;}




View live map at


Download plain text version of the source code https://www.dropbox.com/s/c8eg71vdhwg7xr9/loading%20custom%20markers%20onto%20leaflet%20powered%20maps.txt?dl=0


Thank you for following the blog.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s