„Mapbox” változatai közötti eltérés
(példa struktúra + új kezdő szintű térképek) |
(Útvonaltervezések) |
||
382. sor: | 382. sor: | ||
=== Útvonaltervezés === | === Útvonaltervezés === | ||
+ | |||
+ | ==== Gyalogos útvonaltervezés ==== | ||
+ | |||
+ | [http://zsataai.web.elte.hu/content/mapbox/walking_directions.html Walking directions] | ||
+ | |||
+ | <syntaxhighlight lang="html5"> | ||
+ | <!-- Walking directions --> | ||
+ | <!-- Use the mapbox-directions.js plugin to show walking directions from the Mapbox Directions API --> | ||
+ | |||
+ | <html> | ||
+ | <head> | ||
+ | <meta charset=utf-8 /> | ||
+ | <title>Walking directions</title> | ||
+ | <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | ||
+ | <script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script> | ||
+ | <link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' /> | ||
+ | <style> | ||
+ | body { margin:0; padding:0; } | ||
+ | #map { position:absolute; top:0; bottom:0; width:100%; } | ||
+ | </style> | ||
+ | <script> | ||
+ | var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA'; | ||
+ | </script> | ||
+ | </head> | ||
+ | <body> | ||
+ | <style> | ||
+ | #inputs, | ||
+ | #errors, | ||
+ | #directions { | ||
+ | position: absolute; | ||
+ | width: 33.3333%; | ||
+ | max-width: 300px; | ||
+ | min-width: 200px; | ||
+ | } | ||
+ | |||
+ | #inputs { | ||
+ | z-index: 10; | ||
+ | top: 10px; | ||
+ | left: 10px; | ||
+ | } | ||
+ | |||
+ | #directions { | ||
+ | z-index: 99; | ||
+ | background: rgba(0,0,0,.8); | ||
+ | top: 0; | ||
+ | right: 0; | ||
+ | bottom: 0; | ||
+ | overflow: auto; | ||
+ | } | ||
+ | |||
+ | #errors { | ||
+ | z-index: 8; | ||
+ | opacity: 0; | ||
+ | padding: 10px; | ||
+ | border-radius: 0 0 3px 3px; | ||
+ | background: rgba(0,0,0,.25); | ||
+ | top: 90px; | ||
+ | left: 10px; | ||
+ | } | ||
+ | |||
+ | </style> | ||
+ | |||
+ | <script src='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.js'></script> | ||
+ | <link rel='stylesheet' href='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.css' type='text/css' /> | ||
+ | |||
+ | <div id='map'></div> | ||
+ | <div id='inputs'></div> | ||
+ | <div id='errors'></div> | ||
+ | <div id='directions'> | ||
+ | <div id='routes'></div> | ||
+ | <div id='instructions'></div> | ||
+ | </div> | ||
+ | <script> | ||
+ | L.mapbox.accessToken = '<your access token here>'; | ||
+ | L.mapbox.accessToken = demoAccessToken; | ||
+ | var map = L.mapbox.map('map', 'mapbox.streets', { | ||
+ | zoomControl: false | ||
+ | }).setView([40, -74.50], 9); | ||
+ | |||
+ | // move the attribution control out of the way | ||
+ | map.attributionControl.setPosition('bottomleft'); | ||
+ | |||
+ | // create the initial directions object, from which the layer | ||
+ | // and inputs will pull data. | ||
+ | var directions = L.mapbox.directions({ | ||
+ | profile: 'mapbox.walking' | ||
+ | }); | ||
+ | |||
+ | var directionsLayer = L.mapbox.directions.layer(directions) | ||
+ | .addTo(map); | ||
+ | |||
+ | var directionsInputControl = L.mapbox.directions.inputControl('inputs', directions) | ||
+ | .addTo(map); | ||
+ | |||
+ | var directionsErrorsControl = L.mapbox.directions.errorsControl('errors', directions) | ||
+ | .addTo(map); | ||
+ | |||
+ | var directionsRoutesControl = L.mapbox.directions.routesControl('routes', directions) | ||
+ | .addTo(map); | ||
+ | |||
+ | var directionsInstructionsControl = L.mapbox.directions.instructionsControl('instructions', directions) | ||
+ | .addTo(map); | ||
+ | </script> | ||
+ | </body> | ||
+ | </html> | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==== Biciklis útvonaltervezés ==== | ||
+ | |||
+ | [http://zsataai.web.elte.hu/content/mapbox/cycling_directions.html Cycling directions] | ||
+ | |||
+ | <syntaxhighlight lang="html5"> | ||
+ | <!-- Cycling directions --> | ||
+ | <!-- Use the mapbox-directions.js plugin to show cycling directions from the Mapbox Directions API --> | ||
+ | |||
+ | <!DOCTYPE html> | ||
+ | <html> | ||
+ | <head> | ||
+ | <meta charset=utf-8 /> | ||
+ | <title>Cycling directions</title> | ||
+ | <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | ||
+ | <script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script> | ||
+ | <link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' /> | ||
+ | <style> | ||
+ | body { margin:0; padding:0; } | ||
+ | #map { position:absolute; top:0; bottom:0; width:100%; } | ||
+ | </style> | ||
+ | <script> | ||
+ | var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA'; | ||
+ | </script> | ||
+ | </head> | ||
+ | <body> | ||
+ | <style> | ||
+ | #inputs, | ||
+ | #errors, | ||
+ | #directions { | ||
+ | position: absolute; | ||
+ | width: 33.3333%; | ||
+ | max-width: 300px; | ||
+ | min-width: 200px; | ||
+ | } | ||
+ | |||
+ | #inputs { | ||
+ | z-index: 10; | ||
+ | top: 10px; | ||
+ | left: 10px; | ||
+ | } | ||
+ | |||
+ | #directions { | ||
+ | z-index: 99; | ||
+ | background: rgba(0,0,0,.8); | ||
+ | top: 0; | ||
+ | right: 0; | ||
+ | bottom: 0; | ||
+ | overflow: auto; | ||
+ | } | ||
+ | |||
+ | #errors { | ||
+ | z-index: 8; | ||
+ | opacity: 0; | ||
+ | padding: 10px; | ||
+ | border-radius: 0 0 3px 3px; | ||
+ | background: rgba(0,0,0,.25); | ||
+ | top: 90px; | ||
+ | left: 10px; | ||
+ | } | ||
+ | |||
+ | </style> | ||
+ | |||
+ | <script src='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.js'></script> | ||
+ | <link rel='stylesheet' href='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.css' type='text/css' /> | ||
+ | |||
+ | <div id='map'></div> | ||
+ | <div id='inputs'></div> | ||
+ | <div id='errors'></div> | ||
+ | <div id='directions'> | ||
+ | <div id='routes'></div> | ||
+ | <div id='instructions'></div> | ||
+ | </div> | ||
+ | <script> | ||
+ | L.mapbox.accessToken = '<your access token here>'; | ||
+ | L.mapbox.accessToken = demoAccessToken; | ||
+ | var map = L.mapbox.map('map', 'mapbox.streets', { | ||
+ | zoomControl: false | ||
+ | }).setView([40, -74.50], 9); | ||
+ | |||
+ | // move the attribution control out of the way | ||
+ | map.attributionControl.setPosition('bottomleft'); | ||
+ | |||
+ | // create the initial directions object, from which the layer | ||
+ | // and inputs will pull data. | ||
+ | var directions = L.mapbox.directions({ | ||
+ | profile: 'mapbox.cycling' | ||
+ | }); | ||
+ | |||
+ | var directionsLayer = L.mapbox.directions.layer(directions) | ||
+ | .addTo(map); | ||
+ | |||
+ | var directionsInputControl = L.mapbox.directions.inputControl('inputs', directions) | ||
+ | .addTo(map); | ||
+ | |||
+ | var directionsErrorsControl = L.mapbox.directions.errorsControl('errors', directions) | ||
+ | .addTo(map); | ||
+ | |||
+ | var directionsRoutesControl = L.mapbox.directions.routesControl('routes', directions) | ||
+ | .addTo(map); | ||
+ | |||
+ | var directionsInstructionsControl = L.mapbox.directions.instructionsControl('instructions', directions) | ||
+ | .addTo(map); | ||
+ | </script> | ||
+ | </body> | ||
+ | </html> | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==== Autós útvonaltervezés ==== | ||
+ | |||
+ | [http://zsataai.web.elte.hu/content/mapbox/driving_directions.html Driving directions] | ||
+ | |||
+ | <syntaxhighlight lang="html5"> | ||
+ | <!-- Driving directions --> | ||
+ | <!-- Use the mapbox-directions.js plugin to show results from the Mapbox Directions API --> | ||
+ | |||
+ | <html> | ||
+ | <head> | ||
+ | <meta charset=utf-8 /> | ||
+ | <title>Driving directions</title> | ||
+ | <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | ||
+ | <script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script> | ||
+ | <link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' /> | ||
+ | <style> | ||
+ | body { margin:0; padding:0; } | ||
+ | #map { position:absolute; top:0; bottom:0; width:100%; } | ||
+ | </style> | ||
+ | <script> | ||
+ | var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA'; | ||
+ | </script> | ||
+ | </head> | ||
+ | <body> | ||
+ | <style> | ||
+ | #inputs, | ||
+ | #errors, | ||
+ | #directions { | ||
+ | position: absolute; | ||
+ | width: 33.3333%; | ||
+ | max-width: 300px; | ||
+ | min-width: 200px; | ||
+ | } | ||
+ | |||
+ | #inputs { | ||
+ | z-index: 10; | ||
+ | top: 10px; | ||
+ | left: 10px; | ||
+ | } | ||
+ | |||
+ | #directions { | ||
+ | z-index: 99; | ||
+ | background: rgba(0,0,0,.8); | ||
+ | top: 0; | ||
+ | right: 0; | ||
+ | bottom: 0; | ||
+ | overflow: auto; | ||
+ | } | ||
+ | |||
+ | #errors { | ||
+ | z-index: 8; | ||
+ | opacity: 0; | ||
+ | padding: 10px; | ||
+ | border-radius: 0 0 3px 3px; | ||
+ | background: rgba(0,0,0,.25); | ||
+ | top: 90px; | ||
+ | left: 10px; | ||
+ | } | ||
+ | |||
+ | </style> | ||
+ | |||
+ | <script src='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.js'></script> | ||
+ | <link rel='stylesheet' href='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.css' type='text/css' /> | ||
+ | |||
+ | <div id='map'></div> | ||
+ | <div id='inputs'></div> | ||
+ | <div id='errors'></div> | ||
+ | <div id='directions'> | ||
+ | <div id='routes'></div> | ||
+ | <div id='instructions'></div> | ||
+ | </div> | ||
+ | <script> | ||
+ | L.mapbox.accessToken = '<your access token here>'; | ||
+ | L.mapbox.accessToken = demoAccessToken; | ||
+ | var map = L.mapbox.map('map', 'mapbox.streets', { | ||
+ | zoomControl: false | ||
+ | }).setView([40, -74.50], 9); | ||
+ | |||
+ | // move the attribution control out of the way | ||
+ | map.attributionControl.setPosition('bottomleft'); | ||
+ | |||
+ | // create the initial directions object, from which the layer | ||
+ | // and inputs will pull data. | ||
+ | var directions = L.mapbox.directions(); | ||
+ | |||
+ | var directionsLayer = L.mapbox.directions.layer(directions) | ||
+ | .addTo(map); | ||
+ | |||
+ | var directionsInputControl = L.mapbox.directions.inputControl('inputs', directions) | ||
+ | .addTo(map); | ||
+ | |||
+ | var directionsErrorsControl = L.mapbox.directions.errorsControl('errors', directions) | ||
+ | .addTo(map); | ||
+ | |||
+ | var directionsRoutesControl = L.mapbox.directions.routesControl('routes', directions) | ||
+ | .addTo(map); | ||
+ | |||
+ | var directionsInstructionsControl = L.mapbox.directions.instructionsControl('instructions', directions) | ||
+ | .addTo(map); | ||
+ | </script> | ||
+ | </body> | ||
+ | </html> | ||
+ | </syntaxhighlight> | ||
=== Plugin támogatás és a Mapbox === | === Plugin támogatás és a Mapbox === |
A lap 2017. április 8., 21:10-kori változata
A Mapbox térképszolgáltatóknak kínál megoldásokat, illetve emellett térképek tervezéséhez és karbantartásához készít eszközöket. Ezek többnyire OpenStreetMap adatokat használnak. A Mapbox elkötelezett a nyílt megoldások mellett, de nem csak használja az adatokat, hanem többek között a Mapnik nyílt forrású térképrenderelő megoldás kódjának fő hozzájárulója is.
Történelem: A cég startupként indult 2010-ben, Washingtonban. Dolgozóinak száma 2017-re elérte a 180 főt és olyan cégek valamint szervezetek használják a termékeiket, mint a Foursquare, Evernote, Pinterest, Github, The Weather Channel, Guardian, Financial Times, CNN, Greenpeace, National Geographic.
További munkásság: Egy olyan eljáráson dolgoznak, amivel a műholdképek minősége feljavítható. Ha most bárki megnyitja a Google Maps vagy a Bing Maps térképeit, átkapcsol műholdas nézetbe, akkor azt veheti észre, hogy az egész Földön mindenhol világos van, mindenhol nyár van és nincsenek felhők. Ha elkezdünk visszaközelíteni, akkor kiderül, hogy sokszor nagy kontraszteltérés van egymás mellett lévő sávok közt, feltűnnek felhők, a színek össze-vissza változnak és sok esetben a képek rossz minőségűek. Ez annak köszönhető, hogy ezek a térképek ezernyi kis darabból vannak összerakva. Előfordul, hogy az egymás melletti képek teljesen más forrásból származnak, más technológiával készültek, illetve időben akár évekre van egymástól két szomszédos darab. A Mapbox azt tűzte ki célul, hogy felszámolja az ilyen hibákat, megszabadulva a zavaró felhőktől és grafikai egyenetlenségektől. Ennek megvalósításához az alapanyag a NASA Lance-Modis rendszerének műholdjáról származik. A Mapbox ezekből az adatokból ragadta ki a 2011. január 1. és 2012. december 31. közt készült két évnyi anyagokat. Ez 339 ezer darab 16 megapixeles képet jelent, ami több mint 5687 milliárd pixel összességében. A projekt célja, ezt a pixelmennyiséget lefésülni 5 milliárd pixelnyire, amiből összeáll egy részletes, de egységes glóbusz.
Tartalomjegyzék
- 1 Példák
- 1.1 Térkép (kezdő szint)
- 1.1.1 Minimális példa egy térkép megjelenítésére
- 1.1.2 Világtérkép folytonosságának kikapcsolása
- 1.1.3 Változtatható alapréteg
- 1.1.4 Térkép nagyításának és mozgatásának letiltása
- 1.1.5 Megnézhető térképterület leszűkítése határokkal
- 1.1.6 Dupla kattintásra nagyítás az adott területre középre helyezve + aránymérték
- 1.1.7 Töltésjelző megjelenítése
- 1.2 Jelölők a térképen
- 1.3 Tippek, üzenetek, szövegek
- 1.4 Helyek
- 1.5 Térkép és GeoJSON
- 1.6 Útvonaltervezés
- 1.7 Plugin támogatás és a Mapbox
- 1.8 Térkép (haladó szint)
- 1.9 Alakzatok, vonalak, rajzolás a térképen
- 1.1 Térkép (kezdő szint)
Példák
Térkép (kezdő szint)
Minimális példa egy térkép megjelenítésére
<!-- A simple map -->
<!-- Initialize a map in an HTML element with Mapbox.js. -->
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>A simple map</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
</script>
</head>
<body>
<div id='map'></div>
<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets')
.setView([47.47, 19.06], 15);
</script>
</body>
</html>
Világtérkép folytonosságának kikapcsolása
<!-- Disable world wrapping -->
<!-- Instead of loading tiles beyond -180 and 180, only show one copy of the world. -->
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Disable world wrapping</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
</script>
</head>
<body>
<div id='map'></div>
<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets', {
// These options apply to the tile layer in the map.
tileLayer: {
// This map option disables world wrapping. by default, it is false.
continuousWorld: false,
// This option disables loading tiles outside of the world bounds.
noWrap: true
}
}).setView([40, 0], 2);
</script>
</body>
</html>
Változtatható alapréteg
<!-- Toggling baselayers -->
<!-- Toggling between three different baselayers. -->
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Toggling baselayers</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
</script>
</head>
<body>
<div id='map'></div>
<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', null, {
maxZoom: 18
}).setView([22.76, -25.84], 3);
var layers = {
Streets: L.mapbox.tileLayer('mapbox.streets'),
Outdoors: L.mapbox.tileLayer('mapbox.outdoors'),
Satellite: L.mapbox.tileLayer('mapbox.satellite')
};
layers.Streets.addTo(map);
L.control.layers(layers).addTo(map);
</script>
</body>
</html>
Térkép nagyításának és mozgatásának letiltása
<!-- Disable zooming and panning -->
<!-- How to disable zooming and panning with Mapbox.js, our open source JavaScript library. -->
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Disable zooming and panning</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
</script>
</head>
<body>
<div id='map'></div>
<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets', {
zoomControl: false
}).setView([41.0252, 28.9950], 11);
// Disable drag and zoom handlers.
map.dragging.disable();
map.touchZoom.disable();
map.doubleClickZoom.disable();
map.scrollWheelZoom.disable();
map.keyboard.disable();
// Disable tap handler, if present.
if (map.tap) map.tap.disable();
</script>
</body>
</html>
Megnézhető térképterület leszűkítése határokkal
Using maxBounds to restrict map panning
<!-- Using maxBounds to restrict map panning -->
<!-- Preventing users from leaving an area on the map -->
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Using maxBounds to restrict map panning</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
</script>
</head>
<body>
<div id='map'></div>
<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
// Construct a bounding box for this map that the user cannot
// move out of
var southWest = L.latLng(46.47, 17.06),
northEast = L.latLng(48.47, 21.06),
bounds = L.latLngBounds(southWest, northEast);
var map = L.mapbox.map('map', 'mapbox.streets', {
// set that bounding box as maxBounds to restrict moving the map
// see full maxBounds documentation:
// http://leafletjs.com/reference.html#map-maxbounds
maxBounds: bounds,
maxZoom: 19,
minZoom: 10
});
// zoom the map to that bounding box
map.fitBounds(bounds);
</script>
</body>
</html>
Dupla kattintásra nagyítás az adott területre középre helyezve + aránymérték
<!-- Double click to zoom -->
<!-- Listen for a double click event from a user and zoom in on the map. -->
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Double click to zoom</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
</script>
</head>
<body>
<div id='map'></div>
<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets', {
// Disable default double-click behavior.
doubleClickZoom: false
})
.setView([46.695, 11.470], 4)
.on('dblclick', function(e) {
// Zoom exactly to each double-clicked point
map.setView(e.latlng, map.getZoom() + 1);
});
// L.control.scale() is included in Leaflet see
// https://www.mapbox.com/mapbox.js/api/v3.0.1/l-control-scale/
L.control.scale().addTo(map);
</script>
</body>
</html>
Töltésjelző megjelenítése
<!-- Show loading screen -->
<!-- Use events to show when features are loading and loaded by displaying and hiding a loading message -->
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Show loading screen</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
</script>
</head>
<body>
<style>
/*
* This is a very simple version of a 'loading screen': there are much
* fancier ones you can use instead, like
* http://codepen.io/collection/HtAne/
*/
#loader {
position:absolute; top:0; bottom:0; width:100%;
background:rgba(255, 255, 255, 1);
transition:background 1s ease-out;
-webkit-transition:background 1s ease-out;
}
#loader.done {
background:rgba(255, 255, 255, 0);
}
#loader.hide {
display:none;
}
#loader .message {
position:absolute;
left:50%;
top:50%;
}
</style>
<div id='map'></div>
<div id='loader'><span class='message'>loading</span></div>
<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var loader = document.getElementById('loader');
var map = L.mapbox.map('map')
.setView([47.47, 19.06], 13);
// Add a tile layer with a loading animation
// start the loading screen
startLoading();
L.mapbox.tileLayer('mapbox.streets')
.addTo(map) // add your tiles to the map
.on('load', finishedLoading); // when the tiles load, remove the screen
function startLoading() {
loader.className = '';
}
function finishedLoading() {
// first, toggle the class 'done', which makes the loading screen
// fade out
loader.className = 'done';
setTimeout(function() {
// then, after a half-second, add the class 'hide', which hides
// it completely and ensures that the user can interact with the
// map again.
loader.className = 'hide';
}, 500);
}
</script>
</body>
</html>
Jelölők a térképen
Tippek, üzenetek, szövegek
Helyek
Térkép és GeoJSON
Útvonaltervezés
Gyalogos útvonaltervezés
<!-- Walking directions -->
<!-- Use the mapbox-directions.js plugin to show walking directions from the Mapbox Directions API -->
<html>
<head>
<meta charset=utf-8 />
<title>Walking directions</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
</script>
</head>
<body>
<style>
#inputs,
#errors,
#directions {
position: absolute;
width: 33.3333%;
max-width: 300px;
min-width: 200px;
}
#inputs {
z-index: 10;
top: 10px;
left: 10px;
}
#directions {
z-index: 99;
background: rgba(0,0,0,.8);
top: 0;
right: 0;
bottom: 0;
overflow: auto;
}
#errors {
z-index: 8;
opacity: 0;
padding: 10px;
border-radius: 0 0 3px 3px;
background: rgba(0,0,0,.25);
top: 90px;
left: 10px;
}
</style>
<script src='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.js'></script>
<link rel='stylesheet' href='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.css' type='text/css' />
<div id='map'></div>
<div id='inputs'></div>
<div id='errors'></div>
<div id='directions'>
<div id='routes'></div>
<div id='instructions'></div>
</div>
<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets', {
zoomControl: false
}).setView([40, -74.50], 9);
// move the attribution control out of the way
map.attributionControl.setPosition('bottomleft');
// create the initial directions object, from which the layer
// and inputs will pull data.
var directions = L.mapbox.directions({
profile: 'mapbox.walking'
});
var directionsLayer = L.mapbox.directions.layer(directions)
.addTo(map);
var directionsInputControl = L.mapbox.directions.inputControl('inputs', directions)
.addTo(map);
var directionsErrorsControl = L.mapbox.directions.errorsControl('errors', directions)
.addTo(map);
var directionsRoutesControl = L.mapbox.directions.routesControl('routes', directions)
.addTo(map);
var directionsInstructionsControl = L.mapbox.directions.instructionsControl('instructions', directions)
.addTo(map);
</script>
</body>
</html>
Biciklis útvonaltervezés
<!-- Cycling directions -->
<!-- Use the mapbox-directions.js plugin to show cycling directions from the Mapbox Directions API -->
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Cycling directions</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
</script>
</head>
<body>
<style>
#inputs,
#errors,
#directions {
position: absolute;
width: 33.3333%;
max-width: 300px;
min-width: 200px;
}
#inputs {
z-index: 10;
top: 10px;
left: 10px;
}
#directions {
z-index: 99;
background: rgba(0,0,0,.8);
top: 0;
right: 0;
bottom: 0;
overflow: auto;
}
#errors {
z-index: 8;
opacity: 0;
padding: 10px;
border-radius: 0 0 3px 3px;
background: rgba(0,0,0,.25);
top: 90px;
left: 10px;
}
</style>
<script src='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.js'></script>
<link rel='stylesheet' href='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.css' type='text/css' />
<div id='map'></div>
<div id='inputs'></div>
<div id='errors'></div>
<div id='directions'>
<div id='routes'></div>
<div id='instructions'></div>
</div>
<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets', {
zoomControl: false
}).setView([40, -74.50], 9);
// move the attribution control out of the way
map.attributionControl.setPosition('bottomleft');
// create the initial directions object, from which the layer
// and inputs will pull data.
var directions = L.mapbox.directions({
profile: 'mapbox.cycling'
});
var directionsLayer = L.mapbox.directions.layer(directions)
.addTo(map);
var directionsInputControl = L.mapbox.directions.inputControl('inputs', directions)
.addTo(map);
var directionsErrorsControl = L.mapbox.directions.errorsControl('errors', directions)
.addTo(map);
var directionsRoutesControl = L.mapbox.directions.routesControl('routes', directions)
.addTo(map);
var directionsInstructionsControl = L.mapbox.directions.instructionsControl('instructions', directions)
.addTo(map);
</script>
</body>
</html>
Autós útvonaltervezés
<!-- Driving directions -->
<!-- Use the mapbox-directions.js plugin to show results from the Mapbox Directions API -->
<html>
<head>
<meta charset=utf-8 />
<title>Driving directions</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
</script>
</head>
<body>
<style>
#inputs,
#errors,
#directions {
position: absolute;
width: 33.3333%;
max-width: 300px;
min-width: 200px;
}
#inputs {
z-index: 10;
top: 10px;
left: 10px;
}
#directions {
z-index: 99;
background: rgba(0,0,0,.8);
top: 0;
right: 0;
bottom: 0;
overflow: auto;
}
#errors {
z-index: 8;
opacity: 0;
padding: 10px;
border-radius: 0 0 3px 3px;
background: rgba(0,0,0,.25);
top: 90px;
left: 10px;
}
</style>
<script src='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.js'></script>
<link rel='stylesheet' href='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.css' type='text/css' />
<div id='map'></div>
<div id='inputs'></div>
<div id='errors'></div>
<div id='directions'>
<div id='routes'></div>
<div id='instructions'></div>
</div>
<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets', {
zoomControl: false
}).setView([40, -74.50], 9);
// move the attribution control out of the way
map.attributionControl.setPosition('bottomleft');
// create the initial directions object, from which the layer
// and inputs will pull data.
var directions = L.mapbox.directions();
var directionsLayer = L.mapbox.directions.layer(directions)
.addTo(map);
var directionsInputControl = L.mapbox.directions.inputControl('inputs', directions)
.addTo(map);
var directionsErrorsControl = L.mapbox.directions.errorsControl('errors', directions)
.addTo(map);
var directionsRoutesControl = L.mapbox.directions.routesControl('routes', directions)
.addTo(map);
var directionsInstructionsControl = L.mapbox.directions.instructionsControl('instructions', directions)
.addTo(map);
</script>
</body>
</html>