Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

feat(configure): expose configure method #637

Merged
merged 14 commits into from
Nov 21, 2018
Merged

Conversation

JonathanMontane
Copy link
Contributor

@JonathanMontane JonathanMontane commented Nov 9, 2018

Summary

We created a setUseDeviceLocation to allow dynamic control of the useDeviceLocation in a previous PR. This PR supersedes it with an improved API that allows one to reconfigure all of the query parameters and some of the controls dynamically (includes useDeviceLocation).

The idea is that there are a lot of use case where one might want to modify the behaviour of the search based on user input, and this was not possible before. For instance, if the user selected a country we can now dynamically restrict the search to that country so the performances will be greatly improved and the relevance will be better too.

I also took the liberty of moving some of the options in the documentation, so that non-modifiable options appear at the beginning of the page (container, appId, apiKey, style) and advanced non-modifiable options appear at the very end.

This PR removes the syntax:

places.setUseDeviceLocation(true);

in favour of

places.configure({ useDeviceLocation: true });

The configure method applies partial updates to the configuration:

places.configure({ type: 'city' });
places.configure({
  countries: ['fr'],
  language: 'en',
  aroundLatLng: `123,234`
});

/*
configuration is now: {
  type: 'city',
  countries: ['fr'],
  language: 'en',
  aroundLatLng: `123,234`
}
*/

@JonathanMontane
Copy link
Contributor Author

JonathanMontane commented Nov 9, 2018

It's still a WIP, as I haven't checked perfectly how we can reset values to their defaults with this pattern, but it should be pretty close to the end behaviour 🙂, so if you want to have a look already, don't hesitate 👍

I'll also add some additional documentation before merging, but I'm still trying to figure what the correct way of writing it would be.

@JonathanMontane JonathanMontane changed the title Feat/configure feat(configure): expose configure method Nov 15, 2018
Copy link
Contributor

@raphi raphi left a comment

Choose a reason for hiding this comment

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

LGTM 👍🚀

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

Successfully merging this pull request may close these issues.

2 participants