Last active
November 30, 2016 13:18
-
-
Save asmaloney/a632bbf8dd5cda2544ad15e2497d0d88 to your computer and use it in GitHub Desktop.
Modified leaflet example for Rich
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type='text/javascript'> | |
var markers = [ | |
{ | |
"name": "Canada", | |
"url": "https://en.wikipedia.org/wiki/Canada", | |
"lat": 56.130366, | |
"lng": -106.346771 | |
}, | |
{ | |
"name": "Anguilla", | |
"details": "favoriteMusic: <a href=\"#\" rel=\"nofollow\">80s Rock</a>", | |
"url": "https://en.wikipedia.org/wiki/Anguilla", | |
"lat": 18.220554, | |
"lng": -63.068615 | |
} | |
]; | |
var map = L.map( 'map', { | |
center: [20.0, 5.0], | |
minZoom: 2, | |
zoom: 2 | |
}) | |
L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | |
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>', | |
subdomains: ['a', 'b', 'c'] | |
}).addTo( map ) | |
var myIcon = L.icon({ | |
iconUrl: 'maps/images/pin24.png', | |
iconRetinaUrl: 'maps/images/pin48.png', | |
iconSize: [29, 24], | |
iconAnchor: [9, 21], | |
popupAnchor: [0, -14] | |
}) | |
for ( var i=0; i < markers.length; ++i ) | |
{ | |
L.marker( [markers[i].lat, markers[i].lng], {icon: myIcon} ) | |
.bindPopup( '<a href="' + markers[i].url + '" target="_blank">' + markers[i].name + '</a><br/>' + markers[i].details ) | |
.addTo( map ); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment