Created
November 14, 2014 20:42
-
-
Save vschmidt94/5b4b82787cd94cbd48a3 to your computer and use it in GitHub Desktop.
Adding a collection of markers to Leaflet.js map & binding popups
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
| var map2 = L.map('map2').setView([44.56357, -123.28141355887], 14); | |
| L.tileLayer('http://{s}.tiles.mapbox.com/v3/YOUR_MAP_ID_HERE/{z}/{x}/{y}.png', | |
| { | |
| attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>', | |
| maxZoom: 18 | |
| }).addTo(map2); | |
| var points = [ | |
| { | |
| 'name': 'Valley Library', | |
| 'lat': 44.5650618928, | |
| 'lng': -123.27603917 | |
| }, | |
| { | |
| 'name': 'Cascade Hall', | |
| 'lat': 44.5615013978, | |
| 'lng': -123.275598074 | |
| }, | |
| { | |
| 'name': 'Reser Stadium', | |
| 'lat': 44.559575735338, | |
| 'lng': -123.28141355887 | |
| } | |
| ]; | |
| var markers = new Array(); | |
| for (i = 0; i < points.length; i++) { | |
| markers[i] = L.marker([points[i].lat, points[i].lng]).addTo(map2); | |
| markers[i].bindPopup(points[i].name); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment