Popup and Offset problems

1,281 views
Skip to first unread message

Andy Wallace

unread,
Aug 29, 2013, 9:03:03 PM8/29/13
to leafl...@googlegroups.com
Hey all -
I've got my maps working, now dealing with more visual issues. One thing I'm trying to tweak is the location of popups. I have this code:


var popup = new L.Popup({
                          closeOnClick: true,
                          autoPan: true,
                          closeButton: false,
                          autoPanPadding: [10,10]
                        })
                          .setLatLng(this.latlng)
                          .setContent(infowindow_html);
listingmarker.bindPopup(popup).openPopup();

and it works fine, but the popup is shifted over from where I want it "on" my icon. So I try to use the offset argument:

var offset = [0, 6];
var popup = new L.Popup({
                          offset: offset,
                          closeOnClick: true,
                          autoPan: true,
                          closeButton: false,
                          autoPanPadding: [10,10]
                        })
                          .setLatLng(this.latlng)
                          .setContent(infowindow_html);

And nothing changes, the popup still comes up at the same position relative to my icon. Putting large offsets (40 or -40) 
doesn't make any difference. 

Any thoughts? What am I messing up here?

thanks,
Andy

Bryan McBride

unread,
Aug 30, 2013, 9:48:08 AM8/30/13
to leafl...@googlegroups.com
Hi Andy,

I don't think the autoPanPadding option is what you are looking for. This option allows you to set the padding between the popup and the edge of the map. If you want to modify the location of the popup relative to the icon, you should adjust the popupAnchor option for the icon. See http://leafletjs.com/reference.html#icon for documentation.

Best of luck!

BRYAN

Andy Wallace

unread,
Aug 30, 2013, 3:35:35 PM8/30/13
to leafl...@googlegroups.com
Thanks for the suggestion Bryan. I was actually trying to use the "offset" parameter. fooling with those values, and not getting what I expected (that the popup change position relative to the anchor on the icon).
Reply all
Reply to author
Forward
0 new messages