Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Source interface to allow/prepare for extensibility #2667

Merged
merged 68 commits into from
Jul 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
4fe07e4
Add optional callback for dispatcher.broadcast
May 17, 2016
0ac57ec
Major refactor to Source interface
May 17, 2016
d456d53
Move coveringZoomLevel, coveringTiles to Transform
May 27, 2016
f68be4e
Refactor raster source to new interface
May 27, 2016
e7a103c
WIP - refactor video source
May 28, 2016
aa8a101
Reload pyramid in onChange()
May 28, 2016
98a63b5
Reinstate query*Features
May 28, 2016
f01ce89
Restore validateStyle to top of style init
Jun 3, 2016
6cd84a2
Small edits from PR comments
Jun 7, 2016
5298d03
Go back to mixing in Evented in Source impls
Jun 7, 2016
d05056f
Drop Source.is
Jun 7, 2016
98eb8b0
Enforce correct source.id value
Jun 7, 2016
6cb89c9
s/cb/callback
Jun 7, 2016
5f8ac39
Fix extend/inherit and other minor errors
Jun 7, 2016
2596891
Use more descriptive names for Source methods
Jun 9, 2016
922ca7b
Rename TilePyramid to SourceCache
Jun 9, 2016
e55a030
Remove bucketStats
Jun 10, 2016
2e27d07
Remove unused var
Jun 10, 2016
1b22daf
Simplify GeoJSONWorkerSource
Jun 10, 2016
6411432
Fix geojson_source.test
Jun 14, 2016
51de91c
s/tile_pyramid/source_cache
Jun 14, 2016
8d11c5d
Fix source_cache tests
Jun 14, 2016
8d71570
Restore 'ignore reload' test, now in source_cache
Jun 15, 2016
68ef2e2
Fix vector_tile_source.test
Jun 15, 2016
a333ae9
Fix style.test
Jun 15, 2016
cd4aa8f
Fix map tests
Jun 15, 2016
d1cbbc4
Remove async loading of core source types
Jun 16, 2016
d4bfe10
s/query-features.js/query_features.js
Jun 16, 2016
17c9c91
Replace old queryRenderedFeature edge case test
Jun 16, 2016
6ab8013
Replace old GeoJSONSource test
Jun 16, 2016
9ff61c4
Improve getSource API
Jun 16, 2016
fc280e6
Treat errored source as loaded()
Jun 16, 2016
35e19c0
Add some docs to geojson_worker_source
Jun 16, 2016
9330bc4
Add supercluster-specific debug page
Jun 16, 2016
2ebc03d
Fix typo
Jun 16, 2016
b688be4
Fix 'geojson / reparse-overscaled' render test
Jun 16, 2016
73c6028
Fix lint
Jun 16, 2016
c53526d
Correctly handle Source error events
Jun 17, 2016
fddd401
WIP - add more docs
Jun 17, 2016
0a25b90
Fix generated doc output
Jun 17, 2016
8fcec8d
Do not call prepare() unless source is ready
Jun 17, 2016
b80ff64
Fix VideoSource
Jun 17, 2016
91d6d38
Add image.html debug page
Jun 17, 2016
319474a
Fix ImageSource
Jun 17, 2016
7bc469d
Fix render tests
Jun 18, 2016
b0b5654
Revise addSourceType API and add basic tests.
Jun 20, 2016
5f7d6fc
Make GeoJSONSource more hackable
Jun 20, 2016
58305ba
Suppress signature and params in @interface docs
Jun 21, 2016
fea6718
Improve custom source type docs
Jun 21, 2016
db13933
Update GeoJSONSource,VideoSource,ImageSource docs
Jun 21, 2016
80d0270
Throw from addSource if source.type is missing
Jun 21, 2016
b2f758c
Update GeoJSON source examples
Jun 21, 2016
f30a746
load-tilejson => load_tilejson
Jun 29, 2016
0619b49
Move _sendDataToWorker to setData
Jun 30, 2016
9d072ce
Revert to new-based API for sources
Jul 1, 2016
96a6983
Drop extra cluster stuff from default debug page.
Jul 1, 2016
020660c
Dedupe debug & test-suite assets
Jul 1, 2016
f45a8d2
Factor VectorTileWorkerSource out of Worker
Jul 5, 2016
e61f2a4
Fix tests
Jul 5, 2016
57a61c8
Update registerWorkerSource to current WorkerSource interface
Jul 5, 2016
e3c462d
Fix test after rebase
Jul 14, 2016
560529e
Image/Video: tile.loaded|errored => tile.state
Jul 14, 2016
ed19027
Restore *.tile events on sources
Jul 20, 2016
c991549
Hide custom source classes / interfaces from documentation
Jul 20, 2016
ad2e938
Namespace mapbox-gl-test-suite files in debug server
Jul 20, 2016
54284d8
Add source docs
Jul 20, 2016
030647d
Remove GeoJSONSource, VideoSource, ImageSource from the public interface
Jul 20, 2016
9f434bd
Minor GeoJSONSource simplification
Jul 20, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## master

