์ค๊ตญ์์๋ google map ์ฌ์ฉ์ด ์ ์๋๋ค๊ณ ํ๋ค.
๋ ์ ์จ๋ด์ ๋ชจ๋ฅด๊ฒ ์ง๋ง.. ์๋ ๋จ๋ค... ๊ทธ๋ฆฌํ์ฌ ์ฌ์ฉํ๊ฒ ๋ Mapbox !
์ฌ์ค ์์ธํ ๋ด์ฉ์ ์๋ ๋ฌธ์๊ฐ ์ ์ ๋ฆฌ๋์ด ์์ด์ ํํ์ด์ง๋ฅผ ๋ฐฉ๋ฌธ ํ๋๊ฒ ๋น ๋ฅด๋ค.
๊ธฐ๋ณธ ๋ช๊ฐ์ง์ ๋ด์ฉ๋ง ์ ๋ฆฌํด ๋๋ค!
Map ๐
- Create map object and connect element by id.
- Clear default bottom-right info button if attributionControl option set false.
<div id='map' style='width: 400px; height: 300px;'></div>
<script>
// TO MAKE THE MAP APPEAR YOU MUST
// ADD YOUR ACCESS TOKEN FROM
// https://account.mapbox.com
mapboxgl.accessToken = 'YOUR_ACCESS_TOKEN';
const map = new mapboxgl.Map({
container: 'map', // container ID
style: 'mapbox://styles/mapbox/streets-v11', // style URL
center: [-74.5, 40], // starting position [lng, lat]
zoom: 9, // starting zoom
attributionControl: false // remove mapbox info(?) button
});
</script>
Marker ๐
- Draw marker on the map.
const marker = new mapboxgl.Marker({
color: "#FFFFFF"
}).setLngLat([-74.5, 40])
.addTo(map);
Custom Marker ๐
- Can create custom marker using HTML element.
- View full-screen demo page
Line Draw ๐
- Draw line between points
- If you want to change your map style, you add source and layer after style load
map.on('style.load', function(){
// addSource
// addLayer
});
Controller ๐
- Make map size to full screen
- Zoom map
- I think they don't support a style controller but you can make use setStyle option.
Thanks for ๐
'Lang > Javascript' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
JS * ๋ณ์ ์ด๊ธฐํ์ ๋ํ์ฌ... (2) | 2022.02.25 |
---|---|
JS * JSON ๋ฐ์ดํฐ KEY๋ง UpperCase ํ๊ธฐ ! ( ์์ฉํ๋ฉด LowerCase ๋ ๊ฐ๋ฅ! ) (0) | 2021.12.20 |
JQuery * .off() ๊ฐ์ ์ด๋ฒคํธ ์ค์ ํน์ ์ด๋ฒคํธ๋ง ๋ ์๋ ์์๊น? (0) | 2021.12.15 |
JQuery * .one() ์ด๋ฒคํธ ํ๋ฒ๋ง ์ฌ์ฉํ๊ธฐ! ( feat .on() .off() ) (0) | 2021.12.15 |
JS * ๋งค๊ฐ๋ณ์ ๊ฐ์ ํ์ธ (0) | 2021.11.20 |