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

Manually set latitude and longitude #24

Open
nickff opened this issue Feb 24, 2015 · 1 comment
Open

Manually set latitude and longitude #24

nickff opened this issue Feb 24, 2015 · 1 comment
Assignees

Comments

@nickff
Copy link
Member

nickff commented Feb 24, 2015

Let's add the ability to manually set latitude and longitude! It'll be swell.

@nickff nickff changed the title Add ability to manually set latitude and longitude Manually set latitude and longitude Feb 24, 2015
@fireproofsocks
Copy link
Member

This is trickier than it sounds, so hear me out.

Regular (current) user flow:

  1. user adds address data to a page, clicks save.
  2. onSave event triggers plugin: fingerprints the address, checks cache to see if we already have lat/lng coordinates
  3. If we don't have the info in cache, we perform a query to Google Maps API.
  4. Save the lat/lng coordinates.

If you manually add lat/lng coordinates, you could change the plugin to skip the lookup if the lat/lng TVs are not empty. However, that means that if you change the address of a page, the lat/lng won't change unless you manually delete the lat/lng each time you update the address -- this won't work if you have the TVs hidden, for example.

An un-elegant solution is to have a checkbox that can override the API lookup and allow for manual definitions. A similar low-brow solution is to use a different template for records that you wish to manually set (because only resources with certain templates trigger the map API lookups).

A more elegant solution would be this:

  1. Add an address, save your page.
  2. If the address lookup came from Google Maps API, you cache the lat/lng and you write the lat/lng to the TVs.
  3. If the address lookup came from cache, then you don't re-write the TV values UNLESS they are empty.

This would require a "hasCacheKey" type of function in the Gmarker class. The advantage here would be that a new lookup (and thus new coordinates) would be triggered/injected each time the address was changed, and you would be free to edit the lat/lng coordinates manually after that. If you needed to reset the lat/lng coordinates to the "official" coordinates, then you would need to delete the values in the lat/lng TVs (which is only possible if the TVs are visible and not hidden).

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

2 participants