Hi,
Thank you for the enlightening answer!
Ok, I think I need to rewind the tape a bit and make sure that I
understand what I have;
I have the working map which sends the lat/lng to the PHP-script. This
is done via the function place() and function showAddress(). Show
address has an if-statement that decides if a marker was placed
directly on the map after the search or if there were multiple choices
to choose from.
When the marker is dragged by the user the value in the text-field is
updated by:
document.getElementById("lat").value=marker.getPoint().lat();(/lng())
Summary: I have the lat/lng and I need to use that to retrieve the
address and additional info.
So far so good...
I the example with reverse geocoding they use two functions;
getAddress(overlay, latlng)
and
function showAddress(response)
Am I thinking wrong when I thinking that the getAddress-function
should be called from the GEvent.addListener(marker, "drag", function
()?
When the user moved the marker addlistner-event calls the getAddress-
function like this GEvent.addListener(marker, "drag", getAddress ) (as
you say). The getAddress-function uses the latlng for a reverse
geocoding.
Is it correct so far?
Question: Should I use GEvent.addListener(marker, "dragend",
getAddress ) so that the function getAddress is called when the marker
not is dragged anymore?
I have tried to use GEvent.addListener(marker, "dragend", getAddress )
but the map will not show.
If this somehow is correct (but I do not get it to work), let's
continue with looking into the getAddress-function:
function getAddress(overlay, latlng) {
if (latlng != null) {
address = latlng;
geo.getLocations(latlng, showAddress);
}
}
geo.getLocations(latlng, showAddress);. It takes latlng and
showAddress is the function that should handle the results. Is that
correct?
Ok, I need to change the name from showAddress to something
else...small thing.(showAddressNew)
In the showAddressNew I assign the values to the hidden fields...is
that correct?
Like: document.getElementById("statcode").value=result.Status.code;
Shouldn't that do the trick?
I have updated the map but it doesn't work.
I'm grateful for choaching in the right direction, thank you!
/Nimrod
On 5 Maj, 23:14, Rossko <[email protected]> wrote:
> > Please seehttp://www.g8journey.com/map.php
>
> > The map is working apart from thereversegeocoding.
>
> Unconnected to this, do a 'view source' on your page and you will see
> some funny characters before the doctype that need to come out.
>
> At the heart of your code is your place() function, which includes -
> GEvent.addListener(marker, "drag", function(getAddress)
> { document.getElementById ....
>
> You can't do that. You can do
> GEvent.addListener(marker, "drag", function() { some anonymous code })
> or you can do
> GEvent.addListener(marker, "drag", getAddress ) // with getAddress()
> defined elsewhere
>
> Look at the listener in the Google example you quote. What
> parameters their getAddress() gets fed, depends on what the event
> defines - you can't just make these up.
> Here's a quick guide to the data returned from event listeners
> -http://econym.org.uk/gmap/gevent.htm
>
> Whichever way you decide to go, your code will need to extract the lat/
> long of the dragged marker,reversegeocode it to get an address, and
> then paste the address text in your form.
>
> You'll also need to think about what happens if the user doesn't want
> to drag the marker.
>
> cheers, Ross K
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---