#### Breaking Changes

* The `GeoJSONSource`, `VideoSource`, `ImageSource` constructors are now private. Please use `map.addSource({...})` to create sources and `map.getSource(...).setData(...)` to update GeoJSON sources.

## 0.21.0 (July 13 2016)

#### Breaking Changes
Expand Down
4 changes: 2 additions & 2 deletions debug/circles.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<script>
var map = window.map = new mapboxgl.Map({
container: 'map',
zoom: 12.5,
zoom: 3,
center: [-77.01866, 38.888],
style: 'mapbox://styles/mapbox/streets-v9',
hash: true
Expand All @@ -68,7 +68,7 @@

map.addSource('circles', {
"type": "geojson",
"data": "random.geojson"
"data": "mapbox-gl-test-suite/data/places.geojson"
});

map.addLayer({
Expand Down
167 changes: 167 additions & 0 deletions debug/cluster.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<!DOCTYPE html>
<html>
<head>
<title>Mapbox GL JS debug page</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">

<link rel='stylesheet' href='../dist/mapbox-gl.css' />
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
#checkboxes {
position: absolute;
background: #fff;
top:0;
left:0;
padding:10px;
}
#buffer {
position: absolute;
top:100px;
left:0;
pointer-events: none;
}
#buffer div {
background-color: #fff;
padding: 5px 0;
text-indent: 10px;
white-space: nowrap;
text-shadow:
-1px -1px 0 #fff,
1px -1px 0 #fff,
-1px 1px 0 #fff,
1px 1px 0 #fff;
}
</style>
</head>

<body>
<div id='map'></div>
<div id='checkboxes'>
<input id='show-tile-boundaries-checkbox' name='show-tile-boundaries' type='checkbox'> <label for='show-tile-boundaries'>tile debug</label><br />
<input id='show-symbol-collision-boxes-checkbox' name='show-symbol-collision-boxes' type='checkbox'> <label for='show-symbol-collision-boxes'>collision debug</label><br />
<input id='show-overdraw-checkbox' name='show-overdraw' type='checkbox'> <label for='show-overdraw'>overdraw debug</label><br />
<input id='buffer-checkbox' name='buffer' type='checkbox'> <label for='buffer'>buffer stats</label>
</div>

<div id='buffer' style="display:none">
<em>Waiting for data...</em>
</div>

<script src='mapbox-gl.js'></script>
<script src='access-token.js'></script>

<script>
var style = {
"version": 8,
"metadata": {
"test": {
"native": false,
"width": 512,
"height": 512
}
},
"center": [
0,
0
],
"zoom": 0,
"sources": {
"geojson": {
"type": "geojson",
"data": "mapbox-gl-test-suite/data/places.geojson",
"cluster": true,
"clusterRadius": 25
}
},
"glyphs": "mapbox-gl-test-suite/glyphs/{fontstack}/{range}.pbf",
"layers": [
{
"id": "cluster",
"type": "circle",
"source": "geojson",
"filter": [
"==",
"cluster",
true
],
"paint": {
"circle-color": "rgba(0, 200, 0, 1)",
"circle-radius": 20
}
},
{
"id": "cluster_label",
"type": "symbol",
"source": "geojson",
"filter": [
"==",
"cluster",
true
],
"layout": {
"text-field": "{point_count}",
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
],
"text-size": 12,
"text-allow-overlap": true,
"text-ignore-placement": true
}
},
{
"id": "unclustered_point",
"type": "circle",
"source": "geojson",
"filter": [
"!=",
"cluster",
true
],
"paint": {
"circle-color": "rgba(0, 0, 200, 1)",
"circle-radius": 10
}
}
]
}

var map = window.map = new mapboxgl.Map({
container: 'map',
style: style,
hash: true
});

map.addControl(new mapboxgl.Navigation());
map.addControl(new mapboxgl.Geolocate());

document.getElementById('show-tile-boundaries-checkbox').onclick = function() {
map.showTileBoundaries = !!this.checked;
};

document.getElementById('show-symbol-collision-boxes-checkbox').onclick = function() {
map.showCollisionBoxes = !!this.checked;
};

document.getElementById('show-overdraw-checkbox').onclick = function() {
map.showOverdrawInspector = !!this.checked;
};

