SHOW:
|
|
- or go back to the newest paste.
| 1 | // create a variable to store Stamen 'toner' tiles | |
| 2 | var layer = new L.StamenTileLayer("toner");
| |
| 3 | ||
| 4 | // initialize and set map center and zoom | |
| 5 | var map = L.map('map', {
| |
| 6 | center: new L.LatLng(40.67, -73.94), | |
| 7 | zoom: 11, | |
| 8 | minZoom: 11, | |
| 9 | maxZoom: 16 | |
| 10 | }); | |
| 11 | ||
| 12 | // add the Stamen layer to the map | |
| 13 | map.addLayer(layer); | |
| 14 | ||
| 15 | // create an object to store marker style properties | |
| 16 | var geojsonMarkerOptions = {
| |
| 17 | maxWidth: 400, | |
| 18 | radius: 10, | |
| 19 | fillColor: "rgb(255,0,195)", | |
| 20 | color: "#fff", | |
| 21 | weight: 2, | |
| 22 | opacity: 1, | |
| 23 | fillOpacity: 1 | |
| 24 | }; | |
| 25 | ||
| 26 | // function that will create pop-ups | |
| 27 | function onEachFeature(feature, layer) {
| |
| 28 | var popupContent, | |
| 29 | popupOptions = geojsonMarkerOptions; | |
| 30 | ||
| 31 | popupContent = feature.properties.t; | |
| 32 | ||
| 33 | // create a new variable to store Date in | |
| 34 | var time = new Date(0); | |
| 35 | // create a date by passing it the Unix UTC epoch | |
| 36 | time.setUTCSeconds(popupContent); | |
| 37 | ||
| 38 | popupContent = time; | |
| 39 | ||
| 40 | console.log(popupContent); | |
| 41 | ||
| 42 | layer.bindPopup("<b>Time:</b> " + time +
| |
| 43 | "<br><b>Altitude: </b>" + feature.properties.alt + "meters" | |
| 44 | ,popupOptions); | |
| 45 | } | |
| 46 | ||
| 47 | // create new layer to store geojson | |
| 48 | var myLayer = L.geoJson().addTo(map); | |
| 49 | ||
| 50 | - | // to store lat lon of scrambled data |
| 50 | + | |
| 51 | - | var test; |
| 51 | + | |
| 52 | $.getJSON("data/test_random.json", function(json) {
| |
| 53 | myLayer.addData(json); | |
| 54 | }) | |
| 55 | .done(function (response) {
| |
| 56 | scrambledGeo = L.geoJson(response, {
| |
| 57 | - | var items = []; |
| 57 | + | |
| 58 | - | $.each( json, function(key, val){
|
| 58 | + | |
| 59 | - | items.push |
| 59 | + | |
| 60 | - | }) |
| 60 | + | |
| 61 | fillColor: 'FFFFFF', | |
| 62 | - | //test.append(items); |
| 62 | + | |
| 63 | - | console.log(test); |
| 63 | + | |
| 64 | }, | |
| 65 | ||
| 66 | onEachFeature: onEachFeature, | |
| 67 | ||
| 68 | pointToLayer: function (feature, latlng) {
| |
| 69 | return L.circleMarker(latlng, geojsonMarkerOptions) | |
| 70 | } | |
| 71 | ||
| 72 | }).addTo(map); | |
| 73 | }) |