diff options
| author | Yuval Adam <yuv.adm@gmail.com> | 2013-01-14 22:06:52 +0200 |
|---|---|---|
| committer | Yuval Adam <yuv.adm@gmail.com> | 2013-01-14 22:06:56 +0200 |
| commit | 027e9de06e83eb5c04866ecef16e8ee323f9ee9c (patch) | |
| tree | c75ae28587f2288c54a09f2f901b328556504da6 | |
| parent | 2b2820e5425c486930175f913c21a6f6bca2a654 (diff) | |
Drop all markers on map, it's heavy
| -rw-r--r-- | cities.json | 2 | ||||
| -rw-r--r-- | index.html | 24 |
2 files changed, 16 insertions, 10 deletions
diff --git a/cities.json b/cities.json index 6cb8901..7d82cdb 100644 --- a/cities.json +++ b/cities.json @@ -1,4 +1,4 @@ -{ +cities = { "": { "status": "ZERO_RESULTS", "results": [] @@ -4,7 +4,9 @@ <meta charset="utf8"> <title>Elections 2013 Map</title> <link rel="stylesheet" href="http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.css"> - <script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js'></script> + <script src="http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js"></script> + <script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.3/underscore-min.js"></script> + <script src="cities.json"></script> </head> <body> <h1>Elections 2013 Map</h1> @@ -19,14 +21,18 @@ map.addLayer(markerLayer); map.centerzoom({lat: 31.54, lon: 35.23}, 7); - markerLayer.add_feature({ - geometry: { coordinates: [35.2, 31.5] }, - properties: { - 'marker-color': '#000', - 'marker-symbol': 'star-stroked', - title: 'Example Marker', - description: 'This is a single marker.' - } + _.each(cities, function(v, k){ + if (v.status == "OK") { + var location = v.results[0].geometry.location; + markerLayer.add_feature({ + geometry: { coordinates: [location.lng, location.lat] }, + properties: { + // 'marker-color': '#000', + // 'marker-symbol': 'star-stroked', + title: k + } + }); + }; }); </script> </body> |
