1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
| var map = L.map('map', { zoomSnap: 0.1, maxZoom: 18, zoomControl: true, editable: true, }).setView([26.078799594917704, 119.29471468823111], 14);
let baseLayer = L.tileLayer("http://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}", { attribution: '© 高德地图', maxZoom: 18, minZoom: 3, subdomains: "1234", zoom: 3 }); map.addLayer(baseLayer);
map.on('click', function (event) { let { lat, lng } = event.latlng; console.log("[" + lat + ", " + lng + "]"); });
map.on('zoomstart', function () { var zoomLevel = map.getZoom(); console.log(zoomLevel); });
var marker = L.marker([26.081476491742904, 119.29704755981834]).addTo(map); marker.bindPopup("<b>这个地方真是太好玩了!</b><br/>这是屁股树的坐标😍!");
var latlngs = [ [26.08009367221409,119.29242494512384], [26.080079217568272,119.29223174932305], [26.08009367221409,119.29216735072279], [26.080310491686973,119.29212978487263], [26.080296037067946,119.29162532917066], [26.080453431663422,119.29152938351272], [26.080381158638648,119.29095499726753], [26.07820812885429,119.29081367507568], [26.07815030932909,119.29159187052262], [26.078212947146778,119.29209635584687] ];
var polyline = L.polyline(latlngs, {color: 'green'}).addTo(map); polyline.bindPopup("上学去了😭");
var latlngs = [ [26.074889884389435,119.2912822984996], [26.073579264327183,119.2915720922007], [26.073902102248386,119.2926293025549], [26.07466823643904,119.29226437715347], [26.075150079274067,119.29180822040166] ];
var polygon = L.polygon(latlngs, {color: 'blue'}).addTo(map); polygon.bindPopup("乌石山下,白马河旁~");
var circle = L.circle([26.077862817425885, 119.29212395568047], { color: 'red', fillColor: '#f03', fillOpacity: 0.5, radius: 32.6 }).addTo(map); circle.bindPopup("阿公阿妈家~");
var bounds = [[26.081312674254516, 119.2925756072068], [26.08073449305117, 119.29365965031108]];
var rectangle = L.rectangle(bounds, {color: "#ff7800", weight: 1}).addTo(map); rectangle.bindPopup("就没见它开张过!😠");
var svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svgElement.setAttribute('xmlns', "http://www.w3.org/2000/svg"); svgElement.setAttribute('viewBox', "0 0 200 200"); svgElement.innerHTML = '<rect width="200" height="200"/><rect x="75" y="23" width="50" height="50" style="fill:red"/><rect x="75" y="123" width="50" height="50" style="fill:#0013ff"/>'; var svgElementBounds = [[26.077898151572324, 119.30137317389199], [26.07745968496554, 119.30187226304396]]; var svg = L.svgOverlay(svgElement, svgElementBounds).addTo(map);
var popup = L.popup() .setLatLng([26.079171783403833, 119.2939243421818]) .setContent("小迷糊和小小怪最喜欢吃的百姓鲜捞~") .openOn(map);
|