leaflet本サイトのサンプルをみて地図を作っているのですが、例えば、下記のように、ピンを立てる位置の緯度経度が完全に一致している場合で、情報を4つ同じ位置から表示したい場合はどうしたらいいのでしょうか?
ピンをクリックした時に4つとも(下記で言うと、This is Littleton,This is Littleton02,This is Littleton03,This is Littleton04,)の情報を確認出来るようにしたいです。
L.marker([39.61, -105.02]).bindPopup('This is Littleton, CO.').addTo(cities),
L.marker([39.61, -105.02]).bindPopup('This is Littleton02, CO.').addTo(cities),
L.marker([39.61, -105.02]).bindPopup('This is Littleton03, CO.').addTo(cities),
L.marker([39.61, -105.02]).bindPopup('This is Littleton04, CO.').addTo(cities);
Javascript
1 2 3<!DOCTYPE html> 4<html> 5<head> 6 7 <title>Layers Control Tutorial - Leaflet</title> 8 9 <meta charset="utf-8" /> 10 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 11 12 <link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" /> 13 14 <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.1/dist/leaflet.css" /> 15 <script src="https://unpkg.com/leaflet@1.0.1/dist/leaflet.js"></script> 16 17 18 <style> 19 #map { 20 width: 600px; 21 height: 400px; 22 } 23 </style> 24 25 26</head> 27<body> 28 29<div id='map'></div> 30 31<script> 32 var cities = new L.LayerGroup(); 33 34 L.marker([39.61, -105.02]).bindPopup('This is Littleton, CO.').addTo(cities), 35 L.marker([39.61, -105.02]).bindPopup('This is Littleton02, CO.').addTo(cities), 36 L.marker([39.61, -105.02]).bindPopup('This is Littleton03, CO.').addTo(cities), 37 L.marker([39.61, -105.02]).bindPopup('This is Littleton04, CO.').addTo(cities); 38 39 40 var mbAttr = 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + 41 '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + 42 'Imagery © <a href="http://mapbox.com">Mapbox</a>', 43 mbUrl = 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpandmbXliNDBjZWd2M2x6bDk3c2ZtOTkifQ._QA7i5Mpkd_m30IGElHziw'; 44 45 var grayscale = L.tileLayer(mbUrl, {id: 'mapbox.light', attribution: mbAttr}), 46 streets = L.tileLayer(mbUrl, {id: 'mapbox.streets', attribution: mbAttr}); 47 48 var map = L.map('map', { 49 center: [39.73, -104.99], 50 zoom: 10, 51 layers: [grayscale, cities] 52 }); 53 54 var baseLayers = { 55 "Grayscale": grayscale, 56 "Streets": streets 57 }; 58 59 var overlays = { 60 "Cities": cities 61 }; 62 63 L.control.layers(baseLayers, overlays).addTo(map); 64</script> 65 66 67 68</body> 69</html> 70
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/17 07:52
2016/10/18 16:12