debug for regular layers
This commit is contained in:
parent
ff470d5861
commit
1c3b1889ec
@ -21,7 +21,7 @@
|
|||||||
<button id="openLine">Open Line</button>
|
<button id="openLine">Open Line</button>
|
||||||
<button id="openPoly">Open Polygon</button>
|
<button id="openPoly">Open Polygon</button>
|
||||||
<button id="close">Close</button>
|
<button id="close">Close</button>
|
||||||
<button id="toggle">Toggle</button>
|
<button id="toggle">Toggle Marker</button>
|
||||||
<button id="change">Change content</button>
|
<button id="change">Change content</button>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -35,9 +35,8 @@
|
|||||||
.addLayer(osm);
|
.addLayer(osm);
|
||||||
|
|
||||||
var features = new L.FeatureGroup();
|
var features = new L.FeatureGroup();
|
||||||
for (var i = 0; i < 100; i++) {
|
|
||||||
var marker = L.marker(getRandomLatLng(map)).addTo(features);
|
var marker = L.marker(getRandomLatLng(map)).addTo(features);
|
||||||
}
|
|
||||||
|
|
||||||
var line = L.polyline([
|
var line = L.polyline([
|
||||||
getRandomLatLng(map),
|
getRandomLatLng(map),
|
||||||
@ -52,13 +51,10 @@
|
|||||||
getRandomLatLng(map)
|
getRandomLatLng(map)
|
||||||
]).addTo(features);
|
]).addTo(features);
|
||||||
|
|
||||||
// features.bindPopup("<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p><p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque.</p>").addTo(map);
|
|
||||||
features.bindPopup(function(layer){
|
features.bindPopup(function(layer){
|
||||||
return layer._leaflet_id + '';
|
return "Layer ID is " + L.stamp(layer);
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
function logEvent(e) { console.log(e.type); }
|
|
||||||
|
|
||||||
L.DomUtil.get('change').onclick = function(){
|
L.DomUtil.get('change').onclick = function(){
|
||||||
features.setPopupContent('Foo');
|
features.setPopupContent('Foo');
|
||||||
};
|
};
|
||||||
@ -84,18 +80,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
L.DomUtil.get('toggle').onclick = function(){
|
L.DomUtil.get('toggle').onclick = function(){
|
||||||
features.togglePopup();
|
features.togglePopup(features.getLayerId(marker));
|
||||||
};
|
};
|
||||||
|
|
||||||
// map.on('click', logEvent);
|
|
||||||
|
|
||||||
// map.on('movestart', logEvent);
|
|
||||||
// map.on('move', logEvent);
|
|
||||||
// map.on('moveend', logEvent);
|
|
||||||
|
|
||||||
// map.on('zoomstart', logEvent);
|
|
||||||
// map.on('zoomend', logEvent);
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
alert("you clicked a rectangle.")
|
alert("you clicked a rectangle.")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rectangle.bindPopup('I\'m a rectangle!');
|
||||||
|
|
||||||
var map = new L.Map('map', {
|
var map = new L.Map('map', {
|
||||||
center: bounds.getCenter(),
|
center: bounds.getCenter(),
|
||||||
zoom: 7,
|
zoom: 7,
|
||||||
|
@ -79,7 +79,7 @@ L.Layer.include({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_openPopup: function (e) {
|
_openPopup: function (e) {
|
||||||
this._popup.options.offset = this._popupAnchor(e.layer);
|
this._popup.options.offset = this._popupAnchor(e.layer || e.target);
|
||||||
if(typeof this._popup._content === 'function') {
|
if(typeof this._popup._content === 'function') {
|
||||||
this._popup._source = e.layer;
|
this._popup._source = e.layer;
|
||||||
this._popup.update();
|
this._popup.update();
|
||||||
@ -88,7 +88,7 @@ L.Layer.include({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_popupAnchor: function(layer){
|
_popupAnchor: function(layer){
|
||||||
var anchor = layer._getPopupAnchor ? layer._getPopupAnchor() : [0,0];
|
var anchor = (layer._getPopupAnchor) ? layer._getPopupAnchor() : [0,0];
|
||||||
return L.point(anchor).add(L.Popup.prototype.options.offset);
|
return L.point(anchor).add(L.Popup.prototype.options.offset);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user