On Jul 23, 4:02 pm, Rossko <[email protected]> wrote:
> > Thanks to remind me my mistake about Point, I solve it but the problem still
> > remains and markers create a new lat lang in the table when I drag them.
>
> You need to get a javascript debugger, it'd be a lot quicker for you
> to find your own problems when javascript errors are reported.
>
> On page load, there's a javascript error "point is not defined" in
> this line
> document.getElementById("cLat").innerHTML = point.lat().toFixed
> (5);
> in your map load() function.
> 'point' hasn't been defined at this time, in this scope.
>
> The code is all a bit muddled here,
>
> GEvent.addListener(map, 'click', function(overlay, latlng) {
> ...
> map.addOverlay(marker);
> markers.push(marker);
>
> Okay so far, we've put a click listener on the map to make a new
> marker
>
> GEvent.addListener(marker, 'dragend', function(){
> geocoder.getLocations(marker.getLatLng(), showAddress)});
>
> Okay, when we make that new marker we will add a dragend listener.
> When a dragend does occur, that will reverse geocode the new location
> and run showAddress(). That's all that happens at dragend, the
> listener is closed with the }).
>
> geocoder.getLocations(latlng, showAddress);});
>
> Now (while doing the make-new-marker thing in the map-click routine
> still) we'll reverse geocode the click location and rund run
> showAddress() on it. That's all that happens on map-click, the
> listener is closed at }).
>
> document.getElementById("cLat").innerHTML = point.lat().toFixed(5);
> document.getElementById("cLng").innerHTML = point.lng().toFixed
> (5); }}
>
> These are trying to run in the map load() function, before any clicks
> or drags.
> 'point' hasn't been created anywhere yet. Are they supposed to be
> there at all?
>
> ----
>
> Anyway, the key thing is that your showAddress() routine is the thing
> that populates the table, on a click or on a drag.
> It uses a global variable row_no to decide where to put the new
> information.
> Then it increments row_no.
>
> If I read you right, on a dragend, you don't want a new row, you want
> to overwrite the last one.
I would assume he would want to overwrite the existing entry for that
marker. That would require keeping an association between the row of
the table and the marker. Doable if you are creating the table
yourself (give each row a unique id so you can access it via
document.getElementById, I don't know whether it is possible with the
"visualisation thing" either. I suppose you could always destroy and
recreate the whole table (by that probably would be inefficient as the
number of markers grows).
-- Larry
> I don't know anything about this data visualisation thing you are
> using, but thats the part you need to alter.
> What happens if you set the row pointer back one at a dragend, like
> this -
> GEvent.addListener(marker, 'dragend', function(){
> --row_no;
> geocoder.getLocations(marker.getLatLng(), showAddress);
> });
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---