Skip to content

Commit

Permalink
Added live GeoJSON example
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Wojciechowski committed Oct 23, 2015
1 parent d932579 commit b38be16
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions docs/_posts/examples/3400-01-10-live-geojson.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
layout: example
category: example
title: GeoJSON from live realtime data
description: Moving a marker based on an API response of GeoJSON data.
---
<div id='map'></div>

<script>
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v8',
zoom: 0
});

var url = 'https://wanderdrone.appspot.com/';
var source = new mapboxgl.GeoJSONSource({
data: url
});
window.setInterval(function() {
source.setData(url);
}, 2000);

map.on('style.load', function () {
map.addSource('drone', source);
map.addLayer({
"id": "drone",
"type": "symbol",
"source": "drone",
"layout": {
"icon-image": "rocket-15",
}
});
});
</script>

0 comments on commit b38be16

Please sign in to comment.