Skip to content

Conversation

quinnchr
Copy link
Contributor

This is a fairly simple change to pass along options to the Mapbox API. All options that are set are passed directly to the API, except for the proximity option which will also accept L.latLng objects. This allows you to do something like:

Geocoder.mapbox('pk.blahblahblah', { geocodingQueryParams: {
    country: 'US',
    proximity: map.getCenter()
}})

Copy link
Owner

@perliedman perliedman left a comment

Choose a reason for hiding this comment

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

Hi and thanks, this looks great! I added a quick comment, tell me what you think.

initialize: function(accessToken, options) {
var params = options.geocodingQueryParams;
params.access_token = accessToken;
if (typeof params.proximity !== 'undefined'
Copy link
Owner

Choose a reason for hiding this comment

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

What do you think about moving this check to the geocode method, so that it will work even if the options are updated after the control has been initialized?

I would thing it's quite common to set the proximity option to the map's center or similar, so that it will be updated as the user moves around.

@quinnchr
Copy link
Contributor Author

It definitely makes more sense to handle the proximity param inside the geocode function. Thanks for the idea! The latest commit should take care of it. Let me know if there's anything else this needs.

@perliedman perliedman merged commit a0151cc into perliedman:master May 21, 2017
@perliedman
Copy link
Owner

Thanks again, great addition!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants