ux icon indicating copy to clipboard operation
ux copied to clipboard

[Map] Setting Point not by coordinates but by text query

Open simonsolutions opened this issue 1 year ago • 1 comments

For UX Map it would be helpful if the points for map center and marker would not only be available by Long-Lat-Combinations but by text query. Google maps e.g. has this in their url request: https://www.google.com/maps/embed/v1/place?key={{ GoogleMapsApiKey }}&q={{ GoogleMapsLocation }}&zoom=15 Where GoogleMapsLocation could be "Times Square, Manhattan, New York" for example. Then Google would center the Map around that point instead of giving coordinates.

simonsolutions avatar Oct 23 '24 10:10 simonsolutions

Hi, I understand it can be useful, but that would mean introducing geocoding to UX Map, and I don’t think we really want that. UX Map is designed to display a map on your website.

That said, I kind of agree that having something like Point::fromAddress('Times Square, Manhattan, New York') (or equivalent) would be appealing. However:

  • Imagine you’re using Leaflet to render your map. Should we geocode through Leaflet/OpenStreetMap (if such a service exists) or through the Google Maps API?
  • Point only takes two (required) parameters, $latitude and $longitude, meaning that Point::fromAddress() would need to rely on some workarounds to properly initialize the object. It might also require a static object (to call a geocoding service).
  • We also want to store geocoding results in cache; calling the geocoding service each time the map renders is a no-go.

In conclusion, I believe such logic should stay external to UX Map. You can easily implement this feature by using a geocoding client (with cache) by yourself and creating your Point instance with new Point(...$geocodedAddress['_latlng']).

Kocal avatar Oct 26 '24 13:10 Kocal

I'm closing, feel free to re-open if needed!

Kocal avatar Nov 07 '24 09:11 Kocal