ok,I tried out your example.Here is what I think you are not doing it
right.You are loosing the reference to polygon object.I copy page
chucks of the code I changed to make it work
1] Created a global variable for polygon.
var map = null;
var polygon;
2] You already have global variable for map object so I removed var
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
to
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
3] important changes.reused polygon global variable for both click and
dragend listeners( removed var , and renamed newpolygon to polygon)
polygon = new GPolygon([
new GLatLng(document.getElementById
('latstart').value,document.getElementById('longstart').value),
new GLatLng(document.getElementById
('latend').value,document.getElementById('longstart').value),
new GLatLng(document.getElementById
('latend').value,document.getElementById('longend').value),
new GLatLng(document.getElementById
('latstart').value,document.getElementById('longend').value),
new GLatLng(document.getElementById
('latstart').value,document.getElementById('longstart').value),
], "#CC0000", 1, 0.8, "#CCCC00", 0.1 );
map.addOverlay(polygon);
have fun
On Jan 24, 7:05 pm, peziza <[email protected]> wrote:
> Thank you for the comments Larry & Marcelo. The link to your map,
> Marcelo, was of great inspiration, though I have not solved the
> problem yet, and I am bit mystified (and no javascript nerd,
> unfortunately..)
> I have amended the testmap a bit and now it functions a step more in
> the right direction, but still not there.
> I have added an event trigger on "marker, drag" to remove the polygon
> layer, and it works - the first time you drag, not the following???
> Why is this event not fired? The dragend event IS fired, as the
> polygons are being set.
> When I set a new polygon with the dragend event, why is it not
> targeted with the map.removeOverlay(polygon)? - request?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---