Search

Hello, I'm creating a shop locater and have a postcode field along with the first line of the address. To work with the Google Map API, I need to also fill out a Longitude & Latitude field - which I've also created in my section.

What I need now is to modify the section by adding an button that when clicked executes a Javascript (pure JS, no libs) script to pull the Longitude and Latitude from Google Maps, then fills in the Longitude & Latitude fields I've set up.

This saves the client trying to figure them out as it's not a simple task!

Can this be done? If so, how?

Cheers!

Have you checked out the Geolocation Service or Field: address or the Map Location Field?

I have not personally used any of those but when you search for e.g. 'latitude' on this forum you'll get quite a few results that should help you.

You might find this article useful: Building a store locator using the Map Location Field.

@davidhund: The Geolocation doesn't work in Symphony 2.2 for some reason. When I upload the extension, it breaks Symphony! Field:address didn't appear to be what I was after.

@Nickdunn: Thanks for the article... from what I see that's using Google Map API v2, which I have been informed that's practically depreciated. API v3 doesn't need a key either.

We currently have a basic HTML page which uses API v3, that takes in the address and post code, then finds the co-ordinates upon clicking a button. Would it be difficult to translate that into a Symphony Extension?

Ok. It must not be too hard to port the geolocation script to v. 3 V2 is indeed old, although still supported I believe. V3 is optimized for mobile but lacks some functionality.

I will probably take a look at the Geolocation extensions myself since I might need it soon. If the JS is easily ported to v3 I'll post a patch/fork/watchamacallit.

I'm writing a jQuery Google Maps API v3 plugin at the moment, it is ideal for updating any extensions that have a Geocoding requirement. It's called Goomaps and is available here for anyone who wants to play with updating any extensions on here to the latest API...

The Address field is exactly what you need though, as it Geocodes the entered address as it saves, so no need for the button! The data is all available in the fields datasource XML too.

I must admit, the Goomaps plugin is to aid some projects at work, and to also update some of the Geocoding and Mapping extensions on Symphony, when it's solid, but if anyone wants to play around, please do...

v2 API is depracated, but is still available for use.

Sounds like the Geocoding field does exactly what you need. The extension

  • combines the values of other fields for a Google Maps geocoding request and saves the returned coordinates as a latitude/longitude pair
  • saves coordinates both from the publish page and from events
  • supports “store locator” Data Source filtering

Go with the Geocoding field for now. I'll add it to my todo list to update the Map Location Field to API v3 in the future. But you can still use it... it, like many thousands of other websites and applications, will continue to implement the API v2 for years to come.

Cheers, the Geocoding field works perfectly. Can't believe I missed finding that one!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details