Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom result marker popups via callback #72

Open
nickdaugherty opened this issue Nov 15, 2015 · 1 comment
Open

Support custom result marker popups via callback #72

nickdaugherty opened this issue Nov 15, 2015 · 1 comment

Comments

@nickdaugherty
Copy link

It should be easy to customize the marker popup content by passing a function to the Geocoder options that takes a Pelias result as an argument and returns an html string or DOM element to be used as the marker popup.

L.control.geocoder( <api_key>, {
    ...
    markersPopup: function( result ) {
        // Create popup content here
        return result.properties.label;
    }
    ...
});
@louh
Copy link
Contributor

louh commented Nov 16, 2015

Thanks for the suggestion, @nickdaugherty. I'm contemplating how we might be able to pass through all of the Popup options available on Leaflet as well. This is far from a fully thought out proposal, but I imagine it may be something that extends the options object, like so:

L.control.geocoder( <api_key>, {
    ...
    popup: {
        // Leaflet popup options
        maxWidth: 400,
        maxHeight: 400,
        closeButton: false,
        // Extend options with a function that returns content
        setContent: function (result) {
            // Create popup content here
            return result.properties.label;
        }
    }
    ...
});

This would allow you to also pass false (or falsy values) in place of options to disable popups entirely, or true (or truthy values) for "default" popup behavior.

Let me know what you think?

@dianashk dianashk added this to the Leaflet Geocoder milestone Apr 19, 2016
@louh louh modified the milestones: v2 (future), Leaflet Geocoder Mar 8, 2017
@louh louh removed this from the v2 (future) milestone Mar 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants