-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
work around circular dependency by using LngLatBoundsLike
- Loading branch information
1 parent
bec224d
commit 91ef572
Showing
3 changed files
with
67 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!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%; } | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id='map'></div> | ||
|
||
<script src='/dist/mapbox-gl-dev.js'></script> | ||
<script src='/debug/access_token_generated.js'></script> | ||
<script src='https://npmcdn.com/@turf/turf@3.5.1/turf.min.js'></script> | ||
<script> | ||
|
||
var center = [-77.01866, 38.888]; | ||
var radius = 1000; | ||
|
||
var map = window.map = new mapboxgl.Map({ | ||
container: 'map', | ||
zoom: 3, | ||
center: center, | ||
style: 'mapbox://styles/mapbox/streets-v9', | ||
hash: true | ||
}); | ||
|
||
map.addControl(new mapboxgl.NavigationControl()); | ||
map.addControl(new mapboxgl.GeolocateControl()); | ||
|
||
map.on('load', function() { | ||
var centerCircle = turf.circle(turf.point(center), radius, 50, 'meters'); | ||
|
||
map.addSource('circle', { | ||
"type": "geojson", | ||
"data": turf.featureCollection([centerCircle]) | ||
}); | ||
|
||
map.addLayer({ | ||
"id": "circle", | ||
"type": "line", | ||
"source": "circle", | ||
"paint": { | ||
} | ||
}); | ||
|
||
var centerLngLat = new mapboxgl.LngLat(center[0], center[1]); | ||
var bounds = centerLngLat.toBounds(radius); | ||
map.fitBounds(bounds); | ||
}); | ||
|
||
</script> | ||
</body> | ||
</html> |
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