|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + |
| 4 | +<head> |
| 5 | + <title>MapLibre GL JS debug page</title> |
| 6 | + <meta charset='utf-8'> |
| 7 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 8 | + <link rel='stylesheet' href='../dist/maplibre-gl.css' /> |
| 9 | + <style> |
| 10 | + body { |
| 11 | + margin: 0; |
| 12 | + padding: 0; |
| 13 | + } |
| 14 | + |
| 15 | + html, |
| 16 | + body, |
| 17 | + #map { |
| 18 | + height: 100%; |
| 19 | + } |
| 20 | + </style> |
| 21 | +</head> |
| 22 | + |
| 23 | +<body> |
| 24 | + <style> |
| 25 | + .map-overlay { |
| 26 | + font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif; |
| 27 | + position: absolute; |
| 28 | + width: 200px; |
| 29 | + top: 0; |
| 30 | + left: 0; |
| 31 | + padding: 10px; |
| 32 | + } |
| 33 | + |
| 34 | + .map-overlay .map-overlay-inner { |
| 35 | + background-color: #fff; |
| 36 | + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); |
| 37 | + border-radius: 3px; |
| 38 | + padding: 10px; |
| 39 | + margin-bottom: 10px; |
| 40 | + } |
| 41 | + |
| 42 | + .map-overlay-inner fieldset { |
| 43 | + border: none; |
| 44 | + padding: 0; |
| 45 | + margin: 0 0 10px; |
| 46 | + } |
| 47 | + |
| 48 | + .map-overlay-inner fieldset:last-child { |
| 49 | + margin: 0; |
| 50 | + } |
| 51 | + |
| 52 | + .map-overlay-inner select { |
| 53 | + width: 100%; |
| 54 | + } |
| 55 | + |
| 56 | + .map-overlay-inner label { |
| 57 | + display: block; |
| 58 | + font-weight: bold; |
| 59 | + margin: 0 0 5px; |
| 60 | + } |
| 61 | + </style> |
| 62 | + |
| 63 | + <div id="map"></div> |
| 64 | + <div class="map-overlay top"> |
| 65 | + <div class="map-overlay-inner"> |
| 66 | + <fieldset> |
| 67 | + <label>text-rotation-alignment</label> |
| 68 | + <select id="rotation" name="rotation"> |
| 69 | + <option value="map">map</option> |
| 70 | + <option value="viewport">viewport</option> |
| 71 | + <option value="viewport-glyph">viewport-glyph</option> |
| 72 | + </select> |
| 73 | + </fieldset> |
| 74 | + <fieldset> |
| 75 | + <label>text-pitch-alignment</label> |
| 76 | + <select id="pitch" name="pitch"> |
| 77 | + <option value="map">map</option> |
| 78 | + <option value="viewport">viewport</option> |
| 79 | + </select> |
| 80 | + </fieldset> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + |
| 84 | + <script src='../dist/maplibre-gl-dev.js'></script> |
| 85 | + <script> |
| 86 | + var map = window.map = new maplibregl.Map({ |
| 87 | + container: 'map', |
| 88 | + zoom: 6, |
| 89 | + center: [-69.482, 45.42], |
| 90 | + style: 'https://demotiles.maplibre.org/style.json', |
| 91 | + hash: true |
| 92 | + }); |
| 93 | + |
| 94 | + map.addControl(new maplibregl.NavigationControl()); |
| 95 | + map.addControl(new maplibregl.GeolocateControl()); |
| 96 | + |
| 97 | + map.on('load', function () { |
| 98 | + map.addSource('maine', { |
| 99 | + 'type': 'geojson', |
| 100 | + 'data': { |
| 101 | + 'type': 'Feature', |
| 102 | + 'geometry': { |
| 103 | + 'type': 'Polygon', |
| 104 | + 'coordinates': [ |
| 105 | + [ |
| 106 | + [-67.13734351262877, 45.137451890638886], |
| 107 | + [-66.96466, 44.8097], |
| 108 | + [-68.03252, 44.3252], |
| 109 | + [-69.06, 43.98], |
| 110 | + [-70.11617, 43.68405], |
| 111 | + [-70.64573401557249, 43.090083319667144], |
| 112 | + [-70.75102474636725, 43.08003225358635], |
| 113 | + [-70.79761105007827, 43.21973948828747], |
| 114 | + [-70.98176001655037, 43.36789581966826], |
| 115 | + [-70.94416541205806, 43.46633942318431], |
| 116 | + [-71.08482, 45.3052400000002], |
| 117 | + [-70.6600225491012, 45.46022288673396], |
| 118 | + [-70.30495378282376, 45.914794623389355], |
| 119 | + [-70.00014034695016, 46.69317088478567], |
| 120 | + [-69.23708614772835, 47.44777598732787], |
| 121 | + [-68.90478084987546, 47.184794623394396], |
| 122 | + [-68.23430497910454, 47.35462921812177], |
| 123 | + [-67.79035274928509, 47.066248887716995], |
| 124 | + [-67.79141211614706, 45.702585354182816], |
| 125 | + [-67.13734351262877, 45.137451890638886] |
| 126 | + ] |
| 127 | + ] |
| 128 | + } |
| 129 | + } |
| 130 | + }); |
| 131 | + map.addLayer({ |
| 132 | + 'id': 'maine-line', |
| 133 | + 'type': 'line', |
| 134 | + 'source': 'maine' |
| 135 | + }); |
| 136 | + map.addLayer({ |
| 137 | + 'id': 'maine-text', |
| 138 | + 'type': 'symbol', |
| 139 | + 'source': 'maine', |
| 140 | + 'layout': { |
| 141 | + 'text-field': 'maine', |
| 142 | + 'symbol-placement': 'line', |
| 143 | + 'text-pitch-alignment': 'map', |
| 144 | + 'text-rotation-alignment': 'map', |
| 145 | + 'text-size': 36 |
| 146 | + } |
| 147 | + }); |
| 148 | + var rotation = document.getElementById('rotation'); |
| 149 | + rotation.addEventListener('change', function() { |
| 150 | + map.setLayoutProperty('maine-text', 'text-rotation-alignment', rotation.value); |
| 151 | + }); |
| 152 | + var pitch = document.getElementById('pitch'); |
| 153 | + pitch.addEventListener('change', function() { |
| 154 | + map.setLayoutProperty('maine-text', 'text-pitch-alignment', pitch.value); |
| 155 | + }); |
| 156 | + |
| 157 | + }); |
| 158 | + |
| 159 | + </script> |
| 160 | +</body> |
| 161 | + |
| 162 | +</html> |
0 commit comments