Guest User

Untitled

a guest
Oct 21st, 2013
120
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. // to store lat lon of scrambled data
  51. var test;
  52.  
  53. // jquery ajax call to grab json
  54. $.getJSON("data/test_random.json", function(json) {
  55.   myLayer.addData(json);
  56.  
  57.   var items = [];
  58.   $.each( json, function(key, val){
  59.     items.push
  60.   })
  61.  
  62.   //test.append(items);
  63.   console.log(test);
  64.  
  65. })
  66.     .done(function (response) {
  67.             scrambledGeo = L.geoJson(response, {
  68.  
  69.                 style: function (feature) {
  70.                     return {
  71.                         stroke: false,
  72.                         fillColor: 'FFFFFF',
  73.                         fillOpacity: 0
  74.                     };
  75.                 },
  76.  
  77.                 onEachFeature: onEachFeature,
  78.  
  79.             }).addTo(map);
  80.         })
Advertisement
Add Comment
Please, Sign In to add comment