Skip to content

Commit

Permalink
debug for regular layers
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickarlt committed Dec 29, 2014
1 parent ff470d5 commit 1c3b188
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
24 changes: 5 additions & 19 deletions debug/map/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<button id="openLine">Open Line</button>
<button id="openPoly">Open Polygon</button>
<button id="close">Close</button>
<button id="toggle">Toggle</button>
<button id="toggle">Toggle Marker</button>
<button id="change">Change content</button>

<script type="text/javascript">
Expand All @@ -35,9 +35,8 @@
.addLayer(osm);

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([
getRandomLatLng(map),
Expand All @@ -52,13 +51,10 @@
getRandomLatLng(map)
]).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){
return layer._leaflet_id + '';
return "Layer ID is " + L.stamp(layer);
}).addTo(map);

function logEvent(e) { console.log(e.type); }

L.DomUtil.get('change').onclick = function(){
features.setPopupContent('Foo');
};
Expand All @@ -84,18 +80,8 @@
};

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>
</body>
</html>
2 changes: 2 additions & 0 deletions debug/vector/rectangle.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
alert("you clicked a rectangle.")
});

rectangle.bindPopup('I\'m a rectangle!');

var map = new L.Map('map', {
center: bounds.getCenter(),
zoom: 7,
Expand Down
4 changes: 2 additions & 2 deletions src/layer/Layer.Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ L.Layer.include({
},

_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') {
this._popup._source = e.layer;
this._popup.update();
Expand All @@ -88,7 +88,7 @@ L.Layer.include({
},

_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);
},

Expand Down

0 comments on commit 1c3b188

Please sign in to comment.