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

[ready] address raster flickering #7942

Closed
wants to merge 10 commits into from
100 changes: 100 additions & 0 deletions debug/zoomrange.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!DOCTYPE html>
peterqliu marked this conversation as resolved.
Show resolved Hide resolved
<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%; }
</style>
</head>

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

<script src='../dist/mapbox-gl-dev.js'></script>
<script src='/debug/access_token_generated.js'></script>
<script>

var style = {
"version": 8,
"name": "Satellite",
"metadata": {
"mapbox:autocomposite": true,
"mapbox:type": "default"
},
"sources": {
"mapbox": {
"type": "raster",
"url": "mapbox://mapbox.satellite",
"tileSize": 256
}
},
"sprite": "mapbox://sprites/mapbox/satellite-v9",
"glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
"layers": [
{
"id": "background",
"type": "background",
"paint": {
"background-color": "rgb(4,7,14)"
}
},
{
"id": "satellite",
"type": "raster",
"source": "mapbox",
"source-layer": "mapbox_satellite_full",
"minzoom": 1,
"maxzoom": 2,
}
],
"created": "1970-01-01T00:00:00.000Z",
"modified": "1970-01-01T00:00:00.000Z",
"owner": "mapbox",
"id": "satellite-v9",
"draft": false,
"visibility": "public"
};

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

map.on('load', function() {

map.addLayer({
"id": "circle",
"type": "circle",
"source": {
"type": "geojson",
"data": {
"type": "Point",
"coordinates": [
0,
0
]
}
},
"minzoom": 0,
"maxzoom": 2,
'paint': {
'circle-color': 'red',
'circle-radius':20
}
});

map.on('click', function() {
map.setLayerZoomRange('satellite', 0, 5);
map.setLayerZoomRange('circle', 1, 22);
});
});

</script>
</body>
</html>
4 changes: 3 additions & 1 deletion src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,9 @@ class Style extends Evented {
if (maxzoom != null) {
layer.maxzoom = maxzoom;
}
this._updateLayer(layer);

this._updatedLayers[layer.id] = true;
this._changed = true;
}

setFilter(layerId: string, filter: ?FilterSpecification, options: StyleSetterOptions = {}) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions test/integration/render-tests/zoom-visibility/now-above/style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"version": 8,
"center": [
13.418056,
52.499167
],
"metadata": {
"test": {
"width": 64,
"height": 64,
"operations": [
[
"setZoom",
16
],
[
"wait"
],
[
"setLayerZoomRange",
"circle",
0,
2
],
[
"wait"
],
[
"setLayerZoomRange",
"raster",
0,
2
],
[
"wait"
]
]
}
},
"sources": {
"satellite": {
"type": "raster",
"tiles": [
"local://tiles/{z}-{x}-{y}.satellite.png"
],
"maxzoom": 17,
"tileSize": 256
},
"geojson": {
"type": "geojson",
"data": {
"type": "Point",
"coordinates": [
13.418056,
52.499167
]
}
}
},
"layers": [
{
"id": "raster",
"type": "raster",
"source": "satellite",
"minzoom": 0,
"maxzoom": 22,
"paint": {
"raster-fade-duration": 0
}
},
{
"id": "circle",
"type": "circle",
"source": "geojson",
"minzoom": 0,
"maxzoom": 22,
"paint": {
"circle-color": "red"
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions test/integration/render-tests/zoom-visibility/now-below/style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"version": 8,
"center": [
13.418056,
52.499167
],
"metadata": {
"test": {
"width": 64,
"height": 64,
"operations": [
[
"setZoom",
16
],
[
"wait"
],
[
"setLayerZoomRange",
"circle",
20,
22
],
[
"wait"
],
[
"setLayerZoomRange",
"raster",
20,
22
],
[
"wait"
]
]
}
},
"sources": {
"satellite": {
"type": "raster",
"tiles": [
"local://tiles/{z}-{x}-{y}.satellite.png"
],
"maxzoom": 17,
"tileSize": 256
},
"geojson": {
"type": "geojson",
"data": {
"type": "Point",
"coordinates": [
13.418056,
52.499167
]
}
}
},
"layers": [
{
"id": "raster",
"type": "raster",
"source": "satellite",
"minzoom": 0,
"maxzoom": 22,
"paint": {
"raster-fade-duration": 0
}
},
{
"id": "circle",
"type": "circle",
"source": "geojson",
"minzoom": 0,
"maxzoom": 22,
"paint": {
"circle-color": "red"
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 41 additions & 7 deletions test/integration/render-tests/zoom-visibility/was-above/style.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
{
"version": 8,
"center": [
peterqliu marked this conversation as resolved.
Show resolved Hide resolved
13.418056,
52.499167
],
"metadata": {
"test": {
"width": 64,
"height": 64,
"operations": [
[
"setZoom",
2.1
16
],
[
"wait"
],
[
"setLayerZoomRange",
"circle",
1,
3
0,
22
],
[
"wait"
],
[
"setLayerZoomRange",
"raster",
0,
22
],
[
"wait"
Expand All @@ -25,24 +38,45 @@
}
},
"sources": {
"satellite": {
"type": "raster",
"tiles": [
"local://tiles/{z}-{x}-{y}.satellite.png"
],
"maxzoom": 17,
"tileSize": 256
},
"geojson": {
"type": "geojson",
"data": {
"type": "Point",
"coordinates": [
0,
0
13.418056,
52.499167
]
}
}
},
"layers": [
{
"id": "raster",
"type": "raster",
"source": "satellite",
"minzoom": 0,
"maxzoom": 2,
"paint": {
"raster-fade-duration": 0
}
},
{
"id": "circle",
"type": "circle",
"source": "geojson",
"minzoom": 1,
"maxzoom": 2
"minzoom": 0,
"maxzoom": 2,
"paint": {
"circle-color": "red"
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading