code:css
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" /> </head> <body> <div id="map" style="width: 600px; height: 400px"></div> <script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"/> <script> var map = L.map('map').setView([30, 118], 4); L.tileLayer('http://{s}.mapabc.com/mapabc/maptile?&x={x}&y={y}&z={z}', { subdomains: ["emap1", "emap2", "emap3"] }).addTo(map); </script> </body> </html>
簡單介紹:html
L.map是在頁面上建立地圖並操控它的只要方法。dom
L.map('map').setView([30, 118], 4)
其形式至關於:L.map( <HTMLElement|String> *id*, <Map options> *options*? )
L.tileLayer用於在地圖中加載瓦片(示例加載mapabc的瓦片)。url
L.tileLayer('http://{s}.mapabc.com/mapabc/maptile?&x={x}&y={y}&z={z}', { subdomains: ["emap1", "emap2", "emap3"] }).addTo(map)
其形式至關於:L.tileLayer( <String> *urlTemplate*, <TileLayer options> *options*? )
Demo:http://jsfiddle.net/shitao1988/KDr4B/