Advertisement
Guest User

Untitled

a guest
Oct 21st, 2013
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  51. // jquery ajax call to grab json
  52. $.getJSON("data/test_random.json", function(json) {
  53.   myLayer.addData(json);
  54. })
  55.     .done(function (response) {
  56.             scrambledGeo = L.geoJson(response, {
  57.  
  58.                 style: function (feature) {
  59.                     return {
  60.                         stroke: false,
  61.                         fillColor: 'FFFFFF',
  62.                         fillOpacity: 0
  63.                     };
  64.                 },
  65.  
  66.                 onEachFeature: onEachFeature,
  67.              
  68.             pointToLayer: function (feature, latlng) {
  69.                        return L.circleMarker(latlng, geojsonMarkerOptions)
  70.                     }
  71.  
  72.             }).addTo(map);
  73.         })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement