Skip to content

Commit

Permalink
Tweak popup-style toolbar example to open popup toolbar above markers.
Browse files Browse the repository at this point in the history
…Fixes #9.
  • Loading branch information
justinmanley committed Jan 24, 2015
1 parent 0b6a81c commit bf8dc10
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion examples/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,16 @@
layer.on('click', function(event) {
var latlng = event.latlng;

new L.EditToolbar.Popup(latlng, {
/* Override event.latlng to open the popup just above markers. */
if (layer instanceof L.Marker) {
height = parseFloat(L.DomUtil.getStyle(layer._icon, 'height'));
latlng = map.layerPointToLatLng(map
.latLngToLayerPoint(latlng)
.add(L.point(0, -height))
);
}

new L.EditToolbar.Popup(latlng, {
className: 'leaflet-draw-toolbar',
actions: editActions
}).addTo(map, layer);
Expand Down

2 comments on commit bf8dc10

@jacobtoye
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admittedly I haven't quite followed the history of this change, however couldn't this be achieved with css? Would this then solve #18.

@justinmanley
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobtoye - It's a good idea, and something I hadn't thought of.

However, addressing this with CSS alone means that the offset of the popup toolbar must be hardcoded into the toolbar implementation. This means that this issue and #18 will recur whenever users try to open popup toolbars on markers with non-default icons.

Please sign in to comment.