document.getElementById('buffer-checkbox').onclick = function() {
document.getElementById('buffer').style.display = this.checked ? 'block' : 'none';
};

// keyboard shortcut for comparing rendering with Mapbox GL native
document.onkeypress = function(e) {
if (e.charCode === 111 && !e.shiftKey && !e.metaKey && !e.altKey) {
var center = map.getCenter();
location.href = "mapboxgl://?center=" + center.lat + "," + center.lng + "&zoom=" + map.getZoom() + "&bearing=" + map.getBearing();
return false;
}
};
</script>

</body>
</html>
60 changes: 60 additions & 0 deletions debug/image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!DOCTYPE html>
<html>
<head>
<title>Mapbox GL JS debug page</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel='stylesheet' href='../dist/mapbox-gl.css' />
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
</style>
</head>

<div id='map'></div>

<script src='mapbox-gl.js'></script>
<script src='access-token.js'></script>

<script>
var imageStyle = {
"version": 8,
"sources": {
"image": {
"type": "image",
"url": "mapbox-gl-test-suite/image/0.png",
"coordinates": [
[-122.51596391201019, 37.56238816766053],
[-122.51467645168304, 37.56410183312965],
[-122.51309394836426, 37.563391708549425],
[-122.51423120498657, 37.56161849366671]
]
}
},
"layers": [{
"id": "background",
"type": "background",
"paint": {
"background-color": "rgb(4,7,14)"
}
}, {
"id": "image",
"type": "raster",
"source": "image"
}]
};

var map = new mapboxgl.Map({
container: 'map',
minZoom: 14,
zoom: 17,
center: [-122.514426, 37.562984],
bearing: -96,
style: imageStyle,
hash: false
});
</script>

</body>
</html>
2 changes: 1 addition & 1 deletion debug/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
map.on('load', function() {
map.addSource('geojson', {
"type": "geojson",
"data": "route.json"
"data": "mapbox-gl-test-suite/data/linestring.geojson"
});

map.addLayer({
Expand Down
49 changes: 19 additions & 30 deletions debug/featuresIn.html → debug/queryFeatures.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,17 @@
var map = new mapboxgl.Map({
container: 'map',
zoom: 12.5,
center: [38.888, -77.01866],
center: [-77.01866, 38.888],
hash: true,
style: 'mapbox://styles/mapbox/streets-v9'
});

map.addControl(new mapboxgl.Navigation());

var querySource = new mapboxgl.GeoJSONSource({
data: { type: 'FeatureCollection', features: [] }
});
var boxSource = new mapboxgl.GeoJSONSource({
data: { type: 'FeatureCollection', features: [] }
});
var emptyFc = { type: 'FeatureCollection', features: [] }

map.on('style.load', function() {
map.addSource('queried', querySource);
map.addSource('queried', { type: 'geojson', data: emptyFc });
map.addLayer({
"id": "query",
"type": "line",
Expand All @@ -47,7 +42,7 @@
}
}, 'country-label-sm');

map.addSource('boxsource', boxSource);
map.addSource('boxsource', { type: 'geojson', data: emptyFc });
map.addLayer({
"id": "box",
"type": "fill",
Expand Down Expand Up @@ -81,28 +76,22 @@
[boxcoords[1][0], boxcoords[0][1]],
boxcoords[0]
];
var results = map.queryRenderedFeatures(box, {})
map.getSource('queried').setData({
type: 'FeatureCollection',
features: results
});

console.log('box', boxcoords);
map.queryRenderedFeatures(box, {
includeGeometry: true
}, function (err, results) {
console.log('queryRenderedFeatures', box, err, results);
querySource.setData({
type: 'FeatureCollection',
features: results
});

boxSource.setData({
type: 'FeatureCollection',
features: [{
type: 'Feature',
properties: {},
geometry: {
type: 'LineString',
coordinates: boxcoords
}
}]
});
map.getSource('boxsource').setData({
type: 'FeatureCollection',
features: [{
type: 'Feature',
properties: {},
geometry: {
type: 'LineString',
coordinates: boxcoords
}
}]
});
}
});
Expand Down
1 change: 0 additions & 1 deletion debug/random.geojson

This file was deleted.

10 changes: 0 additions & 10 deletions debug/route.json

This file was deleted.

13 changes: 5 additions & 8 deletions docs/_posts/examples/3400-01-10-live-geojson.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
});

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

map.on('load', function () {
map.addSource('drone', source);
window.setInterval(function() {
map.getSource('drone').setData(url);
}, 2000);

map.addSource('drone', { type: 'geojson', data: url });
map.addLayer({
"id": "drone",
"type": "symbol",
Expand Down
Loading