PDA

View Full Version : Access geocoded latitude and longitude values


info315909
09-20-2009, 09:25 PM
Once a map has been initialised using a text address - where and how can the geocoded latitude and longitude values for that address be accessed?

I would like to store the latitude and longitude values in a database for caching purposes, and also, to then use those values for a seperate Google Street View at the same address.

How would you access the variables for the outputted latitude and longitude? Javascript or PHP variables?

tom92909
09-20-2009, 09:35 PM
When entering the coordinates, use the decimal value, not the Degrees, Minutes, Seconds value.

This site will convert to decimal...
http://www.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html

info315909
09-20-2009, 09:49 PM
Sorry if I wasn't clear.

The map is created from an actual text address (27, long street, etc) the latitude and longitude values are determined via Google's geocode service 'on-the-fly'.

I would like to know where the latitude and longitude values are stored and how to access those values. Variables created in wagmp_map_1.php?

Justin Nemeth
09-21-2009, 10:01 AM
Check your site that contains the map and there will be a directory called _promaps_cache. There is an XML file in there with the cached values.

info315909
09-21-2009, 05:54 PM
Thanks Justin.

That would have made things easy, however, there was no xml file in the '_promaps_cache' directory. The required xml file is not being created.

I created a blank xml file called '_promaps_geocache.xml' and uploaded it to the directory. However it does not get updated when viewing the map (tried many times). The '_promaps_cache' directory and the '_promaps_geocache.xml' have 755 permissions.

How do I troubleshoot this?

info315909
09-21-2009, 06:06 PM
I created a new test page with a google map.

The relevant generated files are attached.

Can you locate the issue?

Thanks for your help.

Justin Nemeth
09-23-2009, 10:47 AM
Can you post a link to your site that contains the map page? That will allow us to debug the map on your live server to see what is going on.

info315909
09-23-2009, 04:44 PM
Justin, unfortunately it is in a secure backend environment.

Is there another way to determine the issue?

Is it possible to upload the files I sent to a testing area on one of your servers to determine if the _promaps_geocache.xml file is being created and updated?

Are the created files exactly as they should be?

Thanks for your continued help with this issue.



In the meantime could you please send me an example of a correctly written _promaps_geocache.xml file with an address written to it?

Justin Nemeth
09-24-2009, 01:33 PM
After some testing it looks like a permissions issue on the _promaps_cache directory. Trying giving that directory (and the file inside to be safe) write permissions. Make sure its not set to read only too.

Here is what the XML looks like:

<geocode_data version="1.0">
<geocode_entry ID="George Street Sydney New South Wales 2000 Australia">
<address>
George Street, Sydney, New South Wales, 2000, Australia
</address>
<geocode>(-33.868737, 151.206946)</geocode>
</geocode_entry>
</geocode_data>

info315909
09-24-2009, 06:00 PM
A combination of the two following changes have got it working:

1. Created the _promaps_geocache.xml file with the example XML you provided as a starting point.
2. Changed permissions for folder and file to '777' (read/write all).

However, the created XML has ![CDATA] tags throughout. What would cause this? And is this an issue?


Example code:

<?xml version="1.0" encoding="utf-8"?>
<geocode_data version="1.0">
<geocode_entry ID="200 George Street Sydney NSW 2000 Australia"><address><![CDATA[200 George Street, Sydney, NSW, 2000, Australia]]></address><geocode><![CDATA[(-33.862622, 151.207813)]]></geocode></geocode_entry></geocode_data>


Thanks again.

Justin Nemeth
09-25-2009, 08:52 AM
The CDATA tags are expected. Basically they are way to allow extra characters in an XML value. It's like the equivalent of escaping in PHP. They don't hurt anything.

info315909
09-27-2009, 08:04 PM
Thanks for your help so far. Much appreciated.

Unfortunately, testing has shown, that for whatever reason, the function that writes to _promaps_geocache.xml is unreliable at best.

Too unreliable to be getting the geocoded latitutde and longitude values from for a seperate Google Street view (the goal that caused this initial forum thread).

It seems the best way now is to obtain the geocoded latitutde and longitude values from wagmp_map_1.php directly and have a function within this file that uploads the values to a database?

Could you be of further assistance in describing where/how to best obtain the geocoded latitude and longitude values within wagmp_map_1.php?

Justin Nemeth
10-02-2009, 09:33 AM
Here is a way to get the map coordinates. This is taken from the FAQ under the Pro Maps support page on our site:

On occasion, Google’s geo-coding service cannot properly locate an address, and in such cases, this default location is displayed. In order to accommodate for this, enter a location’s latitude and longitude coordinates in stead of a street address. To find the latitude and longitude coordinates of an address, follow these steps.


In your browser, navigate to http://maps.google.com and search for your address.
When the address is displayed, enter the following javascript code in the browser’s address bar and press Enter:

javascript:void(prompt('',gApplication.getMap().ge tCenter()));This will present an info window containing the latitude and longitude coordinates.

-justin

info315909
10-02-2009, 05:23 PM
Thanks for the reply, but that is utterley useless information when dealing with dynamic addresses.

If someone is able to provide some help with the following it will be greatly appreciated:


Where/how in the code to obtain the geocoded latitude and longitude values which are determined from a dynamic text address - within wagmp_map_1.php?

Justin Nemeth
10-05-2009, 09:48 AM
It's not utterly useless. You can use that to get coordinates for any address and then store that info in your database. Coordinates can be used within the Pro Maps wizard instead of the address string.

Anywhere in the wagmp_map_1.php file that calls "geocoder.getLatLng" is grabbing the coordinates from the google maps API. Once the coordinates are returned, it attempts to cache that info in the XML file for later use. In the past, any issues I've seen with the cache file have been permissions related. All it is doing it trying to open the file and write a new entry. Then later it reads that file and uses the cached values if they exist.

-justin

info315909
10-05-2009, 06:48 PM
I meant no offense, however I assumed you understood my issue.

The addresses are inputed by a user 'live' then that text data is stored in a database which is inputted dynamically into your Pro Maps for Google interface. Hence why the following is of no help:

"In your browser, navigate to http://maps.google.com and search for your address"

I was simply looking for some advice on where to access the geocoded latitude and logitude values from within wagmp_map_1.php, not the xml cache file. The following was of some help (however not specific in anyway):

"Anywhere in the wagmp_map_1.php file that calls "geocoder.getLatLng" is grabbing the coordinates from the google maps API. Once the coordinates are returned, it attempts to cache that info in the XML file for later use. In the past, any issues I've seen with the cache file have been permissions related. All it is doing it trying to open the file and write a new entry. Then later it reads that file and uses the cached values if they exist".

I was hoping to save time by receiving advice on this, but I will figure it out myself...