forked from maplibre/maplibre-gl-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'cooperative-gestures-fix' into cooperative-gestures-enable
- Loading branch information
Showing
3 changed files
with
157 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>MapLibre GL JS debug page</title> | ||
<meta charset='utf-8'> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel='stylesheet' href='../../dist/maplibre-gl.css' /> | ||
<style> | ||
body { margin: 0; padding: 0; } | ||
html, body { height: 2000px; } | ||
#map { | ||
height: 300px; | ||
margin-top: 100px; | ||
} | ||
|
||
#checkboxes { | ||
position: absolute; | ||
background: #fff; | ||
top:0; | ||
left:0; | ||
padding:10px; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id='map'></div> | ||
<div id='checkboxes'> | ||
<label><input id='show-tile-boundaries-checkbox' type='checkbox'> tile debug</label><br /> | ||
<label><input id='show-symbol-collision-boxes-checkbox' type='checkbox'> collision debug</label><br /> | ||
<label><input id='show-overdraw-checkbox' type='checkbox'> overdraw debug</label><br /> | ||
<label><input id='pitch-checkbox' type='checkbox' checked> pitch with rotate</label><br /> | ||
</div> | ||
|
||
<script src='../../dist/maplibre-gl-dev.js'></script> | ||
<script> | ||
|
||
var map = window.map = new maplibregl.Map({ | ||
container: 'map', | ||
zoom: 12.5, | ||
center: [-77.01866, 38.888], | ||
style: 'https://demotiles.maplibre.org/style.json', | ||
hash: true, | ||
cooperativeGestures: true | ||
}); | ||
|
||
map.addControl(new maplibregl.NavigationControl()); | ||
map.addControl(new maplibregl.GeolocateControl({ | ||
positionOptions: { | ||
enableHighAccuracy: true | ||
}, | ||
trackUserLocation: true, | ||
showUserLocation: true, | ||
fitBoundsOptions: { | ||
maxZoom: 20 | ||
} | ||
})); | ||
map.addControl(new maplibregl.ScaleControl()); | ||
map.addControl(new maplibregl.FullscreenControl()); | ||
|
||
map.on('load', function() { | ||
map.addSource('geojson', { | ||
'type': 'geojson', | ||
'data': '../integration/assets/data/linestring.geojson', | ||
'attribution': 'GeoJSON Attribution' | ||
}); | ||
map.addLayer({ | ||
'id': 'route', | ||
'type': 'line', | ||
'source': 'geojson', | ||
'paint': { | ||
'line-color': '#EC8D8D', | ||
'line-width': {'base': 1.5, 'stops': [[5, 0.75], [18, 32]]} | ||
} | ||
}, 'country-label-lg'); | ||
|
||
map.addSource('points', { | ||
'type': 'geojson', | ||
'data': '/test/debug-pages/cross_source_points.geojson' | ||
}); | ||
|
||
map.addLayer({ | ||
'id': 'points', | ||
'type': 'symbol', | ||
'source': 'points', | ||
'layout': { | ||
'text-field': '{name}', | ||
'text-font': ['Open Sans Semibold', 'Arial Unicode MS Bold'] | ||
} | ||
}); | ||
|
||
map.addLayer({ | ||
id: 'marker', | ||
type: 'symbol', | ||
source: 'points', | ||
layout: { | ||
'icon-image': 'bus-11', | ||
'icon-size': 2, | ||
'icon-ignore-placement': true, | ||
'icon-allow-overlap': true | ||
} | ||
}); | ||
|
||
map.addLayer({ | ||
id: 'marker-hover', | ||
type: 'symbol', | ||
filter: ['==', 'name', ''], | ||
source: 'points', | ||
layout: { | ||
'icon-image': 'bus-15', | ||
'icon-size': 2, | ||
'icon-ignore-placement': true, | ||
'icon-allow-overlap': true | ||
} | ||
}); | ||
|
||
map.on('mouseenter', 'marker', function(e) { | ||
map.setFilter('marker-hover', ['==', 'name', e.features[0].properties.name]); | ||
}); | ||
map.on('mouseleave', 'marker', function(_) { | ||
map.setFilter('marker-hover', ['==', 'name', '']); | ||
}); | ||
|
||
}); | ||
|
||
map.on('click', function(e) { | ||
if (e.originalEvent.shiftKey) return; | ||
(new maplibregl.Popup()) | ||
.setLngLat(map.unproject(e.point)) | ||
.setHTML('<h1>Hello World!</h1>') | ||
.addTo(map); | ||
}); | ||
|
||
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('pitch-checkbox').onclick = function() { | ||
map.dragRotate._pitchWithRotate = !!this.checked; | ||
}; | ||
|
||
</script> | ||
</body> | ||
</html> |