„Mapbox” változatai közötti eltérés

Innen: GIS Wiki
a
a
 
(3 közbenső módosítás, amit 2 másik szerkesztő végzett, nincs mutatva)
29. sor: 29. sor:
 
[[Fájl:mapbox_pricing01.png|frame|center|link=https://www.mapbox.com/pricing/|alt=Mapbox csomagok árazása|A Mapbox csomagok árazása]]
 
[[Fájl:mapbox_pricing01.png|frame|center|link=https://www.mapbox.com/pricing/|alt=Mapbox csomagok árazása|A Mapbox csomagok árazása]]
  
== Megvalósítás és működés a háttérben ==
+
== Fejlődéstörténet ==
  
Három alapvető működési egység és feladatkör különíthető el a Mapbox működésében. Ezek a következők:  
+
A Mapbox a fejlődését tekintve az alábbiak szerint különíthető el részekre/modulokra/termékekre (időrendben felsorolva, illetve a legfontosabb tulajdonságaikkal):
* '''térkép'''
 
* '''adat'''
 
* '''elemzés'''
 
  
=== Térkép: Mapbox GL a rendereléshez ===
+
* [https://www.mapbox.com/blog/mapbox-js-with-leaflet/ Mapbox.js (JavaScript, előgenerált raszteres csempék, Leaflet kompatibilitás)]
 +
* [https://www.mapbox.com/blog/mapbox-gl/ Mapbox GL (vektoros, OpenGL alapú, kliensoldali renderelés)]
 +
* [https://www.mapbox.com/blog/mapbox-gl-js/ Mapbox GL JS (JavaScript, WebGL, kliensoldali renderelés)]
  
A térkép megjelenítését a GPU végzi '''Mapbox GL''' segítségével. A legfontosabb jellemzői:
+
Mivel a Mapbox.js és a Mapbox GL JS is JavaScript alapú megoldás, ezért fontos lehet a kettő közti átjárhatóság. Ez azt jelenti, hogy ugyan nem automatikusan, de manuálisan a régebbi Mapbox.js projektek átalakíthatóak az újabb Mapbox GL JS alapú működésre. Ehhez a konverzióhoz az alábbi link nyújt hivatalos segítséget:
* A régi raszteres adatokkal (png csempék) szemben, itt vektoros adatok (vektoros csempék) vannak.
 
* A megjelenítéskor rugalmasan kezelhetőek a stílusok (style JSON segítségével).
 
* Kliens oldali renderelés (Open/Web GL alapon).
 
* Az adatok külön rétegek a térképen, nem képezik szerves és elválaszthatatlan részét.
 
  
[[Fájl:mapbox_mapboxgl_03.png|frame|center|alt=Mapbox GL|Mapbox GL]]
+
[https://www.mapbox.com/blog/mapbox-js-to-gl-js/ Converting a project from Mapbox.js to Mapbox GL JS]
  
Példa:
+
== Példák (Mapbox.js) ==
<syntaxhighlight lang="html5">
 
var map = new mapboxgl.Map({
 
  container: 'map',
 
  center: [47.47, 19.06],
 
  zoom: 15,
 
  style: style_object,
 
  hash: true
 
});
 
</syntaxhighlight>
 
  
[https://www.mapbox.com/mapbox-gl-js/api Mapbox GL API dokumentáció]
+
=== Térkép (kezdő szint) ===
 +
==== Minimális példa egy térkép megjelenítésére ====
  
=== Adat: Vector Tile ===
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/simple_map.html A simple map]
  
A '''Vector Tile''' egy nyílt szabvány webes térképek adatainak kódolásához.
+
<syntaxhighlight lang="html5">
 +
<!-- A simple map -->
 +
<!-- Initialize a map in an HTML element with Mapbox.js. -->
  
[[Fájl:mapbox_vectortile_01.png|frame|center|alt=Vector Tile ábrázolása|Vector Tile ábrázolása]]
+
<!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>
 +
</syntaxhighlight>
  
[[Fájl:mapbox_vectortile_02.png|frame|center|alt=Vector Tile példa|Vector Tile példa]]
+
==== Világtérkép folytonosságának kikapcsolása ====
  
=== Elemzés: Turf.js ===
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/disable_world_wrapping.html Disable world wrapping]
  
A térkép adatain elvégezhetünk különféle térinformatikai műveleteket és elemzéseket. Erre a célra szolgál a '''Turj.js''' nevű nyílt forráskódú JavaScript könyvtár, melyet a Mapbox is beépítetten használ.
+
<syntaxhighlight lang="html5">
Néhány ilyen térinformatikai művelet a Turf.js képességei közül:
+
<!-- Disable world wrapping -->
* Méretarány, mérték, távolságmérés kezelése
+
<!-- Instead of loading tiles beyond -180 and 180, only show one copy of the world. -->
* Transzformáció (például: buffer terület, unió, metszet és különbség képzés)
 
* Pontok, poligonok és multipoligonok kezelése
 
* Interpoláció
 
* Adat osztályozás
 
* Mértékegység konverzió
 
* Rácsok, hálózatok elemzése
 
* Aggregációs és statisztikai függvények
 
  
[[Fájl:mapbox_turf_03.png|frame|center|alt=Turf.js|Turf.js]]
+
<!DOCTYPE html>
 
+
<html>
Példa:
+
<head>
<syntaxhighlight lang="html5">
+
<meta charset=utf-8 />
var poly1 = {
+
<title>Disable world wrapping</title>
  "type": "Feature",
+
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
  "properties": {
+
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
    "fill": "#0f0"
+
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
  },
+
<style>
  "geometry": {
+
body { margin:0; padding:0; }
    "type": "Polygon",
+
#map { position:absolute; top:0; bottom:0; width:100%; }
    "coordinates": [[
+
</style>
      [-82.574787, 35.594087],
+
<script>
      [-82.574787, 35.615581],
+
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
      [-82.545261, 35.615581],
+
</script>
      [-82.545261, 35.594087],
+
</head>
      [-82.574787, 35.594087]
+
<body>
    ]]
+
<div id='map'></div>
  }
+
 
};
+
<script>
var poly2 = {
+
L.mapbox.accessToken = '<your access token here>';
  "type": "Feature",
+
L.mapbox.accessToken = demoAccessToken;
  "properties": {
+
var map = L.mapbox.map('map', 'mapbox.streets', {
    "fill": "#00f"
+
// These options apply to the tile layer in the map.
  },
+
tileLayer: {
  "geometry": {
+
// This map option disables world wrapping. by default, it is false.
    "type": "Polygon",
+
continuousWorld: false,
    "coordinates": [[
+
// This option disables loading tiles outside of the world bounds.
      [-82.560024, 35.585153],
+
noWrap: true
      [-82.560024, 35.602602],
+
}
      [-82.52964, 35.602602],
+
}).setView([40, 0], 2);
      [-82.52964, 35.585153],
+
</script>
      [-82.560024, 35.585153]
+
</body>
    ]]
+
</html>
  }
 
};
 
 
 
var union = turf.union(poly1, poly2);
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
[http://turfjs.org/docs Turf.js API dokumentáció]
+
==== Változtatható alapréteg ====
 
 
=== Komponensek közötti kapcsolat ===
 
 
 
A Mapbox, illetve annak webes Mapbox.js nevű megoldása, ezen különálló komponensek egyfajta "wrapper" megvalósítása az egyszerűbb és egységesebb kezelhetőség érdekében.
 
  
[[Fájl:mapbox_rendereles_01.png|frame|center|alt=Megjelenítés, renderelés|Megjelenítés, renderelés]]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/toggling_baselayers.html Toggling baselayers]
 
 
[[Fájl:mapbox_elemzes_01.png|frame|center|alt=Elemzés, szűrés|Elemzés, szűrés]]
 
 
 
== Példák (Mapbox használata webes környezetben, azaz Mapbox.js) ==
 
=== Térkép (kezdő szint) ===
 
==== Minimális példa egy térkép megjelenítésére ====
 
 
 
[http://zsataai.web.elte.hu/content/mapbox/simple_map.html A simple map]
 
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- A simple map -->
+
<!-- Toggling baselayers -->
<!-- Initialize a map in an HTML element with Mapbox.js. -->
+
<!-- Toggling between three different baselayers. -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
144. sor: 136. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>A simple map</title>
+
<title>Toggling baselayers</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<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' />
 
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
 
<style>
 
<style>
body { margin:0; padding:0; }
+
  body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
+
  #map { position:absolute; top:0; bottom:0; width:100%; }
 
</style>
 
</style>
 
<script>
 
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
+
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
 
</script>
 
</script>
 
</head>
 
</head>
 
<body>
 
<body>
 
<div id='map'></div>
 
<div id='map'></div>
 +
 
<script>
 
<script>
L.mapbox.accessToken = '<your access token here>';
+
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
+
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets')
+
  var map = L.mapbox.map('map', null, {
.setView([47.47, 19.06], 15);
+
      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>
 
</script>
 
</body>
 
</body>
168. sor: 171. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Világtérkép folytonosságának kikapcsolása ====
+
==== Térkép nagyításának és mozgatásának letiltása ====
  
[http://zsataai.web.elte.hu/content/mapbox/disable_world_wrapping.html Disable world wrapping]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/disable_zooming_and_panning.html Disable zooming and panning]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Disable world wrapping -->
+
<!-- Disable zooming and panning -->
<!-- Instead of loading tiles beyond -180 and 180, only show one copy of the world. -->
+
<!-- How to disable zooming and panning with Mapbox.js, our open source JavaScript library. -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
180. sor: 183. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Disable world wrapping</title>
+
<title>Disable zooming and panning</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<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' />
 
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
 
<style>
 
<style>
body { margin:0; padding:0; }
+
  body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
+
  #map { position:absolute; top:0; bottom:0; width:100%; }
 
</style>
 
</style>
 
<script>
 
<script>
196. sor: 199. sor:
  
 
<script>
 
<script>
L.mapbox.accessToken = '<your access token here>';
+
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
+
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets', {
+
var map = L.mapbox.map('map', 'mapbox.streets', {
// These options apply to the tile layer in the map.
+
  zoomControl: false
tileLayer: {
+
}).setView([41.0252, 28.9950], 11);
// This map option disables world wrapping. by default, it is false.
+
 
continuousWorld: false,
+
// Disable drag and zoom handlers.
// This option disables loading tiles outside of the world bounds.
+
map.dragging.disable();
noWrap: true
+
map.touchZoom.disable();
}
+
map.doubleClickZoom.disable();
}).setView([40, 0], 2);
+
map.scrollWheelZoom.disable();
 +
map.keyboard.disable();
 +
 
 +
// Disable tap handler, if present.
 +
if (map.tap) map.tap.disable();
 
</script>
 
</script>
 
</body>
 
</body>
212. sor: 219. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Változtatható alapréteg ====
+
==== Megnézhető térképterület leszűkítése határokkal ====
  
[http://zsataai.web.elte.hu/content/mapbox/toggling_baselayers.html Toggling baselayers]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/using_maxbounds_to_restrict_map_panning.html Using maxBounds to restrict map panning]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Toggling baselayers -->
+
<!-- Using maxBounds to restrict map panning -->
<!-- Toggling between three different baselayers. -->
+
<!-- Preventing users from leaving an area on the map -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
224. sor: 231. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Toggling baselayers</title>
+
<title>Using maxBounds to restrict map panning</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
242. sor: 249. sor:
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
  var map = L.mapbox.map('map', null, {
+
// Construct a bounding box for this map that the user cannot
      maxZoom: 18
+
// move out of
  }).setView([22.76, -25.84], 3);
+
var southWest = L.latLng(46.47, 17.06),
 +
    northEast = L.latLng(48.47, 21.06),
 +
    bounds = L.latLngBounds(southWest, northEast);
  
  var layers = {
+
var map = L.mapbox.map('map', 'mapbox.streets', {
      Streets: L.mapbox.tileLayer('mapbox.streets'),
+
    // set that bounding box as maxBounds to restrict moving the map
      Outdoors: L.mapbox.tileLayer('mapbox.outdoors'),
+
    // see full maxBounds documentation:
      Satellite: L.mapbox.tileLayer('mapbox.satellite')
+
    // http://leafletjs.com/reference.html#map-maxbounds
  };
+
    maxBounds: bounds,
 +
    maxZoom: 19,
 +
    minZoom: 10
 +
});
  
  layers.Streets.addTo(map);
+
// zoom the map to that bounding box
  L.control.layers(layers).addTo(map);
+
map.fitBounds(bounds);
 
</script>
 
</script>
 
</body>
 
</body>
259. sor: 271. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Térkép nagyításának és mozgatásának letiltása ====
+
==== Dupla kattintásra nagyítás az adott területre középre helyezve + aránymérték ====
  
[http://zsataai.web.elte.hu/content/mapbox/disable_zooming_and_panning.html Disable zooming and panning]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/double_click_to_zoom_+_scale_control.html Double click to zoom]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Disable zooming and panning -->
+
<!-- Double click to zoom -->
<!-- How to disable zooming and panning with Mapbox.js, our open source JavaScript library. -->
+
<!-- Listen for a double click event from a user and zoom in on the map. -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
271. sor: 283. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Disable zooming and panning</title>
+
<title>Double click to zoom</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
290. sor: 302. sor:
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
 
var map = L.mapbox.map('map', 'mapbox.streets', {
 
var map = L.mapbox.map('map', 'mapbox.streets', {
  zoomControl: false
+
    // Disable default double-click behavior.
}).setView([41.0252, 28.9950], 11);
+
    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);
 +
});
  
// Disable drag and zoom handlers.
+
// L.control.scale() is included in Leaflet see
map.dragging.disable();
+
// https://www.mapbox.com/mapbox.js/api/v3.0.1/l-control-scale/
map.touchZoom.disable();
+
L.control.scale().addTo(map);
map.doubleClickZoom.disable();
 
map.scrollWheelZoom.disable();
 
map.keyboard.disable();
 
 
 
// Disable tap handler, if present.
 
if (map.tap) map.tap.disable();
 
 
</script>
 
</script>
 
</body>
 
</body>
307. sor: 319. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Megnézhető térképterület leszűkítése határokkal ====
+
==== Töltésjelző megjelenítése ====
  
[http://zsataai.web.elte.hu/content/mapbox/using_maxbounds_to_restrict_map_panning.html Using maxBounds to restrict map panning]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/show_loading_screen.html Show loading screen]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Using maxBounds to restrict map panning -->
+
<!-- Show loading screen -->
<!-- Preventing users from leaving an area on the map -->
+
<!-- Use events to show when features are loading and loaded by displaying and hiding a loading message -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
319. sor: 331. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Using maxBounds to restrict map panning</title>
+
<title>Show loading screen</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<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' />
 
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
 
<style>
 
<style>
  body { margin:0; padding:0; }
+
body { margin:0; padding:0; }
  #map { position:absolute; top:0; bottom:0; width:100%; }
+
#map { position:absolute; top:0; bottom:0; width:100%; }
 
</style>
 
</style>
 
<script>
 
<script>
332. sor: 344. sor:
 
</head>
 
</head>
 
<body>
 
<body>
<div id='map'></div>
+
<style>
  
<script>
+
/*
L.mapbox.accessToken = '<your access token here>';
+
* This is a very simple version of a 'loading screen': there are much
L.mapbox.accessToken = demoAccessToken;
+
* fancier ones you can use instead, like
// Construct a bounding box for this map that the user cannot
+
* http://codepen.io/collection/HtAne/
// move out of
+
*/
var southWest = L.latLng(46.47, 17.06),
+
#loader {
     northEast = L.latLng(48.47, 21.06),
+
    position:absolute; top:0; bottom:0; width:100%;
    bounds = L.latLngBounds(southWest, northEast);
+
    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);
  
var map = L.mapbox.map('map', 'mapbox.streets', {
+
// Add a tile layer with a loading animation
     // set that bounding box as maxBounds to restrict moving the map
+
 
     // see full maxBounds documentation:
+
// start the loading screen
    // http://leafletjs.com/reference.html#map-maxbounds
+
startLoading();
    maxBounds: bounds,
+
L.mapbox.tileLayer('mapbox.streets')
    maxZoom: 19,
+
     .addTo(map) // add your tiles to the map
     minZoom: 10
+
     .on('load', finishedLoading); // when the tiles load, remove the screen
});
+
 
 +
function startLoading() {
 +
     loader.className = '';
 +
}
  
// zoom the map to that bounding box
+
function finishedLoading() {
map.fitBounds(bounds);
+
    // 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>
 
</script>
 
</body>
 
</body>
359. sor: 407. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Dupla kattintásra nagyítás az adott területre középre helyezve + aránymérték ====
+
=== Jelölők a térképen ===
 +
 
 +
==== Egyszerű jelölő ikonnal ====
  
[http://zsataai.web.elte.hu/content/mapbox/double_click_to_zoom_+_scale_control.html Double click to zoom]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/marker_without_geojson.html Marker without GeoJSON]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Double click to zoom -->
+
<!-- Marker without GeoJSON -->
<!-- Listen for a double click event from a user and zoom in on the map. -->
+
<!-- Use L.mapbox.marker.icon to create a simple marker without GeoJSON. -->
 +
<!-- Icon examples: https://www.mapbox.com/maki-icons/ -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
371. sor: 422. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Double click to zoom</title>
+
<title>Marker without GeoJSON</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
380. sor: 431. sor:
 
</style>
 
</style>
 
<script>
 
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
+
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
 
</script>
 
</script>
 
</head>
 
</head>
389. sor: 440. sor:
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets', {
+
var map = L.mapbox.map('map', 'mapbox.streets')
    // Disable default double-click behavior.
+
     .setView([47.47, 19.06], 16);
     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
+
// L.marker is a low-level marker constructor in Leaflet.
// https://www.mapbox.com/mapbox.js/api/v3.0.1/l-control-scale/
+
L.marker([47.47, 19.06], {
L.control.scale().addTo(map);
+
    icon: L.mapbox.marker.icon({
 +
        'marker-size': 'large',
 +
        'marker-symbol': 'roadblock',
 +
        'marker-color': '#fa0'
 +
    })
 +
}).addTo(map);
 +
L.marker([47.4725, 19.0625], {
 +
    icon: L.mapbox.marker.icon({
 +
        'marker-size': 'large',
 +
        'marker-symbol': 'college',
 +
        'marker-color': '64BA49'
 +
    })
 +
}).addTo(map);
 
</script>
 
</script>
 
</body>
 
</body>
407. sor: 463. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Töltésjelző megjelenítése ====
+
==== Jelölő koordinátáinak megjelenítése ====
  
[http://zsataai.web.elte.hu/content/mapbox/show_loading_screen.html Show loading screen]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/display_latitude_and_longitude_on_marker_movement.html Display latitude and longitude on marker movement]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Show loading screen -->
+
<!-- Display latitude and longitude on marker movement -->
<!-- Use events to show when features are loading and loaded by displaying and hiding a loading message -->
+
<!-- Drag the marker to a new location on a map to view it's coordinates. -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
419. sor: 475. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Show loading screen</title>
+
<title>Display latitude and longitude on marker movement</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<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' />
 
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
 
<style>
 
<style>
body { margin:0; padding:0; }
+
  body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
+
  #map { position:absolute; top:0; bottom:0; width:100%; }
 
</style>
 
</style>
 
<script>
 
<script>
433. sor: 489. sor:
 
<body>
 
<body>
 
<style>
 
<style>
 
+
pre.ui-coordinates {
/*
+
  position:absolute;
* This is a very simple version of a 'loading screen': there are much
+
  bottom:10px;
* fancier ones you can use instead, like
+
  left:10px;
* http://codepen.io/collection/HtAne/
+
  padding:5px 10px;
*/
+
  background:rgba(0,0,0,0.5);
#loader {
+
  color:#fff;
    position:absolute; top:0; bottom:0; width:100%;
+
  font-size:11px;
    background:rgba(255, 255, 255, 1);
+
  line-height:18px;
    transition:background 1s ease-out;
+
  border-radius:3px;
    -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>
 
</style>
 
<div id='map'></div>
 
<div id='map'></div>
<div id='loader'><span class='message'>loading</span></div>
+
<pre id='coordinates' class='ui-coordinates'></pre>
 
<script>
 
<script>
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
var loader = document.getElementById('loader');
+
var map = L.mapbox.map('map', 'mapbox.streets')
 +
    .setView([0, 0], 3);
  
var map = L.mapbox.map('map')
+
var coordinates = document.getElementById('coordinates');
    .setView([47.47, 19.06], 13);
 
  
// Add a tile layer with a loading animation
+
var marker = L.marker([0, 0], {
 +
    icon: L.mapbox.marker.icon({
 +
      'marker-color': '#f86767'
 +
    }),
 +
    draggable: true
 +
}).addTo(map);
  
// start the loading screen
+
// every time the marker is dragged, update the coordinates container
startLoading();
+
marker.on('dragend', ondragend);
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() {
+
// Set the initial marker coordinate on load.
    loader.className = '';
+
ondragend();
}
 
  
function finishedLoading() {
+
function ondragend() {
     // first, toggle the class 'done', which makes the loading screen
+
     var m = marker.getLatLng();
    // fade out
+
     coordinates.innerHTML = 'Latitude: ' + m.lat + '<br />Longitude: ' + m.lng;
     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>
 
</script>
495. sor: 533. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Jelölők a térképen ===
+
==== Jelölőtől való távolság ====
  
==== Egyszerű jelölő ikonnal ====
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/distance_between_two_markers.html Distance between two markers]
 
 
[http://zsataai.web.elte.hu/content/mapbox/marker_without_geojson.html Marker without GeoJSON]
 
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Marker without GeoJSON -->
+
<!-- Distance between two markers -->
<!-- Use L.mapbox.marker.icon to create a simple marker without GeoJSON. -->
+
<!-- Calculate the distance between two points in meters using distanceTo. -->
<!-- Icon examples: https://www.mapbox.com/maki-icons/ -->
 
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
510. sor: 545. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Marker without GeoJSON</title>
+
<title>Distance between two markers</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
523. sor: 558. sor:
 
</head>
 
</head>
 
<body>
 
<body>
<div id='map'></div>
+
<style>
 
+
pre.ui-distance {
<script>
+
  position:absolute;
 +
  bottom:10px;
 +
  left:10px;
 +
  padding:5px 10px;
 +
  background:rgba(0,0,0,0.5);
 +
  color:#fff;
 +
  font-size:11px;
 +
  line-height:18px;
 +
  border-radius:3px;
 +
  }
 +
</style>
 +
<div id='map'></div>
 +
<pre id='distance' class='ui-distance'>Click to place a marker</pre>
 +
 
 +
<script>
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
 
var map = L.mapbox.map('map', 'mapbox.streets')
 
var map = L.mapbox.map('map', 'mapbox.streets')
     .setView([47.47, 19.06], 16);
+
     .setView([47.47, 19.06], 15);
  
// L.marker is a low-level marker constructor in Leaflet.
+
// Start with a fixed marker.
L.marker([47.47, 19.06], {
+
var fixedMarker = L.marker(new L.LatLng(47.4725, 19.0625), {
 
     icon: L.mapbox.marker.icon({
 
     icon: L.mapbox.marker.icon({
        'marker-size': 'large',
+
         'marker-color': 'ff8888'
        'marker-symbol': 'roadblock',
 
         'marker-color': '#fa0'
 
 
     })
 
     })
}).addTo(map);
+
}).bindPopup('ELTE Déli tömb').addTo(map);
L.marker([47.4725, 19.0625], {
+
 
    icon: L.mapbox.marker.icon({
+
// Store the fixedMarker coordinates in a variable.
        'marker-size': 'large',
+
var fc = fixedMarker.getLatLng();
        'marker-symbol': 'college',
 
        'marker-color': '64BA49'
 
    })
 
}).addTo(map);
 
</script>
 
</body>
 
</html>
 
</syntaxhighlight>
 
  
==== Jelölő koordinátáinak megjelenítése ====
+
// Create a featureLayer that will hold a marker and linestring.
 +
var featureLayer = L.mapbox.featureLayer().addTo(map);
  
[http://zsataai.web.elte.hu/content/mapbox/display_latitude_and_longitude_on_marker_movement.html Display latitude and longitude on marker movement]
+
// When a user clicks on the map we want to
 +
// create a new L.featureGroup that will contain a
 +
// marker placed where the user selected the map and
 +
// a linestring that draws itself between the fixedMarkers
 +
// coordinates and the newly placed marker.
 +
map.on('click', function(ev) {
 +
    // ev.latlng gives us the coordinates of
 +
    // the spot clicked on the map.
 +
    var c = ev.latlng;
  
<syntaxhighlight lang="html5">
+
    var geojson = {
<!-- Display latitude and longitude on marker movement -->
+
      type: 'FeatureCollection',
<!-- Drag the marker to a new location on a map to view it's coordinates. -->
+
      features: [
 +
        {
 +
          "type": "Feature",
 +
          "geometry": {
 +
            "type": "Point",
 +
            "coordinates": [c.lng, c.lat]
 +
          },
 +
          "properties": {
 +
            "marker-color": "#ff8888"
 +
          }
 +
        }, {
 +
          "type": "Feature",
 +
          "geometry": {
 +
            "type": "LineString",
 +
            "coordinates": [
 +
              [fc.lng, fc.lat],
 +
              [c.lng, c.lat]
 +
            ]
 +
          },
 +
          "properties": {
 +
            "stroke": "#000",
 +
            "stroke-opacity": 0.5,
 +
            "stroke-width": 4
 +
          }
 +
        }
 +
      ]
 +
    };
  
<!DOCTYPE html>
+
    featureLayer.setGeoJSON(geojson);
<html>
+
 
 +
    // Finally, print the distance between these two points
 +
    // on the screen using distanceTo().
 +
    var container = document.getElementById('distance');
 +
    container.innerHTML = (fc.distanceTo(c)).toFixed(0) + 'm';
 +
});
 +
</script>
 +
</body>
 +
</html>
 +
</syntaxhighlight>
 +
 
 +
==== Navigáció jelölőket tartalmazó menüvel ====
 +
 
 +
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/marker_navigation_from_a_marker_menu.html Marker navigation from a marker menu]
 +
 
 +
<syntaxhighlight lang="html5">
 +
 
 +
<!-- Marker navigation from a marker menu -->
 +
<!-- Zoom to a marker and open its tooltip when a marker menu in a list is selected. -->
 +
<!DOCTYPE html>
 +
<html>
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Display latitude and longitude on marker movement</title>
+
<title>Marker navigation from a marker menu</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
577. sor: 671. sor:
 
<body>
 
<body>
 
<style>
 
<style>
pre.ui-coordinates {
+
  .info {
  position:absolute;
+
    background:#fff;
  bottom:10px;
+
    position:absolute;
  left:10px;
+
    width:260px;
  padding:5px 10px;
+
    top:10px;
  background:rgba(0,0,0,0.5);
+
    right:10px;
  color:#fff;
+
    border-radius:2px;
  font-size:11px;
+
    }
  line-height:18px;
+
    .info .item {
  border-radius:3px;
+
      display:block;
  }
+
      border-bottom:1px solid #eee;
 +
      padding:10px;
 +
      text-decoration:none;
 +
      }
 +
      .info .item small { color:#888; }
 +
      .info .item:hover,
 +
      .info .item.active { background:#f8f8f8; }
 +
      .info .item:last-child { border-bottom:none; }
 
</style>
 
</style>
<div id='map'></div>
+
 
<pre id='coordinates' class='ui-coordinates'></pre>
+
<div id='map' class='map'></div>
 +
<div id='info' class='info'></div>
 +
 
 
<script>
 
<script>
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets')
+
var map = L.mapbox.map('map', 'mapbox.streets').setView([47.47, 19.06], 15);
    .setView([0, 0], 3);
 
  
var coordinates = document.getElementById('coordinates');
+
var myLayer = L.mapbox.featureLayer().addTo(map);
  
var marker = L.marker([0, 0], {
+
myLayer.setGeoJSON({
    icon: L.mapbox.marker.icon({
+
  type: 'FeatureCollection',
      'marker-color': '#f86767'
+
  features: [
     }),
+
    {
     draggable: true
+
      type: 'Feature',
}).addTo(map);
+
      geometry: {
 
+
          type: 'Point',
// every time the marker is dragged, update the coordinates container
+
          coordinates: [19.0625, 47.4725]
marker.on('dragend', ondragend);
+
      },
 
+
      properties: {
// Set the initial marker coordinate on load.
+
          title: 'ELTE Déli tömb',
ondragend();
+
          description: 'ELTE IK',
 
+
          'marker-id': 'marker-1',
function ondragend() {
+
          'marker-color': '#f86767'
    var m = marker.getLatLng();
+
      }
    coordinates.innerHTML = 'Latitude: ' + m.lat + '<br />Longitude: ' + m.lng;
+
     },
}
+
     {
</script>
+
          type: 'Feature',
</body>
+
          geometry: {
</html>
+
              type: 'Point',
</syntaxhighlight>
+
              coordinates: [19.0625, 47.4745]
 
+
          },
==== Jelölőtől való távolság ====
+
          properties: {
 
+
              title: 'ELTE Északi tömb',
[http://zsataai.web.elte.hu/content/mapbox/distance_between_two_markers.html Distance between two markers]
+
              description: 'ELTE TTK',
 
+
              'marker-id': 'marker-2',
<syntaxhighlight lang="html5">
+
              'marker-color': '#f86767'
<!-- Distance between two markers -->
+
          }
<!-- Calculate the distance between two points in meters using distanceTo. -->
+
      },
 +
{
 +
  type: 'Feature',
 +
  geometry: {
 +
  type: 'Point',
 +
  coordinates: [19.063425, 47.505258]
 +
  },
 +
  properties: {
 +
  title: 'Oktogon',
 +
  description: 'Oktogon metró állomás',
 +
  'marker-id': 'marker-2',
 +
  'marker-color': '#f86767',
 +
  'marker-symbol': 'rail-metro'
 +
  }
 +
}
 +
  ]
 +
});
 +
 
 +
var info = document.getElementById('info');
  
<!DOCTYPE html>
+
// Iterate through each feature layer item, build a
<html>
+
// marker menu item and enable a click event that pans to + opens
<head>
+
// a marker that's associated to the marker item.
<meta charset=utf-8 />
+
myLayer.eachLayer(function(marker) {
<title>Distance between two markers</title>
+
  var link = info.appendChild(document.createElement('a'));
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
+
  link.className = 'item';
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
+
  link.href = '#';
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
+
 
<style>
+
  // Populate content from each markers object.
  body { margin:0; padding:0; }
+
  link.innerHTML = marker.feature.properties.title +
  #map { position:absolute; top:0; bottom:0; width:100%; }
+
    '<br /><small>' + marker.feature.properties.description + '</small>';
</style>
+
  link.onclick = function() {
<script>
+
    if (/active/.test(this.className)) {
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
+
      this.className = this.className.replace(/active/, '').replace(/\s\s*$/, '');
</script>
+
    } else {
</head>
+
      var siblings = info.getElementsByTagName('a');
<body>
+
      for (var i = 0; i < siblings.length; i++) {
<style>
+
        siblings[i].className = siblings[i].className
pre.ui-distance {
+
          .replace(/active/, '').replace(/\s\s*$/, '');
  position:absolute;
+
      };
  bottom:10px;
+
      this.className += ' active';
  left:10px;
 
  padding:5px 10px;
 
  background:rgba(0,0,0,0.5);
 
  color:#fff;
 
  font-size:11px;
 
  line-height:18px;
 
  border-radius:3px;
 
  }
 
</style>
 
<div id='map'></div>
 
<pre id='distance' class='ui-distance'>Click to place a marker</pre>
 
  
<script>
+
      // When a menu item is clicked, animate the map to center
L.mapbox.accessToken = '<your access token here>';
+
      // its associated marker and open its popup.
L.mapbox.accessToken = demoAccessToken;
+
      map.panTo(marker.getLatLng());
var map = L.mapbox.map('map', 'mapbox.streets')
+
      marker.openPopup();
    .setView([47.47, 19.06], 15);
+
     }
 
+
    return false;
// Start with a fixed marker.
+
  };
var fixedMarker = L.marker(new L.LatLng(47.4725, 19.0625), {
+
});
     icon: L.mapbox.marker.icon({
+
</script>
        'marker-color': 'ff8888'
+
</body>
    })
+
</html>
}).bindPopup('ELTE Déli tömb').addTo(map);
+
</syntaxhighlight>
  
// Store the fixedMarker coordinates in a variable.
+
==== Csak a környező jelölők megjelenítése ====
var fc = fixedMarker.getLatLng();
 
  
// Create a featureLayer that will hold a marker and linestring.
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/marker_radius_search.html Marker radius search]
var featureLayer = L.mapbox.featureLayer().addTo(map);
 
  
// When a user clicks on the map we want to
+
<syntaxhighlight lang="html5">
// create a new L.featureGroup that will contain a
+
<!-- Marker radius search -->
// marker placed where the user selected the map and
+
<!-- Use the .distanceTo function to only show markers within a range -->
// a linestring that draws itself between the fixedMarkers
 
// coordinates and the newly placed marker.
 
map.on('click', function(ev) {
 
    // ev.latlng gives us the coordinates of
 
    // the spot clicked on the map.
 
    var c = ev.latlng;
 
  
    var geojson = {
+
<!DOCTYPE html>
      type: 'FeatureCollection',
+
<html>
      features: [
+
<head>
        {
+
<meta charset=utf-8 />
          "type": "Feature",
+
<title>Marker radius search</title>
          "geometry": {
+
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
            "type": "Point",
+
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
            "coordinates": [c.lng, c.lat]
+
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
          },
+
<style>
          "properties": {
+
  body { margin:0; padding:0; }
            "marker-color": "#ff8888"
+
  #map { position:absolute; top:0; bottom:0; width:100%; }
          }
+
</style>
        }, {
+
<script>
          "type": "Feature",
+
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
          "geometry": {
+
</script>
            "type": "LineString",
+
</head>
            "coordinates": [
+
<body>
              [fc.lng, fc.lat],
+
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-omnivore/v0.2.0/leaflet-omnivore.min.js'></script>
              [c.lng, c.lat]
+
<div id='map'></div>
            ]
 
          },
 
          "properties": {
 
            "stroke": "#000",
 
            "stroke-opacity": 0.5,
 
            "stroke-width": 4
 
          }
 
        }
 
      ]
 
    };
 
  
     featureLayer.setGeoJSON(geojson);
+
<script>
 +
L.mapbox.accessToken = '<your access token here>';
 +
L.mapbox.accessToken = demoAccessToken;
 +
var map = L.mapbox.map('map', 'mapbox.emerald')
 +
     .setView([40, -95], 4);
  
     // Finally, print the distance between these two points
+
var RADIUS = 500000;
     // on the screen using distanceTo().
+
var filterCircle = L.circle(L.latLng(40, -75), RADIUS, {
    var container = document.getElementById('distance');
+
    opacity: 1,
     container.innerHTML = (fc.distanceTo(c)).toFixed(0) + 'm';
+
     weight: 1,
 +
     fillOpacity: 0.4
 +
}).addTo(map);
 +
 
 +
var csvLayer = omnivore.csv('./data/airports.csv', null, L.mapbox.featureLayer())
 +
    .addTo(map);
 +
 
 +
map.on('mousemove', function(e) {
 +
    filterCircle.setLatLng(e.latlng);
 +
     csvLayer.setFilter(function showAirport(feature) {
 +
        return e.latlng.distanceTo(L.latLng(
 +
                feature.geometry.coordinates[1],
 +
                feature.geometry.coordinates[0])) < RADIUS;
 +
    });
 
});
 
});
 
</script>
 
</script>
733. sor: 841. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Navigáció jelölőket tartalmazó menüvel ====
+
==== Jelölő mozgatása programozottan ====
  
[http://zsataai.web.elte.hu/content/mapbox/marker_navigation_from_a_marker_menu.html Marker navigation from a marker menu]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/marker_movement.html Marker movement]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
 +
<!-- Marker movement -->
 +
<!-- Simple marker animation. -->
  
<!-- Marker navigation from a marker menu -->
 
<!-- Zoom to a marker and open its tooltip when a marker menu in a list is selected. -->
 
 
<!DOCTYPE html>
 
<!DOCTYPE html>
 
<html>
 
<html>
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Marker navigation from a marker menu</title>
+
<title>Marker movement</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
758. sor: 866. sor:
 
</head>
 
</head>
 
<body>
 
<body>
<style>
+
<div id='map'></div>
  .info {
+
 
    background:#fff;
+
<script>
    position:absolute;
 
    width:260px;
 
    top:10px;
 
    right:10px;
 
    border-radius:2px;
 
    }
 
    .info .item {
 
      display:block;
 
      border-bottom:1px solid #eee;
 
      padding:10px;
 
      text-decoration:none;
 
      }
 
      .info .item small { color:#888; }
 
      .info .item:hover,
 
      .info .item.active { background:#f8f8f8; }
 
      .info .item:last-child { border-bottom:none; }
 
</style>
 
 
 
<div id='map' class='map'></div>
 
<div id='info' class='info'></div>
 
 
 
<script>
 
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets').setView([47.47, 19.06], 15);
+
var map = L.mapbox.map('map', 'mapbox.light')
 +
  .setView([0, 0], 3);
  
var myLayer = L.mapbox.featureLayer().addTo(map);
+
var marker = L.marker([0, 0], {
 
+
    icon: L.mapbox.marker.icon({
myLayer.setGeoJSON({
+
       'marker-color': '#f86767'
  type: 'FeatureCollection',
+
    })
  features: [
+
});
    {
+
 
      type: 'Feature',
+
var t = 0;
      geometry: {
+
window.setInterval(function() {
          type: 'Point',
+
    // Making a lissajous curve just for fun.
          coordinates: [19.0625, 47.4725]
+
    // Create your own animated path here.
       },
+
    marker.setLatLng(L.latLng(
      properties: {
+
        Math.cos(t * 0.5) * 10,
          title: 'ELTE Déli tömb',
+
        Math.sin(t) * 10));
          description: 'ELTE IK',
+
    t += 0.01; // Movement
          'marker-id': 'marker-1',
+
}, 1); // Speed
          'marker-color': '#f86767'
+
 
      }
+
marker.addTo(map);
    },
+
</script>
    {
+
</body>
          type: 'Feature',
+
</html>
          geometry: {
+
</syntaxhighlight>
              type: 'Point',
+
 
              coordinates: [19.0625, 47.4745]
+
==== Jelölő animálása geoJson vonalon ====
          },
+
 
          properties: {
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/animate_a_marker_along_line.html Animate a marker along line]
              title: 'ELTE Északi tömb',
+
 
              description: 'ELTE TTK',
+
<syntaxhighlight lang="html5">
              'marker-id': 'marker-2',
+
<!-- Animate a marker along line -->
              'marker-color': '#f86767'
+
<!-- Create a marker and animate its position along the length of a line by looking up its coordinates. -->
          }
+
 
      },
+
<!DOCTYPE html>
{
+
<html>
  type: 'Feature',
+
<head>
  geometry: {
+
<meta charset=utf-8 />
  type: 'Point',
+
<title>Animate a marker along line</title>
  coordinates: [19.063425, 47.505258]
+
<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>
  properties: {
+
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
  title: 'Oktogon',
+
<style>
  description: 'Oktogon metró állomás',
+
  body { margin:0; padding:0; }
  'marker-id': 'marker-2',
+
  #map { position:absolute; top:0; bottom:0; width:100%; }
  'marker-color': '#f86767',
+
</style>
  'marker-symbol': 'rail-metro'
+
<script>
  }
+
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
}
+
</script>
  ]
+
</head>
});
+
<body>
 +
<div id='map'></div>
  
var info = document.getElementById('info');
+
<script>
 +
L.mapbox.accessToken = '<your access token here>';
 +
L.mapbox.accessToken = demoAccessToken;
 +
var map = L.mapbox.map('map', 'mapbox.streets').setView([0, 0], 3);
  
// Iterate through each feature layer item, build a
+
// Generate a GeoJSON line. You could also load GeoJSON via AJAX
// marker menu item and enable a click event that pans to + opens
+
// or generate it some other way.
// a marker that's associated to the marker item.
+
var geojson = { type: 'LineString', coordinates: [] };
myLayer.eachLayer(function(marker) {
+
var start = [0, 0];
  var link = info.appendChild(document.createElement('a'));
+
var momentum = [2, 2];
  link.className = 'item';
 
  link.href = '#';
 
  
  // Populate content from each markers object.
+
for (var i = 0; i < 1000; i++) {
  link.innerHTML = marker.feature.properties.title +
+
     start[0] += momentum[0];
     '<br /><small>' + marker.feature.properties.description + '</small>';
+
    start[1] += momentum[1];
  link.onclick = function() {
+
     if (start[1] > 30 || start[1] < -30) momentum[1] *= -1;
     if (/active/.test(this.className)) {
+
     if (start[0] > 90 || start[0] < -90) momentum[0] *= -1;
      this.className = this.className.replace(/active/, '').replace(/\s\s*$/, '');
+
    geojson.coordinates.push(start.slice());
     } else {
+
}
      var siblings = info.getElementsByTagName('a');
 
      for (var i = 0; i < siblings.length; i++) {
 
        siblings[i].className = siblings[i].className
 
          .replace(/active/, '').replace(/\s\s*$/, '');
 
      };
 
      this.className += ' active';
 
  
      // When a menu item is clicked, animate the map to center
+
// Add this generated geojson object to the map.
      // its associated marker and open its popup.
+
L.geoJson(geojson).addTo(map);
      map.panTo(marker.getLatLng());
 
      marker.openPopup();
 
    }
 
    return false;
 
  };
 
});
 
</script>
 
</body>
 
</html>
 
</syntaxhighlight>
 
  
==== Csak a környező jelölők megjelenítése ====
+
// Create a counter with a value of 0.
 +
var j = 0;
  
[http://zsataai.web.elte.hu/content/mapbox/marker_radius_search.html Marker radius search]
+
// Create a marker and add it to the map.
 +
var marker = L.marker([0, 0], {
 +
  icon: L.mapbox.marker.icon({
 +
    'marker-color': '#f86767'
 +
  })
 +
}).addTo(map);
  
<syntaxhighlight lang="html5">
+
tick();
<!-- Marker radius search -->
+
function tick() {
<!-- Use the .distanceTo function to only show markers within a range -->
+
    // Set the marker to be at the same point as one
 +
    // of the segments or the line.
 +
    marker.setLatLng(L.latLng(
 +
        geojson.coordinates[j][1],
 +
        geojson.coordinates[j][0]));
 +
 
 +
    // Move to the next point of the line
 +
    // until `j` reaches the length of the array.
 +
    if (++j < geojson.coordinates.length) setTimeout(tick, 20);
 +
}
 +
</script>
 +
</body>
 +
</html>
 +
</syntaxhighlight>
  
<!DOCTYPE html>
+
=== Tippek, üzenetek, szövegek ===
<html>
+
 
<head>
+
==== Egyedi jelölő tipp ====
<meta charset=utf-8 />
+
 
<title>Marker radius search</title>
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/custom_marker_tooltips.html Custom marker tooltips]
 +
 
 +
<syntaxhighlight lang="html5">
 +
<!-- Custom marker tooltips -->
 +
<!-- How to create a custom marker tooltip with style text or images using Mapbox.js, our open source JavaScript library. -->
 +
 
 +
<!DOCTYPE html>
 +
<html>
 +
<head>
 +
<meta charset=utf-8 />
 +
<title>Custom marker tooltips</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
897. sor: 999. sor:
 
</head>
 
</head>
 
<body>
 
<body>
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-omnivore/v0.2.0/leaflet-omnivore.min.js'></script>
+
<style>
 +
.leaflet-popup-content img {
 +
  max-width:100%;
 +
  }
 +
</style>
 
<div id='map'></div>
 
<div id='map'></div>
  
903. sor: 1 009. sor:
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.emerald')
+
var map = L.mapbox.map('map', 'mapbox.streets')
     .setView([40, -95], 4);
+
     .setView([47.47, 19.06], 15);
 +
 
 +
var myLayer = L.mapbox.featureLayer().addTo(map);
  
var RADIUS = 500000;
+
var geoJson = [{
var filterCircle = L.circle(L.latLng(40, -75), RADIUS, {
+
    type: 'Feature',
    opacity: 1,
+
    "geometry": { "type": "Point", "coordinates": [19.06, 47.47]},
    weight: 1,
+
    "properties": {
    fillOpacity: 0.4
+
        "image": "http://hazai.kozep.bme.hu/wp-content/uploads/2013/06/00-Info-E-nyit%C3%B3.jpg",
}).addTo(map);
+
        "url": "http://www.infopark.hu/",
 +
        "marker-symbol": "star",
 +
        "marker-color": "#ff8888",
 +
        "marker-size": "large",
 +
        "city": "Budapest - Infopark"
 +
    }
 +
},
 +
{
 +
type: 'Feature',
 +
"geometry": { "type": "Point", "coordinates": [19.063, 47.473]},
 +
"properties": {
 +
"image": "http://photos.wikimapia.org/p/00/02/45/33/03_big.jpg",
 +
"url": "https://www.elte.hu/",
 +
"marker-symbol": "star",
 +
"marker-color": "#ff8888",
 +
"marker-size": "large",
 +
"city": "Budapest - ELTE Lágymányos"
 +
}
 +
}];
  
var csvLayer = omnivore.csv('./data/airports.csv', null, L.mapbox.featureLayer())
+
// Add custom popups to each using our custom feature properties
    .addTo(map);
+
myLayer.on('layeradd', function(e) {
 +
    var marker = e.layer,
 +
        feature = marker.feature;
 +
 
 +
    // Create custom popup content
 +
    var popupContent =  '<a target="_blank" class="popup" href="' + feature.properties.url + '">' +
 +
                            '<img src="' + feature.properties.image + '" />' +
 +
                            feature.properties.city +
 +
                        '</a>';
  
map.on('mousemove', function(e) {
+
     // http://leafletjs.com/reference.html#popup
     filterCircle.setLatLng(e.latlng);
+
     marker.bindPopup(popupContent,{
     csvLayer.setFilter(function showAirport(feature) {
+
         closeButton: false,
         return e.latlng.distanceTo(L.latLng(
+
        minWidth: 480
                feature.geometry.coordinates[1],
 
                feature.geometry.coordinates[0])) < RADIUS;
 
 
     });
 
     });
 
});
 
});
 +
 +
// Add features to the map
 +
myLayer.setGeoJSON(geoJson);
 
</script>
 
</script>
 
</body>
 
</body>
929. sor: 1 064. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Jelölő mozgatása programozottan ====
+
==== Jelölőhöz tartozó tipp megjelenítése egérrel ====
  
[http://zsataai.web.elte.hu/content/mapbox/marker_movement.html Marker movement]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/show_tooltips_on_hover.html Show tooltips on hover]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Marker movement -->
+
<!-- Show tooltips on hover -->
<!-- Simple marker animation. -->
+
<!-- How to show marker popups on hover with Mapbox.js, our open source JavaScript library. -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
941. sor: 1 076. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Marker movement</title>
+
<title>Show tooltips on hover</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
960. sor: 1 095. sor:
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
 
var map = L.mapbox.map('map', 'mapbox.light')
 
var map = L.mapbox.map('map', 'mapbox.light')
   .setView([0, 0], 3);
+
   .setView([47.47, 19.06], 15);
  
var marker = L.marker([0, 0], {
+
var myLayer = L.mapbox.featureLayer().addTo(map);
    icon: L.mapbox.marker.icon({
 
      'marker-color': '#f86767'
 
    })
 
});
 
  
var t = 0;
+
var geojson = {
window.setInterval(function() {
+
    type: 'FeatureCollection',
    // Making a lissajous curve just for fun.
+
    features: [{
     // Create your own animated path here.
+
        type: 'Feature',
     marker.setLatLng(L.latLng(
+
        properties: {
         Math.cos(t * 0.5) * 10,
+
            title: 'Bal alsó',
         Math.sin(t) * 10));
+
            'marker-color': '#f86767',
     t += 0.01; // Movement
+
            'marker-size': 'small',
}, 1); // Speed
+
            'marker-symbol': 'star'
 +
        },
 +
        geometry: {
 +
            type: 'Point',
 +
            coordinates: [19.05, 47.46]
 +
        }
 +
     },
 +
     {
 +
        type: 'Feature',
 +
        properties: {
 +
            title: 'Jobb felső',
 +
            'marker-color': '#7ec9b1',
 +
            'marker-size': 'large',
 +
            'marker-symbol': 'star'
 +
        },
 +
         geometry: {
 +
            type: 'Point',
 +
            coordinates: [19.07, 47.48]
 +
         }
 +
     }]
 +
};
  
marker.addTo(map);
+
myLayer.setGeoJSON(geojson);
 +
myLayer.on('mouseover', function(e) {
 +
    e.layer.openPopup();
 +
});
 +
myLayer.on('mouseout', function(e) {
 +
    e.layer.closePopup();
 +
});
 
</script>
 
</script>
 
</body>
 
</body>
984. sor: 1 141. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Jelölő animálása geoJson vonalon ====
+
=== Helyek ===
  
[http://zsataai.web.elte.hu/content/mapbox/animate_a_marker_along_line.html Animate a marker along line]
+
==== Hely keresése automatikus kiegészítéssel ====
 +
 
 +
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/geocoding_with_autocomplete.html Geocoding with autocomplete]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Animate a marker along line -->
+
<!-- Geocoding with autocomplete -->
<!-- Create a marker and animate its position along the length of a line by looking up its coordinates. -->
+
<!-- Using the Mapbox Geocoding API to show real-time search suggestions. -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
996. sor: 1 155. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Animate a marker along line</title>
+
<title>Geocoding with autocomplete</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
1 010. sor: 1 169. sor:
 
<body>
 
<body>
 
<div id='map'></div>
 
<div id='map'></div>
 
 
<script>
 
<script>
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets').setView([0, 0], 3);
+
L.mapbox.map('map', 'mapbox.streets')
 +
    .addControl(L.mapbox.geocoderControl('mapbox.places', {
 +
        autocomplete: true
 +
    }));
 +
</script>
 +
</body>
 +
</html>
 +
</syntaxhighlight>
 +
 
 +
==== Hely lekérdezése név alapján (Geocoderrel) ====
  
// Generate a GeoJSON line. You could also load GeoJSON via AJAX
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/use_geocoder_to_set_map_position.html Use geocoder to set map position]
// or generate it some other way.
 
var geojson = { type: 'LineString', coordinates: [] };
 
var start = [0, 0];
 
var momentum = [2, 2];
 
  
for (var i = 0; i < 1000; i++) {
+
<syntaxhighlight lang="html5">
    start[0] += momentum[0];
+
<!-- Use geocoder to set map position -->
    start[1] += momentum[1];
+
<!-- Using the Mapbox Geocoding API initially set map position on Chester, New Jersey. -->
    if (start[1] > 30 || start[1] < -30) momentum[1] *= -1;
 
    if (start[0] > 90 || start[0] < -90) momentum[0] *= -1;
 
    geojson.coordinates.push(start.slice());
 
}
 
  
// Add this generated geojson object to the map.
+
<!DOCTYPE html>
L.geoJson(geojson).addTo(map);
+
<html>
 
+
<head>
// Create a counter with a value of 0.
+
<meta charset=utf-8 />
var j = 0;
+
<title>Use geocoder to set map position</title>
 
+
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
// Create a marker and add it to the map.
+
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
var marker = L.marker([0, 0], {
+
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
  icon: L.mapbox.marker.icon({
+
<style>
    'marker-color': '#f86767'
+
   body { margin:0; padding:0; }
   })
+
  #map { position:absolute; top:0; bottom:0; width:100%; }
}).addTo(map);
+
</style>
 
+
<script>
tick();
+
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
function tick() {
 
    // Set the marker to be at the same point as one
 
    // of the segments or the line.
 
    marker.setLatLng(L.latLng(
 
        geojson.coordinates[j][1],
 
        geojson.coordinates[j][0]));
 
 
 
    // Move to the next point of the line
 
    // until `j` reaches the length of the array.
 
    if (++j < geojson.coordinates.length) setTimeout(tick, 20);
 
}
 
 
</script>
 
</script>
</body>
+
</head>
</html>
+
<body>
</syntaxhighlight>
+
<div id='map'></div>
 +
<script>
 +
L.mapbox.accessToken = '<your access token here>';
 +
L.mapbox.accessToken = demoAccessToken;
 +
var geocoder = L.mapbox.geocoder('mapbox.places'),
 +
    map = L.mapbox.map('map', 'examples.map-h67hf2ic');
  
=== Tippek, üzenetek, szövegek ===
+
geocoder.query('Tab, HU', showMap);
  
==== Egyedi jelölő tipp ====
+
function showMap(err, data) {
 +
    // The geocoder can return an area, like a city, or a
 +
    // point, like an address. Here we handle both cases,
 +
    // by fitting the map bounds to an area or zooming to a point.
 +
    if (data.lbounds) {
 +
        map.fitBounds(data.lbounds);
 +
    } else if (data.latlng) {
 +
        map.setView([data.latlng[0], data.latlng[1]], 13);
 +
    }
 +
}
 +
</script>
 +
</body>
 +
</html>
 +
</syntaxhighlight>
 +
 
 +
==== Aktuális pozíció megjelenítése (megközelítőleg) ====
 +
 
 +
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/geolocation.html Geolocation]
  
[http://zsataai.web.elte.hu/content/mapbox/custom_marker_tooltips.html Custom marker tooltips]
+
FONTOS: A Geolocation, azaz helymeghatározás használatához valid HTTPS kapcsolat szükséges.
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Custom marker tooltips -->
+
<!-- Geolocation -->
<!-- How to create a custom marker tooltip with style text or images using Mapbox.js, our open source JavaScript library. -->
+
<!-- Finding the user's position -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
1 074. sor: 1 244. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Custom marker tooltips</title>
+
<title>Geolocation</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
1 088. sor: 1 258. sor:
 
<body>
 
<body>
 
<style>
 
<style>
.leaflet-popup-content img {
+
.ui-button {
   max-width:100%;
+
  background:#3887BE;
 +
  color:#FFF;
 +
  display:block;
 +
  position:absolute;
 +
  top:50%;left:50%;
 +
  width:160px;
 +
  margin:-20px 0 0 -80px;
 +
   z-index:100;
 +
  text-align:center;
 +
  padding:10px;
 +
  border:1px solid rgba(0,0,0,0.4);
 +
  border-radius:3px;
 
   }
 
   }
 +
  .ui-button:hover {
 +
    background:#3074a4;
 +
    color:#fff;
 +
    }
 
</style>
 
</style>
 +
 
<div id='map'></div>
 
<div id='map'></div>
 +
<a href='#' id='geolocate' class='ui-button'>Find me</a>
  
 
<script>
 
<script>
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets')
+
var geolocate = document.getElementById('geolocate');
    .setView([47.47, 19.06], 15);
+
var map = L.mapbox.map('map', 'mapbox.streets');
  
 
var myLayer = L.mapbox.featureLayer().addTo(map);
 
var myLayer = L.mapbox.featureLayer().addTo(map);
  
var geoJson = [{
+
// This uses the HTML5 geolocation API, which is available on
     type: 'Feature',
+
// most mobile browsers and modern browsers, but not in Internet Explorer
    "geometry": { "type": "Point", "coordinates": [19.06, 47.47]},
+
//
     "properties": {
+
// See this chart of compatibility for details:
         "image": "http://hazai.kozep.bme.hu/wp-content/uploads/2013/06/00-Info-E-nyit%C3%B3.jpg",
+
// http://caniuse.com/#feat=geolocation
        "url": "http://www.infopark.hu/",
+
if (!navigator.geolocation) {
        "marker-symbol": "star",
+
     geolocate.innerHTML = 'Geolocation is not available';
        "marker-color": "#ff8888",
+
} else {
        "marker-size": "large",
+
     geolocate.onclick = function (e) {
        "city": "Budapest - Infopark"
+
         e.preventDefault();
     }
+
        e.stopPropagation();
},
+
        map.locate();
{
+
    };
type: 'Feature',
+
}
"geometry": { "type": "Point", "coordinates": [19.063, 47.473]},
+
 
"properties": {
+
// Once we've got a position, zoom and center the map
"image": "http://photos.wikimapia.org/p/00/02/45/33/03_big.jpg",
+
// on it, and add a single marker.
"url": "https://www.elte.hu/",
+
map.on('locationfound', function(e) {
"marker-symbol": "star",
+
    map.fitBounds(e.bounds);
"marker-color": "#ff8888",
+
 
"marker-size": "large",
+
     myLayer.setGeoJSON({
"city": "Budapest - ELTE Lágymányos"
+
        type: 'Feature',
}
+
        geometry: {
}];
+
            type: 'Point',
 +
            coordinates: [e.latlng.lng, e.latlng.lat]
 +
        },
 +
        properties: {
 +
            'title': 'Here I am!',
 +
            'marker-color': '#ff8888',
 +
            'marker-symbol': 'star'
 +
        }
 +
    });
  
// Add custom popups to each using our custom feature properties
+
    // And hide the geolocation button
myLayer.on('layeradd', function(e) {
+
    geolocate.parentNode.removeChild(geolocate);
    var marker = e.layer,
+
});
        feature = marker.feature;
 
  
    // Create custom popup content
+
// If the user chooses not to allow their location
    var popupContent =  '<a target="_blank" class="popup" href="' + feature.properties.url + '">' +
+
// to be shared, display an error message.
                            '<img src="' + feature.properties.image + '" />' +
+
map.on('locationerror', function() {
                            feature.properties.city +
+
     geolocate.innerHTML = 'Position could not be found';
                        '</a>';
 
 
 
    // http://leafletjs.com/reference.html#popup
 
    marker.bindPopup(popupContent,{
 
        closeButton: false,
 
        minWidth: 480
 
     });
 
 
});
 
});
 
// Add features to the map
 
myLayer.setGeoJSON(geoJson);
 
 
</script>
 
</script>
 
</body>
 
</body>
1 152. sor: 1 336. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Jelölőhöz tartozó tipp megjelenítése egérrel ====
+
=== Útvonaltervezés (Autós, biciklis, gyalogos közlekedéssel) ===
  
[http://zsataai.web.elte.hu/content/mapbox/show_tooltips_on_hover.html Show tooltips on hover]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/directions.html Directions]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Show tooltips on hover -->
+
<!-- Directions -->
<!-- How to show marker popups on hover with Mapbox.js, our open source JavaScript library. -->
+
<!-- Use the mapbox-directions.js plugin to show results from the Mapbox Directions API -->
  
<!DOCTYPE html>
 
 
<html>
 
<html>
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Show tooltips on hover</title>
+
<title>Directions</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
1 177. sor: 1 360. sor:
 
</head>
 
</head>
 
<body>
 
<body>
<div id='map'></div>
+
<style>
 
+
#inputs,
<script>
+
#errors,
L.mapbox.accessToken = '<your access token here>';
+
#directions {
L.mapbox.accessToken = demoAccessToken;
+
    position: absolute;
var map = L.mapbox.map('map', 'mapbox.light')
+
    width: 33.3333%;
  .setView([47.47, 19.06], 15);
+
    max-width: 300px;
 +
    min-width: 200px;
 +
}
  
var myLayer = L.mapbox.featureLayer().addTo(map);
+
#inputs {
 +
    z-index: 10;
 +
    top: 10px;
 +
    left: 10px;
 +
}
  
var geojson = {
+
#directions {
     type: 'FeatureCollection',
+
     z-index: 99;
     features: [{
+
     background: rgba(0,0,0,.8);
        type: 'Feature',
+
     top: 0;
        properties: {
+
     right: 0;
            title: 'Bal alsó',
+
    bottom: 0;
            'marker-color': '#f86767',
+
    overflow: auto;
            'marker-size': 'small',
+
}
            'marker-symbol': 'star'
 
        },
 
        geometry: {
 
            type: 'Point',
 
            coordinates: [19.05, 47.46]
 
        }
 
     },
 
     {
 
        type: 'Feature',
 
        properties: {
 
            title: 'Jobb felső',
 
            'marker-color': '#7ec9b1',
 
            'marker-size': 'large',
 
            'marker-symbol': 'star'
 
        },
 
        geometry: {
 
            type: 'Point',
 
            coordinates: [19.07, 47.48]
 
        }
 
    }]
 
};
 
  
myLayer.setGeoJSON(geojson);
+
#errors {
myLayer.on('mouseover', function(e) {
+
    z-index: 8;
     e.layer.openPopup();
+
    opacity: 0;
});
+
     padding: 10px;
myLayer.on('mouseout', function(e) {
+
    border-radius: 0 0 3px 3px;
     e.layer.closePopup();
+
    background: rgba(0,0,0,.25);
});
+
     top: 90px;
</script>
+
    left: 10px;
</body>
+
}
</html>
 
</syntaxhighlight>
 
  
=== Helyek ===
+
</style>
  
==== Hely keresése automatikus kiegészítéssel ====
+
<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' />
  
[http://zsataai.web.elte.hu/content/mapbox/geocoding_with_autocomplete.html Geocoding with autocomplete]
+
<div id='map'></div>
 
+
<div id='inputs'></div>
<syntaxhighlight lang="html5">
+
<div id='errors'></div>
<!-- Geocoding with autocomplete -->
+
<div id='directions'>
<!-- Using the Mapbox Geocoding API to show real-time search suggestions. -->
+
   <div id='routes'></div>
 
+
  <div id='instructions'></div>
<!DOCTYPE html>
+
</div>
<html>
 
<head>
 
<meta charset=utf-8 />
 
<title>Geocoding with autocomplete</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>
 
<script>
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
L.mapbox.map('map', 'mapbox.streets')
+
var map = L.mapbox.map('map', 'mapbox.streets', {
     .addControl(L.mapbox.geocoderControl('mapbox.places', {
+
    zoomControl: false
        autocomplete: true
+
}).setView([47.47, 19.06], 15);
     }));
+
 
 +
// 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>
 
</script>
 
</body>
 
</body>
1 269. sor: 1 440. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Hely lekérdezése név alapján (Geocoderrel) ====
+
=== Plugin támogatás és a Mapbox ===
 +
 
 +
==== Leaflet-MiniMap ====
  
[http://zsataai.web.elte.hu/content/mapbox/use_geocoder_to_set_map_position.html Use geocoder to set map position]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/leaflet_minimap.html Leaflet-MiniMap]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Use geocoder to set map position -->
+
<!-- Leaflet-MiniMap -->
<!-- Using the Mapbox Geocoding API initially set map position on Chester, New Jersey. -->
+
<!-- Display a smaller navigable map using the Leaflet-MiniMap plugin. -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
1 281. sor: 1 454. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Use geocoder to set map position</title>
+
<title>Leaflet-MiniMap</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
1 294. sor: 1 467. sor:
 
</head>
 
</head>
 
<body>
 
<body>
 +
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-minimap/v1.0.0/Control.MiniMap.js'></script>
 +
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-minimap/v1.0.0/Control.MiniMap.css' rel='stylesheet' />
 +
 
<div id='map'></div>
 
<div id='map'></div>
 +
 
<script>
 
<script>
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
var geocoder = L.mapbox.geocoder('mapbox.places'),
+
var map = L.mapbox.map('map', 'mapbox.streets')
    map = L.mapbox.map('map', 'examples.map-h67hf2ic');
+
    .on('ready', function() {
 
+
        new L.Control.MiniMap(L.mapbox.tileLayer('mapbox.streets'))
geocoder.query('Tab, HU', showMap);
+
            .addTo(map);
 
+
     });
function showMap(err, data) {
 
    // The geocoder can return an area, like a city, or a
 
    // point, like an address. Here we handle both cases,
 
    // by fitting the map bounds to an area or zooming to a point.
 
    if (data.lbounds) {
 
        map.fitBounds(data.lbounds);
 
    } else if (data.latlng) {
 
        map.setView([data.latlng[0], data.latlng[1]], 13);
 
     }
 
}
 
 
</script>
 
</script>
 
</body>
 
</body>
1 318. sor: 1 485. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Aktuális pozíció megjelenítése (megközelítőleg) ====
+
==== Leaflet Fullscreen ====
  
[http://zsataai.web.elte.hu/content/mapbox/geolocation.html Geolocation]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/leaflet_fullscreen.html Leaflet Fullscreen]
 
 
FONTOS: A Geolocation, azaz helymeghatározás használatához valid HTTPS kapcsolat szükséges.
 
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Geolocation -->
+
<!-- Leaflet Fullscreen -->
<!-- Finding the user's position -->
+
<!-- Add a control to enable a map to be in full screen mode. -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
1 332. sor: 1 497. sor:
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Geolocation</title>
+
<title>Leaflet Fullscreen</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
1 345. sor: 1 510. sor:
 
</head>
 
</head>
 
<body>
 
<body>
<style>
+
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js'></script>
.ui-button {
+
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/leaflet.fullscreen.css' rel='stylesheet' />
  background:#3887BE;
+
 
  color:#FFF;
+
<div id='map'></div>
  display:block;
+
 
  position:absolute;
+
<script>
  top:50%;left:50%;
+
L.mapbox.accessToken = '<your access token here>';
  width:160px;
+
L.mapbox.accessToken = demoAccessToken;
  margin:-20px 0 0 -80px;
+
var map = L.mapbox.map('map', 'mapbox.streets')
  z-index:100;
+
    .setView([47.47, 19.06], 15);
  text-align:center;
+
 
  padding:10px;
+
L.control.fullscreen().addTo(map);
  border:1px solid rgba(0,0,0,0.4);
+
</script>
  border-radius:3px;
+
</body>
  }
+
</html>
  .ui-button:hover {
+
</syntaxhighlight>
    background:#3074a4;
 
    color:#fff;
 
    }
 
</style>
 
  
<div id='map'></div>
+
==== Leaflet Heat ====
<a href='#' id='geolocate' class='ui-button'>Find me</a>
 
  
<script>
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/leaflet_heat.html Leaflet Heat]
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
var geolocate = document.getElementById('geolocate');
 
var map = L.mapbox.map('map', 'mapbox.streets');
 
  
var myLayer = L.mapbox.featureLayer().addTo(map);
+
<syntaxhighlight lang="html5">
 +
<!-- Leaflet Heat -->
 +
<!-- Initially draw heatmap data on a map and allow a users mouse movement to draw their own. -->
  
// This uses the HTML5 geolocation API, which is available on
+
<!DOCTYPE html>
// most mobile browsers and modern browsers, but not in Internet Explorer
+
<html>
//
+
<head>
// See this chart of compatibility for details:
+
<meta charset=utf-8 />
// http://caniuse.com/#feat=geolocation
+
<title>Leaflet Heat</title>
if (!navigator.geolocation) {
+
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    geolocate.innerHTML = 'Geolocation is not available';
+
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
} else {
+
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
    geolocate.onclick = function (e) {
+
<style>
        e.preventDefault();
+
  body { margin:0; padding:0; }
        e.stopPropagation();
+
  #map { position:absolute; top:0; bottom:0; width:100%; }
        map.locate();
+
</style>
    };
+
<script>
}
+
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
 
+
</script>
// Once we've got a position, zoom and center the map
+
</head>
// on it, and add a single marker.
+
<body>
map.on('locationfound', function(e) {
+
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-heat/v0.1.3/leaflet-heat.js'></script>
    map.fitBounds(e.bounds);
+
<div id='map'></div>
  
    myLayer.setGeoJSON({
+
<!-- Example data. (near Hamilton, New Zealand)-->
        type: 'Feature',
+
<script src='./data/realworld.388.js'></script>
        geometry: {
 
            type: 'Point',
 
            coordinates: [e.latlng.lng, e.latlng.lat]
 
        },
 
        properties: {
 
            'title': 'Here I am!',
 
            'marker-color': '#ff8888',
 
            'marker-symbol': 'star'
 
        }
 
    });
 
  
    // And hide the geolocation button
+
<script>
     geolocate.parentNode.removeChild(geolocate);
+
L.mapbox.accessToken = '<your access token here>';
});
+
L.mapbox.accessToken = demoAccessToken;
 +
     var map = L.mapbox.map('map', 'mapbox.dark')
 +
        .setView([47.47, 19.06], 15);
  
// If the user chooses not to allow their location
+
    var heat = L.heatLayer(addressPoints, {maxZoom: 18}).addTo(map);
// to be shared, display an error message.
+
    var draw = false;
map.on('locationerror', function() {
+
 
    geolocate.innerHTML = 'Position could not be found';
+
    // add points on mouse move (except when interacting with the map)
});
+
    map.on({
 +
        click:  function () { draw = !draw; },
 +
        mousemove: function (e) {
 +
            if (draw) {
 +
                heat.addLatLng(e.latlng);
 +
            }
 +
        }
 +
    })
 
</script>
 
</script>
 
</body>
 
</body>
1 424. sor: 1 581. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Útvonaltervezés (Autós, biciklis, gyalogos közlekedéssel) ===
+
==== Leaflet Markercluster ====
  
[http://zsataai.web.elte.hu/content/mapbox/directions.html Directions]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/leaflet_markercluster.html Leaflet Markercluster]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Directions -->
+
<!-- Leaflet Markercluster -->
<!-- Use the mapbox-directions.js plugin to show results from the Mapbox Directions API -->
+
<!-- Using the Leaflet Markercluster plugin -->
  
 +
<!DOCTYPE html>
 
<html>
 
<html>
 
<head>
 
<head>
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Directions</title>
+
<title>Leaflet Markercluster</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
1 448. sor: 1 606. sor:
 
</head>
 
</head>
 
<body>
 
<body>
<style>
+
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/leaflet.markercluster.js'></script>
#inputs,
+
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/MarkerCluster.css' rel='stylesheet' />
#errors,
+
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/MarkerCluster.Default.css' rel='stylesheet' />
#directions {
 
    position: absolute;
 
    width: 33.3333%;
 
    max-width: 300px;
 
    min-width: 200px;
 
}
 
  
#inputs {
+
<!-- Example data. (near Hamilton, New Zealand)-->
    z-index: 10;
+
<script src="./data/realworld.388.js"></script>
    top: 10px;
 
    left: 10px;
 
}
 
  
#directions {
+
<div id='map'></div>
    z-index: 99;
 
    background: rgba(0,0,0,.8);
 
    top: 0;
 
    right: 0;
 
    bottom: 0;
 
    overflow: auto;
 
}
 
  
#errors {
+
<script>
    z-index: 8;
+
L.mapbox.accessToken = '<your access token here>';
    opacity: 0;
+
L.mapbox.accessToken = demoAccessToken;
     padding: 10px;
+
     var map = L.mapbox.map('map', 'mapbox.streets')
    border-radius: 0 0 3px 3px;
+
        .setView([-37.82, 175.215], 14);
    background: rgba(0,0,0,.25);
 
    top: 90px;
 
    left: 10px;
 
}
 
  
</style>
+
    var markers = new L.MarkerClusterGroup();
  
<script src='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.js'></script>
+
    for (var i = 0; i < addressPoints.length; i++) {
<link rel='stylesheet' href='https://api.mapbox.com/mapbox.js/plugins/mapbox-directions.js/v0.4.0/mapbox.directions.css' type='text/css' />
+
        var a = addressPoints[i];
 +
        var title = a[2];
 +
        var marker = L.marker(new L.LatLng(a[0], a[1]), {
 +
            icon: L.mapbox.marker.icon({'marker-symbol': 'post', 'marker-color': '0044FF'}),
 +
            title: title
 +
        });
 +
        marker.bindPopup(title);
 +
        markers.addLayer(marker);
 +
    }
  
<div id='map'></div>
+
    map.addLayer(markers);
<div id='inputs'></div>
+
</script>
<div id='errors'></div>
+
</body>
<div id='directions'>
+
</html>
  <div id='routes'></div>
+
</syntaxhighlight>
  <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([47.47, 19.06], 15);
 
  
// move the attribution control out of the way
+
==== Listing markers in clusters ====
map.attributionControl.setPosition('bottomleft');
 
  
// create the initial directions object, from which the layer
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/listing_markers_in_clusters.html Listing markers in clusters]
// and inputs will pull data.
 
var directions = L.mapbox.directions();
 
  
var directionsLayer = L.mapbox.directions.layer(directions)
+
<syntaxhighlight lang="html5">
    .addTo(map);
+
<!-- Listing markers in clusters -->
 +
<!-- Show a list of clustered markers by their coordinates on a map with Mapbox.js. -->
  
var directionsInputControl = L.mapbox.directions.inputControl('inputs', directions)
+
<!DOCTYPE html>
    .addTo(map);
+
<html>
 
+
<head>
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 ===
 
 
 
==== Leaflet-MiniMap ====
 
 
 
[http://zsataai.web.elte.hu/content/mapbox/leaflet_minimap.html Leaflet-MiniMap]
 
 
 
<syntaxhighlight lang="html5">
 
<!-- Leaflet-MiniMap -->
 
<!-- Display a smaller navigable map using the Leaflet-MiniMap plugin. -->
 
 
 
<!DOCTYPE html>
 
<html>
 
<head>
 
 
<meta charset=utf-8 />
 
<meta charset=utf-8 />
<title>Leaflet-MiniMap</title>
+
<title>Listing markers in clusters</title>
 
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 
<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>
 
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
1 555. sor: 1 665. sor:
 
</head>
 
</head>
 
<body>
 
<body>
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-minimap/v1.0.0/Control.MiniMap.js'></script>
+
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/leaflet.markercluster.js'></script>
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-minimap/v1.0.0/Control.MiniMap.css' rel='stylesheet' />
+
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/MarkerCluster.css' rel='stylesheet' />
 +
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/MarkerCluster.Default.css' rel='stylesheet' />
 +
 
 +
<style>
 +
pre.ui-coordinates {
 +
  background:rgba(0,0,0,0.5);
 +
  position:absolute;
 +
  bottom:10px;
 +
  left:10px;
 +
  padding:5px 10px;
 +
  color:#fff;
 +
  font-size:11px;
 +
  line-height:18px;
 +
  border-radius:3px;
 +
  max-height:240px;
 +
  overflow:auto;
 +
  width:100px;
 +
  }
 +
</style>
  
 
<div id='map'></div>
 
<div id='map'></div>
 +
<pre id='coordinates' class='ui-coordinates'></pre>
  
 +
<!-- Example data. (near Hamilton, New Zealand)-->
 +
<script src="./data/realworld.388.js"></script>
 
<script>
 
<script>
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
L.mapbox.accessToken = demoAccessToken;
 
var map = L.mapbox.map('map', 'mapbox.streets')
 
var map = L.mapbox.map('map', 'mapbox.streets')
     .on('ready', function() {
+
     .setView([-37.82, 175.215], 14);;
        new L.Control.MiniMap(L.mapbox.tileLayer('mapbox.streets'))
+
 
            .addTo(map);
+
var markers = new L.MarkerClusterGroup();
 +
 
 +
for (var i = 0; i < addressPoints.length; i++) {
 +
    var a = addressPoints[i];
 +
    var title = a[2];
 +
    var marker = L.marker(new L.LatLng(a[0], a[1]), {
 +
        icon: L.mapbox.marker.icon({'marker-symbol': 'post', 'marker-color': '0044FF'}),
 +
        title: title
 
     });
 
     });
</script>
+
    marker.bindPopup(title);
</body>
+
    markers.addLayer(marker);
</html>
+
}
</syntaxhighlight>
 
  
==== Leaflet Fullscreen ====
+
map.addLayer(markers);
  
[http://zsataai.web.elte.hu/content/mapbox/leaflet_fullscreen.html Leaflet Fullscreen]
+
function onmove() {
 
+
    // Get the map bounds - the top-left and bottom-right locations.
<syntaxhighlight lang="html5">
+
    var inBounds = [],
<!-- Leaflet Fullscreen -->
+
        bounds = map.getBounds();
<!-- Add a control to enable a map to be in full screen mode. -->
+
    markers.eachLayer(function(marker) {
 
+
        // For each marker, consider whether it is currently visible by comparing
<!DOCTYPE html>
+
        // with the current map bounds.
<html>
+
        if (bounds.contains(marker.getLatLng())) {
<head>
+
            inBounds.push(marker.options.title);
<meta charset=utf-8 />
+
        }
<title>Leaflet Fullscreen</title>
+
    });
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
+
    // Display a list of markers.
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
+
    document.getElementById('coordinates').innerHTML = inBounds.join('\n');
<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>
 
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js'></script>
 
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/leaflet.fullscreen.css' rel='stylesheet' />
 
  
<div id='map'></div>
+
map.on('move', onmove);
  
<script>
+
// call onmove off the bat so that the list is populated.
L.mapbox.accessToken = '<your access token here>';
+
// otherwise, there will be no markers listed until the map is moved.
L.mapbox.accessToken = demoAccessToken;
+
onmove();
var map = L.mapbox.map('map', 'mapbox.streets')
 
    .setView([47.47, 19.06], 15);
 
 
 
L.control.fullscreen().addTo(map);
 
 
</script>
 
</script>
 
</body>
 
</body>
1 615. sor: 1 737. sor:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Leaflet Heat ====
+
== Az újabb irányvonal: a Mapbox GL JS megvalósítása és működése a háttérben ==
  
[http://zsataai.web.elte.hu/content/mapbox/leaflet_heat.html Leaflet Heat]
+
Három alapvető működési egység és feladatkör különíthető el a Mapbox működésében. Ezek a következők:  
 +
* '''térkép'''
 +
* '''adat'''
 +
* '''elemzés'''
  
<syntaxhighlight lang="html5">
+
=== Térkép: Mapbox GL a rendereléshez ===
<!-- Leaflet Heat -->
+
 
<!-- Initially draw heatmap data on a map and allow a users mouse movement to draw their own. -->
+
A térkép megjelenítését a GPU végzi '''Mapbox GL''' segítségével. A legfontosabb jellemzői:
 +
* A régi raszteres adatokkal (png csempék) szemben, itt vektoros adatok (vektoros csempék) vannak.
 +
* A megjelenítéskor rugalmasan kezelhetőek a stílusok (style JSON segítségével).
 +
* Kliens oldali renderelés (Open/Web GL alapon).
 +
* Az adatok külön rétegek a térképen, nem képezik szerves és elválaszthatatlan részét.
  
<!DOCTYPE html>
+
[[Fájl:mapbox_mapboxgl_03.png|frame|center|alt=Mapbox GL|Mapbox GL]]
<html>
 
<head>
 
<meta charset=utf-8 />
 
<title>Leaflet Heat</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>
 
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-heat/v0.1.3/leaflet-heat.js'></script>
 
<div id='map'></div>
 
  
<!-- Example data. (near Hamilton, New Zealand)-->
+
Példa:
<script src='./data/realworld.388.js'></script>
+
<syntaxhighlight lang="html5">
 +
var map = new mapboxgl.Map({
 +
  container: 'map',
 +
  center: [47.47, 19.06],
 +
  zoom: 15,
 +
  style: style_object,
 +
  hash: true
 +
});
 +
</syntaxhighlight>
  
<script>
+
[https://www.mapbox.com/mapbox-gl-js/api Mapbox GL API dokumentáció]
L.mapbox.accessToken = '<your access token here>';
 
L.mapbox.accessToken = demoAccessToken;
 
    var map = L.mapbox.map('map', 'mapbox.dark')
 
        .setView([47.47, 19.06], 15);
 
  
    var heat = L.heatLayer(addressPoints, {maxZoom: 18}).addTo(map);
+
=== Adat: Vector Tile ===
    var draw = false;
 
  
    // add points on mouse move (except when interacting with the map)
+
A '''Vector Tile''' egy nyílt szabvány webes térképek adatainak kódolásához.
    map.on({
 
        click:  function () { draw = !draw; },
 
        mousemove: function (e) {
 
            if (draw) {
 
                heat.addLatLng(e.latlng);
 
            }
 
        }
 
    })
 
</script>
 
</body>
 
</html>
 
</syntaxhighlight>
 
  
==== Leaflet Markercluster ====
+
[[Fájl:mapbox_vectortile_01.png|frame|center|alt=Vector Tile ábrázolása|Vector Tile ábrázolása]]
  
[http://zsataai.web.elte.hu/content/mapbox/leaflet_markercluster.html Leaflet Markercluster]
+
[[Fájl:mapbox_vectortile_02.png|frame|center|alt=Vector Tile példa|Vector Tile példa]]
  
<syntaxhighlight lang="html5">
+
=== Elemzés: Turf.js ===
<!-- Leaflet Markercluster -->
 
<!-- Using the Leaflet Markercluster plugin -->
 
  
<!DOCTYPE html>
+
A térkép adatain elvégezhetünk különféle térinformatikai műveleteket és elemzéseket. Erre a célra szolgál a '''Turj.js''' nevű nyílt forráskódú JavaScript könyvtár, melyet a Mapbox is beépítetten használ.
<html>
+
Néhány ilyen térinformatikai művelet a Turf.js képességei közül:
<head>
+
* Méretarány, mérték, távolságmérés kezelése
<meta charset=utf-8 />
+
* Transzformáció (például: buffer terület, unió, metszet és különbség képzés)
<title>Leaflet Markercluster</title>
+
* Pontok, poligonok és multipoligonok kezelése
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
+
* Interpoláció
<script src='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.js'></script>
+
* Adat osztályozás
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
+
* Mértékegység konverzió
<style>
+
* Rácsok, hálózatok elemzése
  body { margin:0; padding:0; }
+
* Aggregációs és statisztikai függvények
  #map { position:absolute; top:0; bottom:0; width:100%; }
 
</style>
 
<script>
 
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
 
</script>
 
</head>
 
<body>
 
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/leaflet.markercluster.js'></script>
 
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/MarkerCluster.css' rel='stylesheet' />
 
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/MarkerCluster.Default.css' rel='stylesheet' />
 
  
<!-- Example data. (near Hamilton, New Zealand)-->
+
[[Fájl:mapbox_turf_03.png|frame|center|alt=Turf.js|Turf.js]]
<script src="./data/realworld.388.js"></script>
 
  
<div id='map'></div>
+
Példa:
 
+
<syntaxhighlight lang="html5">
<script>
+
var poly1 = {
L.mapbox.accessToken = '<your access token here>';
+
  "type": "Feature",
L.mapbox.accessToken = demoAccessToken;
+
  "properties": {
    var map = L.mapbox.map('map', 'mapbox.streets')
+
    "fill": "#0f0"
        .setView([-37.82, 175.215], 14);
+
  },
 
+
  "geometry": {
     var markers = new L.MarkerClusterGroup();
+
    "type": "Polygon",
 
+
    "coordinates": [[
     for (var i = 0; i < addressPoints.length; i++) {
+
      [-82.574787, 35.594087],
        var a = addressPoints[i];
+
      [-82.574787, 35.615581],
        var title = a[2];
+
      [-82.545261, 35.615581],
        var marker = L.marker(new L.LatLng(a[0], a[1]), {
+
      [-82.545261, 35.594087],
            icon: L.mapbox.marker.icon({'marker-symbol': 'post', 'marker-color': '0044FF'}),
+
      [-82.574787, 35.594087]
            title: title
+
     ]]
        });
+
  }
        marker.bindPopup(title);
+
};
        markers.addLayer(marker);
+
var poly2 = {
    }
+
  "type": "Feature",
 +
  "properties": {
 +
     "fill": "#00f"
 +
  },
 +
  "geometry": {
 +
    "type": "Polygon",
 +
    "coordinates": [[
 +
      [-82.560024, 35.585153],
 +
      [-82.560024, 35.602602],
 +
      [-82.52964, 35.602602],
 +
      [-82.52964, 35.585153],
 +
      [-82.560024, 35.585153]
 +
    ]]
 +
  }
 +
};
  
    map.addLayer(markers);
+
var union = turf.union(poly1, poly2);
</script>
 
</body>
 
</html>
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==== Listing markers in clusters ====
+
[http://turfjs.org/docs Turf.js API dokumentáció]
 +
 
 +
=== Komponensek közötti kapcsolat ===
 +
 
 +
A Mapbox, illetve annak webes Mapbox.js nevű megoldása, ezen különálló komponensek egyfajta "wrapper" megvalósítása az egyszerűbb és egységesebb kezelhetőség érdekében.
 +
 
 +
[[Fájl:mapbox_rendereles_01.png|frame|center|alt=Megjelenítés, renderelés|Megjelenítés, renderelés]]
 +
 
 +
[[Fájl:mapbox_elemzes_01.png|frame|center|alt=Elemzés, szűrés|Elemzés, szűrés]]
 +
 
 +
== Példák (Mapbox GL JS) ==
 +
 
 +
=== Minimális példa egy térkép megjelenítésére ===
  
[http://zsataai.web.elte.hu/content/mapbox/listing_markers_in_clusters.html Listing markers in clusters]
+
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/display_a_map.html Display a map]
  
 
<syntaxhighlight lang="html5">
 
<syntaxhighlight lang="html5">
<!-- Listing markers in clusters -->
+
<!-- Display a map -->
<!-- Show a list of clustered markers by their coordinates on a map with Mapbox.js. -->
+
<!-- Initialize a map in an HTML element with Mapbox GL JS. -->
  
 
<!DOCTYPE html>
 
<!DOCTYPE html>
 
<html>
 
<html>
 
<head>
 
<head>
<meta charset=utf-8 />
+
    <meta charset='utf-8' />
<title>Listing markers in clusters</title>
+
    <title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
+
    <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>
+
    <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.0.1/mapbox.css' rel='stylesheet' />
+
    <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.css' rel='stylesheet' />
<style>
+
    <style>
  body { margin:0; padding:0; }
+
        body { margin:0; padding:0; }
  #map { position:absolute; top:0; bottom:0; width:100%; }
+
        #map { position:absolute; top:0; bottom:0; width:100%; }
</style>
+
    </style>
<script>
+
<script>
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
+
var demoAccessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejh2N21nMzAxMmQzMnA5emRyN2lucW0ifQ.jSE-g2vsn48Ry928pqylcg' || 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4M29iazA2Z2gycXA4N2pmbDZmangifQ.-g_vE53SD2WrJ6tFX7QHmA';
 +
</script>
 +
</head>
 +
<body>
 +
 
 +
<div id='map'></div>
 +
<script>
 +
mapboxgl.accessToken = '<your access token here>';
 +
mapboxgl.accessToken = demoAccessToken;
 +
var map = new mapboxgl.Map({
 +
    container: 'map', // container id
 +
    style: 'mapbox://styles/mapbox/streets-v9', //stylesheet location
 +
    center: [19.06, 47.47], // starting position
 +
    zoom: 15 // starting zoom
 +
});
 
</script>
 
</script>
 +
 +
</body>
 +
</html>
 +
</syntaxhighlight>
 +
 +
=== Vector tile forrás hozzáadása a térképhez ===
 +
 +
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/add_a_vector_tile_source.html Add a vector tile source]
 +
 +
<syntaxhighlight lang="html5">
 +
<!-- Add a vector tile source -->
 +
<!-- Add a vector source to a map. -->
 +
 +
<!DOCTYPE html>
 +
<html>
 +
<head>
 +
    <meta charset='utf-8' />
 +
    <title></title>
 +
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 +
    <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.js'></script>
 +
    <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.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>
 
</head>
 
<body>
 
<body>
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/leaflet.markercluster.js'></script>
 
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/MarkerCluster.css' rel='stylesheet' />
 
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/MarkerCluster.Default.css' rel='stylesheet' />
 
  
<style>
+
<div id='map'></div>
pre.ui-coordinates {
+
<script>
  background:rgba(0,0,0,0.5);
+
mapboxgl.accessToken = '<your access token here>';
  position:absolute;
+
mapboxgl.accessToken = demoAccessToken;
  bottom:10px;
+
var map = new mapboxgl.Map({
  left:10px;
+
    container: 'map',
  padding:5px 10px;
+
    style: 'mapbox://styles/mapbox/light-v9',
  color:#fff;
+
    zoom: 15,
  font-size:11px;
+
    center: [19.06, 47.47]
  line-height:18px;
+
});
  border-radius:3px;
+
 
  max-height:240px;
+
map.on('load', function () {
  overflow:auto;
+
 
  width:100px;
+
    map.addLayer({
  }
+
        "id": "terrain-data",
</style>
+
        "type": "line",
 +
        "source": {
 +
            type: 'vector',
 +
            url: 'mapbox://mapbox.mapbox-terrain-v2'
 +
        },
 +
        "source-layer": "contour",
 +
        "layout": {
 +
            "line-join": "round",
 +
            "line-cap": "round"
 +
        },
 +
        "paint": {
 +
            "line-color": "#ff69b4",
 +
            "line-width": 1
 +
        }
 +
    });
 +
});
 +
</script>
 +
</body>
 +
</html>
 +
</syntaxhighlight>
 +
 
 +
=== Külső forrásból származó vector tile hozzáadása a térképhez ===
 +
 
 +
[http://gis.inf.elte.hu/giswiki/uploads/D9B9SN/add_a_third_party_vector_tile_source.html Add a third party vector tile source]
 +
 
 +
<syntaxhighlight lang="html5">
 +
<!-- Add a third party vector tile source -->
 +
<!-- Render a map using an external vector source of OpenStreetMap data provided by Mapzen. -->
 +
 
 +
<!DOCTYPE html>
 +
<html>
 +
<head>
 +
    <meta charset='utf-8' />
 +
    <title></title>
 +
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
 +
    <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.js'></script>
 +
    <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.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>
 
<div id='map'></div>
<pre id='coordinates' class='ui-coordinates'></pre>
 
 
<!-- Example data. (near Hamilton, New Zealand)-->
 
<script src="./data/realworld.388.js"></script>
 
 
<script>
 
<script>
L.mapbox.accessToken = '<your access token here>';
+
mapboxgl.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
+
mapboxgl.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets')
+
var simple = {
     .setView([-37.82, 175.215], 14);;
+
    "version": 8,
 +
    "sources": {
 +
        "osm": {
 +
            "type": "vector",
 +
            "tiles": ["https://tile.mapzen.com/mapzen/vector/v1/all/{z}/{x}/{y}.mvt?api_key=vector-tiles-LM25tq4"]
 +
        }
 +
    },
 +
     "layers": [
 +
        {
 +
            "id": "background",
 +
            "type": "background",
 +
            "paint": {
 +
                "background-color": "#41afa5"
 +
            }
 +
        }, {
 +
            "id": "water",
 +
            "type": "fill",
 +
            "source": "osm",
 +
            "source-layer": "water",
 +
            "filter": ["==", "$type", "Polygon"],
 +
            "paint": {
 +
                "fill-color": "#3887be"
 +
            }
 +
        }
 +
    ]
 +
};
  
var markers = new L.MarkerClusterGroup();
+
var map = new mapboxgl.Map({
 
+
     container: 'map',
for (var i = 0; i < addressPoints.length; i++) {
+
     style: simple,
     var a = addressPoints[i];
+
     zoom: 1,
     var title = a[2];
+
    center: [-14, 35]
     var marker = L.marker(new L.LatLng(a[0], a[1]), {
+
});
        icon: L.mapbox.marker.icon({'marker-symbol': 'post', 'marker-color': '0044FF'}),
 
        title: title
 
    });
 
    marker.bindPopup(title);
 
    markers.addLayer(marker);
 
}
 
  
map.addLayer(markers);
+
map.addControl(new mapboxgl.NavigationControl());
 
 
function onmove() {
 
    // Get the map bounds - the top-left and bottom-right locations.
 
    var inBounds = [],
 
        bounds = map.getBounds();
 
    markers.eachLayer(function(marker) {
 
        // For each marker, consider whether it is currently visible by comparing
 
        // with the current map bounds.
 
        if (bounds.contains(marker.getLatLng())) {
 
            inBounds.push(marker.options.title);
 
        }
 
    });
 
    // Display a list of markers.
 
    document.getElementById('coordinates').innerHTML = inBounds.join('\n');
 
}
 
 
 
map.on('move', onmove);
 
 
 
// call onmove off the bat so that the list is populated.
 
// otherwise, there will be no markers listed until the map is moved.
 
onmove();
 
 
</script>
 
</script>
 
</body>
 
</body>

A lap jelenlegi, 2017. május 28., 18:20-kori változata

Mapbox logo

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.

Tartalomjegyzék

Mapbox, mint cég

Történelem

A cég startupként indult 2010-ben, Washingtonban. Dolgozóinak száma 2017-re elérte a 180 főt (az első negyedév végére 199 fő). Főként dizájnerek, szoftver fejlesztők és térképészek. Mára több, mint 5000 üzleti és 200000 ingyenes ügyfelük és felhasználójuk van. 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. Hisznek az open-source fejlesztésekben, ezért jelenleg 440-nél is több publikus repójuk van a GitHubon.

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.

Külön tájékoztató oldal a logójukról és a nevükről

A cég precízen figyel a nevüket és logójukat érintő pontosságra. Épp ezért egy külön oldal hoztak létre ezek helyes használatáról. A szemléletesség kedvéért összeszedtek néhány korábban előjött, helytelen példát is.

A Mapbox tájékoztató oldala a helyes logó- és névhasználatról

Árazás

A Mapbox jelenleg háromféle csomagban nyújtja a termékeit és szolgáltatásait. Ezek épp úgy lefedik a kisebb igényű, hobbicélú felhasználókat, mint a komoly ipari igényű céges felhasználókat.

Csomagok összehasonlítása

Mapbox csomagok árazása
A Mapbox csomagok árazása

Fejlődéstörténet

A Mapbox a fejlődését tekintve az alábbiak szerint különíthető el részekre/modulokra/termékekre (időrendben felsorolva, illetve a legfontosabb tulajdonságaikkal):

Mivel a Mapbox.js és a Mapbox GL JS is JavaScript alapú megoldás, ezért fontos lehet a kettő közti átjárhatóság. Ez azt jelenti, hogy ugyan nem automatikusan, de manuálisan a régebbi Mapbox.js projektek átalakíthatóak az újabb Mapbox GL JS alapú működésre. Ehhez a konverzióhoz az alábbi link nyújt hivatalos segítséget:

Converting a project from Mapbox.js to Mapbox GL JS

Példák (Mapbox.js)

Térkép (kezdő szint)

Minimális példa egy térkép megjelenítésére

A simple map

<!-- 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

<!-- 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 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

<!-- 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

<!-- 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

<!-- 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

Egyszerű jelölő ikonnal

Marker without GeoJSON

<!-- Marker without GeoJSON -->
<!-- Use L.mapbox.marker.icon to create a simple marker without GeoJSON. -->
<!-- Icon examples: https://www.mapbox.com/maki-icons/ -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Marker without GeoJSON</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], 16);

// L.marker is a low-level marker constructor in Leaflet.
L.marker([47.47, 19.06], {
    icon: L.mapbox.marker.icon({
        'marker-size': 'large',
        'marker-symbol': 'roadblock',
        'marker-color': '#fa0'
    })
}).addTo(map);
L.marker([47.4725, 19.0625], {
    icon: L.mapbox.marker.icon({
        'marker-size': 'large',
        'marker-symbol': 'college',
        'marker-color': '64BA49'
    })
}).addTo(map);
</script>
</body>
</html>

Jelölő koordinátáinak megjelenítése

Display latitude and longitude on marker movement

<!-- Display latitude and longitude on marker movement -->
<!-- Drag the marker to a new location on a map to view it's coordinates. -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Display latitude and longitude on marker movement</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>
pre.ui-coordinates {
  position:absolute;
  bottom:10px;
  left:10px;
  padding:5px 10px;
  background:rgba(0,0,0,0.5);
  color:#fff;
  font-size:11px;
  line-height:18px;
  border-radius:3px;
  }
</style>
<div id='map'></div>
<pre id='coordinates' class='ui-coordinates'></pre>
<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets')
    .setView([0, 0], 3);

var coordinates = document.getElementById('coordinates');

var marker = L.marker([0, 0], {
    icon: L.mapbox.marker.icon({
      'marker-color': '#f86767'
    }),
    draggable: true
}).addTo(map);

// every time the marker is dragged, update the coordinates container
marker.on('dragend', ondragend);

// Set the initial marker coordinate on load.
ondragend();

function ondragend() {
    var m = marker.getLatLng();
    coordinates.innerHTML = 'Latitude: ' + m.lat + '<br />Longitude: ' + m.lng;
}
</script>
</body>
</html>

Jelölőtől való távolság

Distance between two markers

<!-- Distance between two markers -->
<!-- Calculate the distance between two points in meters using distanceTo. -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Distance between two markers</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>
pre.ui-distance {
  position:absolute;
  bottom:10px;
  left:10px;
  padding:5px 10px;
  background:rgba(0,0,0,0.5);
  color:#fff;
  font-size:11px;
  line-height:18px;
  border-radius:3px;
  }
</style>
<div id='map'></div>
<pre id='distance' class='ui-distance'>Click to place a marker</pre>

<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);

// Start with a fixed marker.
var fixedMarker = L.marker(new L.LatLng(47.4725, 19.0625), {
    icon: L.mapbox.marker.icon({
        'marker-color': 'ff8888'
    })
}).bindPopup('ELTE Déli tömb').addTo(map);

// Store the fixedMarker coordinates in a variable.
var fc = fixedMarker.getLatLng();

// Create a featureLayer that will hold a marker and linestring.
var featureLayer = L.mapbox.featureLayer().addTo(map);

// When a user clicks on the map we want to
// create a new L.featureGroup that will contain a
// marker placed where the user selected the map and
// a linestring that draws itself between the fixedMarkers
// coordinates and the newly placed marker.
map.on('click', function(ev) {
    // ev.latlng gives us the coordinates of
    // the spot clicked on the map.
    var c = ev.latlng;

    var geojson = {
      type: 'FeatureCollection',
      features: [
        {
          "type": "Feature",
          "geometry": {
            "type": "Point",
            "coordinates": [c.lng, c.lat]
          },
          "properties": {
            "marker-color": "#ff8888"
          }
        }, {
          "type": "Feature",
          "geometry": {
            "type": "LineString",
            "coordinates": [
              [fc.lng, fc.lat],
              [c.lng, c.lat]
            ]
          },
          "properties": {
            "stroke": "#000",
            "stroke-opacity": 0.5,
            "stroke-width": 4
          }
        }
      ]
    };

    featureLayer.setGeoJSON(geojson);

    // Finally, print the distance between these two points
    // on the screen using distanceTo().
    var container = document.getElementById('distance');
    container.innerHTML = (fc.distanceTo(c)).toFixed(0) + 'm';
});
</script>
</body>
</html>

Navigáció jelölőket tartalmazó menüvel

Marker navigation from a marker menu

<!-- Marker navigation from a marker menu -->
<!-- Zoom to a marker and open its tooltip when a marker menu in a list is selected. -->
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Marker navigation from a marker menu</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>
  .info {
    background:#fff;
    position:absolute;
    width:260px;
    top:10px;
    right:10px;
    border-radius:2px;
    }
    .info .item {
      display:block;
      border-bottom:1px solid #eee;
      padding:10px;
      text-decoration:none;
      }
      .info .item small { color:#888; }
      .info .item:hover,
      .info .item.active { background:#f8f8f8; }
      .info .item:last-child { border-bottom:none; }
</style>

<div id='map' class='map'></div>
<div id='info' class='info'></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);

var myLayer = L.mapbox.featureLayer().addTo(map);

myLayer.setGeoJSON({
  type: 'FeatureCollection',
  features: [
    {
      type: 'Feature',
      geometry: {
          type: 'Point',
          coordinates: [19.0625, 47.4725]
      },
      properties: {
          title: 'ELTE Déli tömb',
          description: 'ELTE IK',
          'marker-id': 'marker-1',
          'marker-color': '#f86767'
      }
    },
    {
          type: 'Feature',
          geometry: {
              type: 'Point',
              coordinates: [19.0625, 47.4745]
          },
          properties: {
              title: 'ELTE Északi tömb',
              description: 'ELTE TTK',
              'marker-id': 'marker-2',
              'marker-color': '#f86767'
          }
      },
		{
		  type: 'Feature',
		  geometry: {
			  type: 'Point',
			  coordinates: [19.063425, 47.505258]
		  },
		  properties: {
			  title: 'Oktogon',
			  description: 'Oktogon metró állomás',
			  'marker-id': 'marker-2',
			  'marker-color': '#f86767',
			  'marker-symbol': 'rail-metro'
		  }
		}
  ]
});

var info = document.getElementById('info');

// Iterate through each feature layer item, build a
// marker menu item and enable a click event that pans to + opens
// a marker that's associated to the marker item.
myLayer.eachLayer(function(marker) {
  var link = info.appendChild(document.createElement('a'));
  link.className = 'item';
  link.href = '#';

  // Populate content from each markers object.
  link.innerHTML = marker.feature.properties.title +
    '<br /><small>' + marker.feature.properties.description + '</small>';
  link.onclick = function() {
    if (/active/.test(this.className)) {
      this.className = this.className.replace(/active/, '').replace(/\s\s*$/, '');
    } else {
      var siblings = info.getElementsByTagName('a');
      for (var i = 0; i < siblings.length; i++) {
        siblings[i].className = siblings[i].className
          .replace(/active/, '').replace(/\s\s*$/, '');
      };
      this.className += ' active';

      // When a menu item is clicked, animate the map to center
      // its associated marker and open its popup.
      map.panTo(marker.getLatLng());
      marker.openPopup();
    }
    return false;
  };
});
</script>
</body>
</html>

Csak a környező jelölők megjelenítése

Marker radius search

<!-- Marker radius search -->
<!-- Use the .distanceTo function to only show markers within a range -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Marker radius search</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>
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-omnivore/v0.2.0/leaflet-omnivore.min.js'></script>
<div id='map'></div>

<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.emerald')
    .setView([40, -95], 4);

var RADIUS = 500000;
var filterCircle = L.circle(L.latLng(40, -75), RADIUS, {
    opacity: 1,
    weight: 1,
    fillOpacity: 0.4
}).addTo(map);

var csvLayer = omnivore.csv('./data/airports.csv', null, L.mapbox.featureLayer())
    .addTo(map);

map.on('mousemove', function(e) {
    filterCircle.setLatLng(e.latlng);
    csvLayer.setFilter(function showAirport(feature) {
        return e.latlng.distanceTo(L.latLng(
                feature.geometry.coordinates[1],
                feature.geometry.coordinates[0])) < RADIUS;
    });
});
</script>
</body>
</html>

Jelölő mozgatása programozottan

Marker movement

<!-- Marker movement -->
<!-- Simple marker animation. -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Marker movement</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.light')
  .setView([0, 0], 3);

var marker = L.marker([0, 0], {
    icon: L.mapbox.marker.icon({
      'marker-color': '#f86767'
    })
});

var t = 0;
window.setInterval(function() {
    // Making a lissajous curve just for fun.
    // Create your own animated path here.
    marker.setLatLng(L.latLng(
        Math.cos(t * 0.5) * 10,
        Math.sin(t) * 10));
    t += 0.01; // Movement
}, 1); // Speed

marker.addTo(map);
</script>
</body>
</html>

Jelölő animálása geoJson vonalon

Animate a marker along line

<!-- Animate a marker along line -->
<!-- Create a marker and animate its position along the length of a line by looking up its coordinates. -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Animate a marker along line</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([0, 0], 3);

// Generate a GeoJSON line. You could also load GeoJSON via AJAX
// or generate it some other way.
var geojson = { type: 'LineString', coordinates: [] };
var start = [0, 0];
var momentum = [2, 2];

for (var i = 0; i < 1000; i++) {
    start[0] += momentum[0];
    start[1] += momentum[1];
    if (start[1] > 30 || start[1] < -30) momentum[1] *= -1;
    if (start[0] > 90 || start[0] < -90) momentum[0] *= -1;
    geojson.coordinates.push(start.slice());
}

// Add this generated geojson object to the map.
L.geoJson(geojson).addTo(map);

// Create a counter with a value of 0.
var j = 0;

// Create a marker and add it to the map.
var marker = L.marker([0, 0], {
  icon: L.mapbox.marker.icon({
    'marker-color': '#f86767'
  })
}).addTo(map);

tick();
function tick() {
    // Set the marker to be at the same point as one
    // of the segments or the line.
    marker.setLatLng(L.latLng(
        geojson.coordinates[j][1],
        geojson.coordinates[j][0]));

    // Move to the next point of the line
    // until `j` reaches the length of the array.
    if (++j < geojson.coordinates.length) setTimeout(tick, 20);
}
</script>
</body>
</html>

Tippek, üzenetek, szövegek

Egyedi jelölő tipp

Custom marker tooltips

<!-- Custom marker tooltips -->
<!-- How to create a custom marker tooltip with style text or images using Mapbox.js, our open source JavaScript library. -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Custom marker tooltips</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>
.leaflet-popup-content img {
  max-width:100%;
  }
</style>
<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);

var myLayer = L.mapbox.featureLayer().addTo(map);

var geoJson = [{
    type: 'Feature',
    "geometry": { "type": "Point", "coordinates": [19.06, 47.47]},
    "properties": {
        "image": "http://hazai.kozep.bme.hu/wp-content/uploads/2013/06/00-Info-E-nyit%C3%B3.jpg",
        "url": "http://www.infopark.hu/",
        "marker-symbol": "star",
        "marker-color": "#ff8888",
        "marker-size": "large",
        "city": "Budapest - Infopark"
    }
	},
	{
		type: 'Feature',
		"geometry": { "type": "Point", "coordinates": [19.063, 47.473]},
		"properties": {
			"image": "http://photos.wikimapia.org/p/00/02/45/33/03_big.jpg",
			"url": "https://www.elte.hu/",
			"marker-symbol": "star",
			"marker-color": "#ff8888",
			"marker-size": "large",
			"city": "Budapest - ELTE Lágymányos"
		}
}];

// Add custom popups to each using our custom feature properties
myLayer.on('layeradd', function(e) {
    var marker = e.layer,
        feature = marker.feature;

    // Create custom popup content
    var popupContent =  '<a target="_blank" class="popup" href="' + feature.properties.url + '">' +
                            '<img src="' + feature.properties.image + '" />' +
                            feature.properties.city +
                        '</a>';

    // http://leafletjs.com/reference.html#popup
    marker.bindPopup(popupContent,{
        closeButton: false,
        minWidth: 480
    });
});

// Add features to the map
myLayer.setGeoJSON(geoJson);
</script>
</body>
</html>

Jelölőhöz tartozó tipp megjelenítése egérrel

Show tooltips on hover

<!-- Show tooltips on hover -->
<!-- How to show marker popups on hover with Mapbox.js, our open source JavaScript library. -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Show tooltips on hover</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.light')
  .setView([47.47, 19.06], 15);

var myLayer = L.mapbox.featureLayer().addTo(map);

var geojson = {
    type: 'FeatureCollection',
    features: [{
        type: 'Feature',
        properties: {
            title: 'Bal alsó',
            'marker-color': '#f86767',
            'marker-size': 'small',
            'marker-symbol': 'star'
        },
        geometry: {
            type: 'Point',
            coordinates: [19.05, 47.46]
        }
    },
    {
        type: 'Feature',
        properties: {
            title: 'Jobb felső',
            'marker-color': '#7ec9b1',
            'marker-size': 'large',
            'marker-symbol': 'star'
        },
        geometry: {
            type: 'Point',
            coordinates: [19.07, 47.48]
        }
    }]
};

myLayer.setGeoJSON(geojson);
myLayer.on('mouseover', function(e) {
    e.layer.openPopup();
});
myLayer.on('mouseout', function(e) {
    e.layer.closePopup();
});
</script>
</body>
</html>

Helyek

Hely keresése automatikus kiegészítéssel

Geocoding with autocomplete

<!-- Geocoding with autocomplete -->
<!-- Using the Mapbox Geocoding API to show real-time search suggestions. -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Geocoding with autocomplete</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;
L.mapbox.map('map', 'mapbox.streets')
    .addControl(L.mapbox.geocoderControl('mapbox.places', {
        autocomplete: true
    }));
</script>
</body>
</html>

Hely lekérdezése név alapján (Geocoderrel)

Use geocoder to set map position

<!-- Use geocoder to set map position -->
<!-- Using the Mapbox Geocoding API initially set map position on Chester, New Jersey. -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Use geocoder to set map position</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 geocoder = L.mapbox.geocoder('mapbox.places'),
    map = L.mapbox.map('map', 'examples.map-h67hf2ic');

geocoder.query('Tab, HU', showMap);

function showMap(err, data) {
    // The geocoder can return an area, like a city, or a
    // point, like an address. Here we handle both cases,
    // by fitting the map bounds to an area or zooming to a point.
    if (data.lbounds) {
        map.fitBounds(data.lbounds);
    } else if (data.latlng) {
        map.setView([data.latlng[0], data.latlng[1]], 13);
    }
}
</script>
</body>
</html>

Aktuális pozíció megjelenítése (megközelítőleg)

Geolocation

FONTOS: A Geolocation, azaz helymeghatározás használatához valid HTTPS kapcsolat szükséges.

<!-- Geolocation -->
<!-- Finding the user's position -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Geolocation</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>
.ui-button {
  background:#3887BE;
  color:#FFF;
  display:block;
  position:absolute;
  top:50%;left:50%;
  width:160px;
  margin:-20px 0 0 -80px;
  z-index:100;
  text-align:center;
  padding:10px;
  border:1px solid rgba(0,0,0,0.4);
  border-radius:3px;
  }
  .ui-button:hover {
    background:#3074a4;
    color:#fff;
    }
</style>

<div id='map'></div>
<a href='#' id='geolocate' class='ui-button'>Find me</a>

<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var geolocate = document.getElementById('geolocate');
var map = L.mapbox.map('map', 'mapbox.streets');

var myLayer = L.mapbox.featureLayer().addTo(map);

// This uses the HTML5 geolocation API, which is available on
// most mobile browsers and modern browsers, but not in Internet Explorer
//
// See this chart of compatibility for details:
// http://caniuse.com/#feat=geolocation
if (!navigator.geolocation) {
    geolocate.innerHTML = 'Geolocation is not available';
} else {
    geolocate.onclick = function (e) {
        e.preventDefault();
        e.stopPropagation();
        map.locate();
    };
}

// Once we've got a position, zoom and center the map
// on it, and add a single marker.
map.on('locationfound', function(e) {
    map.fitBounds(e.bounds);

    myLayer.setGeoJSON({
        type: 'Feature',
        geometry: {
            type: 'Point',
            coordinates: [e.latlng.lng, e.latlng.lat]
        },
        properties: {
            'title': 'Here I am!',
            'marker-color': '#ff8888',
            'marker-symbol': 'star'
        }
    });

    // And hide the geolocation button
    geolocate.parentNode.removeChild(geolocate);
});

// If the user chooses not to allow their location
// to be shared, display an error message.
map.on('locationerror', function() {
    geolocate.innerHTML = 'Position could not be found';
});
</script>
</body>
</html>

Útvonaltervezés (Autós, biciklis, gyalogos közlekedéssel)

Directions

<!-- Directions -->
<!-- Use the mapbox-directions.js plugin to show results from the Mapbox Directions API -->

<html>
<head>
<meta charset=utf-8 />
<title>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([47.47, 19.06], 15);

// 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>

Plugin támogatás és a Mapbox

Leaflet-MiniMap

Leaflet-MiniMap

<!-- Leaflet-MiniMap -->
<!-- Display a smaller navigable map using the Leaflet-MiniMap plugin. -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Leaflet-MiniMap</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>
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-minimap/v1.0.0/Control.MiniMap.js'></script>
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-minimap/v1.0.0/Control.MiniMap.css' rel='stylesheet' />

<div id='map'></div>

<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets')
    .on('ready', function() {
        new L.Control.MiniMap(L.mapbox.tileLayer('mapbox.streets'))
            .addTo(map);
    });
</script>
</body>
</html>

Leaflet Fullscreen

Leaflet Fullscreen

<!-- Leaflet Fullscreen -->
<!-- Add a control to enable a map to be in full screen mode. -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Leaflet Fullscreen</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>
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js'></script>
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/leaflet.fullscreen.css' rel='stylesheet' />

<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);

L.control.fullscreen().addTo(map);
</script>
</body>
</html>

Leaflet Heat

Leaflet Heat

<!-- Leaflet Heat -->
<!-- Initially draw heatmap data on a map and allow a users mouse movement to draw their own. -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Leaflet Heat</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>
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-heat/v0.1.3/leaflet-heat.js'></script>
<div id='map'></div>

<!-- Example data. (near Hamilton, New Zealand)-->
<script src='./data/realworld.388.js'></script>

<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
    var map = L.mapbox.map('map', 'mapbox.dark')
        .setView([47.47, 19.06], 15);

    var heat = L.heatLayer(addressPoints, {maxZoom: 18}).addTo(map);
    var draw = false;

    // add points on mouse move (except when interacting with the map)
    map.on({
        click:   function () { draw = !draw; },
        mousemove: function (e) {
            if (draw) {
                heat.addLatLng(e.latlng);
            }
        }
    })
</script>
</body>
</html>

Leaflet Markercluster

Leaflet Markercluster

<!-- Leaflet Markercluster -->
<!-- Using the Leaflet Markercluster plugin -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Leaflet Markercluster</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>
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/leaflet.markercluster.js'></script>
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/MarkerCluster.css' rel='stylesheet' />
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/MarkerCluster.Default.css' rel='stylesheet' />

<!-- Example data. (near Hamilton, New Zealand)-->
<script src="./data/realworld.388.js"></script>

<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([-37.82, 175.215], 14);

    var markers = new L.MarkerClusterGroup();

    for (var i = 0; i < addressPoints.length; i++) {
        var a = addressPoints[i];
        var title = a[2];
        var marker = L.marker(new L.LatLng(a[0], a[1]), {
            icon: L.mapbox.marker.icon({'marker-symbol': 'post', 'marker-color': '0044FF'}),
            title: title
        });
        marker.bindPopup(title);
        markers.addLayer(marker);
    }

    map.addLayer(markers);
</script>
</body>
</html>

Listing markers in clusters

Listing markers in clusters

<!-- Listing markers in clusters -->
<!-- Show a list of clustered markers by their coordinates on a map with Mapbox.js. -->

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Listing markers in clusters</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>
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/leaflet.markercluster.js'></script>
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/MarkerCluster.css' rel='stylesheet' />
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-markercluster/v1.0.0/MarkerCluster.Default.css' rel='stylesheet' />

<style>
pre.ui-coordinates {
  background:rgba(0,0,0,0.5);
  position:absolute;
  bottom:10px;
  left:10px;
  padding:5px 10px;
  color:#fff;
  font-size:11px;
  line-height:18px;
  border-radius:3px;
  max-height:240px;
  overflow:auto;
  width:100px;
  }
</style>

<div id='map'></div>
<pre id='coordinates' class='ui-coordinates'></pre>

<!-- Example data. (near Hamilton, New Zealand)-->
<script src="./data/realworld.388.js"></script>
<script>
L.mapbox.accessToken = '<your access token here>';
L.mapbox.accessToken = demoAccessToken;
var map = L.mapbox.map('map', 'mapbox.streets')
    .setView([-37.82, 175.215], 14);;

var markers = new L.MarkerClusterGroup();

for (var i = 0; i < addressPoints.length; i++) {
    var a = addressPoints[i];
    var title = a[2];
    var marker = L.marker(new L.LatLng(a[0], a[1]), {
        icon: L.mapbox.marker.icon({'marker-symbol': 'post', 'marker-color': '0044FF'}),
        title: title
    });
    marker.bindPopup(title);
    markers.addLayer(marker);
}

map.addLayer(markers);

function onmove() {
    // Get the map bounds - the top-left and bottom-right locations.
    var inBounds = [],
        bounds = map.getBounds();
    markers.eachLayer(function(marker) {
        // For each marker, consider whether it is currently visible by comparing
        // with the current map bounds.
        if (bounds.contains(marker.getLatLng())) {
            inBounds.push(marker.options.title);
        }
    });
    // Display a list of markers.
    document.getElementById('coordinates').innerHTML = inBounds.join('\n');
}

map.on('move', onmove);

// call onmove off the bat so that the list is populated.
// otherwise, there will be no markers listed until the map is moved.
onmove();
</script>
</body>
</html>

Az újabb irányvonal: a Mapbox GL JS megvalósítása és működése a háttérben

Három alapvető működési egység és feladatkör különíthető el a Mapbox működésében. Ezek a következők:

  • térkép
  • adat
  • elemzés

Térkép: Mapbox GL a rendereléshez

A térkép megjelenítését a GPU végzi Mapbox GL segítségével. A legfontosabb jellemzői:

  • A régi raszteres adatokkal (png csempék) szemben, itt vektoros adatok (vektoros csempék) vannak.
  • A megjelenítéskor rugalmasan kezelhetőek a stílusok (style JSON segítségével).
  • Kliens oldali renderelés (Open/Web GL alapon).
  • Az adatok külön rétegek a térképen, nem képezik szerves és elválaszthatatlan részét.
Mapbox GL
Mapbox GL

Példa:

var map = new mapboxgl.Map({
  container: 'map',
  center: [47.47, 19.06],
  zoom: 15,
  style: style_object,
  hash: true
});

Mapbox GL API dokumentáció

Adat: Vector Tile

A Vector Tile egy nyílt szabvány webes térképek adatainak kódolásához.

Vector Tile ábrázolása
Vector Tile ábrázolása
Vector Tile példa
Vector Tile példa

Elemzés: Turf.js

A térkép adatain elvégezhetünk különféle térinformatikai műveleteket és elemzéseket. Erre a célra szolgál a Turj.js nevű nyílt forráskódú JavaScript könyvtár, melyet a Mapbox is beépítetten használ. Néhány ilyen térinformatikai művelet a Turf.js képességei közül:

  • Méretarány, mérték, távolságmérés kezelése
  • Transzformáció (például: buffer terület, unió, metszet és különbség képzés)
  • Pontok, poligonok és multipoligonok kezelése
  • Interpoláció
  • Adat osztályozás
  • Mértékegység konverzió
  • Rácsok, hálózatok elemzése
  • Aggregációs és statisztikai függvények
Turf.js
Turf.js

Példa:

var poly1 = {
  "type": "Feature",
  "properties": {
    "fill": "#0f0"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-82.574787, 35.594087],
      [-82.574787, 35.615581],
      [-82.545261, 35.615581],
      [-82.545261, 35.594087],
      [-82.574787, 35.594087]
    ]]
  }
};
var poly2 = {
  "type": "Feature",
  "properties": {
    "fill": "#00f"
  },
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-82.560024, 35.585153],
      [-82.560024, 35.602602],
      [-82.52964, 35.602602],
      [-82.52964, 35.585153],
      [-82.560024, 35.585153]
    ]]
  }
};

var union = turf.union(poly1, poly2);

Turf.js API dokumentáció

Komponensek közötti kapcsolat

A Mapbox, illetve annak webes Mapbox.js nevű megoldása, ezen különálló komponensek egyfajta "wrapper" megvalósítása az egyszerűbb és egységesebb kezelhetőség érdekében.

Megjelenítés, renderelés
Megjelenítés, renderelés
Elemzés, szűrés
Elemzés, szűrés

Példák (Mapbox GL JS)

Minimális példa egy térkép megjelenítésére

Display a map

<!-- Display a map -->
<!-- Initialize a map in an HTML element with Mapbox GL JS. -->

<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8' />
    <title></title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.js'></script>
    <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.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>
mapboxgl.accessToken = '<your access token here>';
mapboxgl.accessToken = demoAccessToken;
var map = new mapboxgl.Map({
    container: 'map', // container id
    style: 'mapbox://styles/mapbox/streets-v9', //stylesheet location
    center: [19.06, 47.47], // starting position
    zoom: 15 // starting zoom
});
</script>

</body>
</html>

Vector tile forrás hozzáadása a térképhez

Add a vector tile source

<!-- Add a vector tile source -->
<!-- Add a vector source to a map. -->

<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8' />
    <title></title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.js'></script>
    <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.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>
mapboxgl.accessToken = '<your access token here>';
mapboxgl.accessToken = demoAccessToken;
var map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/light-v9',
    zoom: 15,
    center: [19.06, 47.47]
});

map.on('load', function () {

    map.addLayer({
        "id": "terrain-data",
        "type": "line",
        "source": {
            type: 'vector',
            url: 'mapbox://mapbox.mapbox-terrain-v2'
        },
        "source-layer": "contour",
        "layout": {
            "line-join": "round",
            "line-cap": "round"
        },
        "paint": {
            "line-color": "#ff69b4",
            "line-width": 1
        }
    });
});
</script>
</body>
</html>

Külső forrásból származó vector tile hozzáadása a térképhez

Add a third party vector tile source

<!-- Add a third party vector tile source -->
<!-- Render a map using an external vector source of OpenStreetMap data provided by Mapzen. -->

<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8' />
    <title></title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.js'></script>
    <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.37.0/mapbox-gl.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>
mapboxgl.accessToken = '<your access token here>';
mapboxgl.accessToken = demoAccessToken;
var simple = {
    "version": 8,
    "sources": {
        "osm": {
            "type": "vector",
            "tiles": ["https://tile.mapzen.com/mapzen/vector/v1/all/{z}/{x}/{y}.mvt?api_key=vector-tiles-LM25tq4"]
        }
    },
    "layers": [
        {
            "id": "background",
            "type": "background",
            "paint": {
                "background-color": "#41afa5"
            }
        }, {
            "id": "water",
            "type": "fill",
            "source": "osm",
            "source-layer": "water",
            "filter": ["==", "$type", "Polygon"],
            "paint": {
                "fill-color": "#3887be"
            }
        }
    ]
};

var map = new mapboxgl.Map({
    container: 'map',
    style: simple,
    zoom: 1,
    center: [-14, 35]
});

map.addControl(new mapboxgl.NavigationControl());
</script>
</body>
</html>

Felhasználás, alkalmazás

A Foursquare is Mapbox-ra váltott

A Foursquare 2012-ben lecserélte a Google térképszolgáltatására épülő webes felületét egy Mapbox alapú verzióra. Ezzel az újítással a felhasználók már egy színesebb, több információt tartalmazó térképpel találkozhatnak a Foursquare weboldalán. Mindezzel együtt a térképes adatok, képek szolgáltatását sem a Google Maps biztosítja, hanem a szintén népszerű OpenStreetMap. Az OpenStreetMap térképei a világ legtöbb pontján, így Magyarországon is nagyon pontosak és részletesek, és mivel nyílt rendszerről van szó, semmi sem akadályozza a folyamatos fejlődést.

Mapbox és WordPress: látványos térképek WordPress oldalon kódolás nélkül

Hivatalos bővítmény

Hivatalos bővítmény

Elavult verziójú, feltehetően nem fejlesztik tovább.

Harmadik féltől származó bővítmény

Mapbox for Wordpress Advanced

Harmadik féltől származó bővítmény

A Mapbox for Wordpress Advanced nevű WordPress bővítménnyel egyszerűen lehet térképeket hozzáadni egy WordPress oldalhoz. Ehhez nem kell mást tenni, mint letölteni a bővítményt az alábbi linken:

Mapbox for Wordpress Advanded letöltése

Majd a bővítményt feltölteni az adott WordPress oldalra és aktiválni. Ezután egy meglévő Mapbox felhasználói fiókon keresztül Mapbox Studio Classic használatával elkészíthető a kívánt térkép. Végül az elkészített térképhez tartozó Access Token-t és térkép ID-t meg kell adni a Mapbox for Wordpress Advanced bővítménynek.

Mapbox működés közben egy WordPress oldalon

További érdekességek

Térkép a Twitter első 6 milliárd geotaggel ellátott fotója alapján

Egy speciális világatlaszt készített a nagyvárosokról Eric Fischer, a Mapbox fejlesztője, aki a Twitter indulása óta megosztott összes geotaggel, vagyis földrajzi koordinátákkal ellátott több mint 6 milliárd bejegyzést használta fel hozzá. Első körben azt vizsgálta, hogy melyek azon régiók, kerületek, ahol a legsűrűbben fotóznak.

Twitteres geotaggel ellátott fotók térképe

Locals and Tourists - Budapest

A projektet továbbgondolva Fischer megkülönböztette a képeket készítő helybelieket a turistáktól. Így létrejött a Locals and Tourists nevű projektje, melynek keretében már azt is elkülönítette, hogy a képeket helybeliek vagy turisták készíthették.

Kék a helyi lakos, piros a turista Fischer azokat a személyeket számolta helyi lakosnak, aki egy hónapnál hosszabb ideje készít földrajzi címkékkel rendelkező fotókat egy adott térségben: őket jelölte kék színnel. A pirossal kiemelt turista kategóriába azok tartoznak, akik egy hónapnál kevesebb ideig készítettek és osztottak meg egy helyszínről képeket. A sárga pontok alatt azokat kell érteni, akiknél mindez nem volt egyértelműen meghatározható.

Budapest térképrészletére tekintve a legnépszerűbb turistacélpontok között a Hősök tere, a Városliget, a Lánchíd, és a Gellért-hegy is jól látható.

Átdolgozott, teljesértékű interaktív világtérképre bővített verzió:

Twitter Locals and Tourists project

Források