Skip to content

Instantly share code, notes, and snippets.

@aaizemberg
Last active November 28, 2019 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aaizemberg/0095a7795ae6cc0d451b to your computer and use it in GitHub Desktop.
Save aaizemberg/0095a7795ae6cc0d451b to your computer and use it in GitHub Desktop.
real time marker (#mapbox,

Cuando se hace una consulta a esta URL --> https://wanderdrone.appspot.com/

Se devuelve un GeoJSON:

{"geometry": {"type": "Point", "coordinates": [-80.318956205249776, 21.32829010710741]}, "type": "Feature", "properties": {}}

JSON Pretty Print

{  
   "geometry":{  
      "type":"Point",
      "coordinates":[  
         -80.318956205249776,
         21.32829010710741
      ]
   },
   "type":"Feature",
   "properties":{  

   }
}
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>GeoJSON from live realtime data</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox.js/v2.1.9/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v2.1.9/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id='map'></div>
<script>
L.mapbox.accessToken = 'pk.eyJ1IjoiYWFpemVtYmVyZyIsImEiOiJIQmdlUkVzIn0.kzKfi1ndNMUcY4sH07RaUQ';
var map = L.mapbox.map('map', 'mapbox.streets')
.setView([38, -102.0], 2);
// As with any other AJAX request, this technique is subject to the Same Origin Policy:
// http://en.wikipedia.org/wiki/Same_origin_policy
var featureLayer = L.mapbox.featureLayer()
.loadURL('https://wanderdrone.appspot.com/')
// Once this layer loads, we set a timer to load it again in a few seconds.
.on('ready', run)
.addTo(map);
function run() {
featureLayer.eachLayer(function(l) {
map.panTo(l.getLatLng());
});
window.setTimeout(function() {
featureLayer.loadURL('https://wanderdrone.appspot.com/');
}, 2000);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment