219f8990fceedb413834305837ccd35b01ee5f90.svn-base 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8' />
  5. <title></title>
  6. <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
  7. <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.29.0/mapbox-gl.js'></script>
  8. <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.29.0/mapbox-gl.css' rel='stylesheet' />
  9. <style>
  10. body {
  11. margin: 0;
  12. padding: 0;
  13. }
  14. #map {
  15. position: absolute;
  16. top: 0;
  17. bottom: 0;
  18. width: 100%;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <div id='map'></div>
  24. <script>
  25. mapboxgl.accessToken = '<your access token here>';
  26. var map = new mapboxgl.Map({
  27. style: 'mapbox://styles/mapbox/light-v9',
  28. center: [-74.0066, 40.7135],
  29. zoom: 15,
  30. pitch: 45,
  31. bearing: -17.6,
  32. container: 'map'
  33. });
  34. // the 'building' layer in the mapbox-streets vector source contains building-height
  35. // data from OpenStreetMap.
  36. map.on('load', function () {
  37. map.addLayer({
  38. 'id': '3d-buildings',
  39. 'source': 'composite',
  40. 'source-layer': 'building',
  41. 'filter': ['==', 'extrude', 'true'], /* 过滤器 */
  42. 'type': 'fill-extrusion',
  43. 'minzoom': 15,
  44. 'paint': {
  45. 'fill-extrusion-color': '#aaa',
  46. 'fill-extrusion-height': { /* 使用source中的height属性为fill-extrusion-height赋值 */
  47. 'type': 'identity',
  48. 'property': 'height'
  49. },
  50. 'fill-extrusion-base': {
  51. 'type': 'identity',
  52. 'property': 'min_height'
  53. },
  54. 'fill-extrusion-opacity': .6
  55. }
  56. });
  57. });
  58. </script>
  59. </body>
  60. </html>