Hi,
I am trying to make a map with polygons. First I tested a polygon
which was like the boundary of a city. I wanted to make the polygon
green, then when a user moves their mouse over the polygon, the
polygon turns white. When the user moves their mouse away from the
polygon, they polygon again turns green. When the user clicks on the
polygon, the polygon goes away. For one polygon this was working
fine, albeit it was not smooth for example if you moved you mouse over
the polygon and quickly moved your mouse out, it would stay white
instead of turning back into green. But the real problem came when i
added a second polygon. Now when i click on the first polygon it does
not go away. After i click on it a couple of times then it goes away,
or when i click on when the pointer is a hand then it goes away. If
the pointer is for something clickable, the polygon does not go away.
Any help in this regard will be appreciated. Here is the code:
function initialize()
{
var map = new GMap2(document.getElementById
("map_canvas"));
map.setCenter(new GLatLng(43.6, - 79.65), 10);
map.addControl(new GSmallMapControl());
var polygon_Mississauga1 = new GPolygon([
new GLatLng(43.600221867628214, -79.78799343109131),
new GLatLng(43.61414318728641, -79.7578239440918),
new GLatLng(43.63734857969663, -79.72816944122314),
new GLatLng(43.66849246700415, -79.68881607055664),
new GLatLng(43.707965772347045, -79.67156410217285),
new GLatLng(43.73705759025331, -79.63929176330566),
new GLatLng(43.73315055548809, -79.63362693786621),
new GLatLng(43.73401880746534, -79.62727546691895),
new GLatLng(43.670975830331784, -79.57448959350586),
new GLatLng(43.64619968179377, -79.6083927154541),
new GLatLng(43.626818728686395, -79.56384658813477),
new GLatLng(43.5843700152048, -79.54092979431152),
new GLatLng(43.48138690457062, -79.62489366531372),
new GLatLng(43.52272572350131, -79.68160629272461),
new GLatLng(43.508191880679064, -79.69737768173218),
new GLatLng(43.59005851314322, -79.80807781219482),
new GLatLng(43.600221867628214, -79.78799343109131)
], "#7FFF00", 5, 0.5, "#7FFF00", 0.2);
map.addOverlay(polygon_Mississauga1);
var polygon_Brampton1 = new GPolygon([
new GLatLng(43.67476276157896, -79.88880157470703),
new GLatLng(43.72862303765891, -79.83009338378906),
new GLatLng(43.73282495775122, -79.8357367515564),
new GLatLng(43.74161547529797, -79.8232913017273),
new GLatLng(43.73859242702497, -79.81979370117188),
new GLatLng(43.84799142017673, -79.69542503356934),
new GLatLng(43.7510092049126, -79.6402359008789),
new GLatLng(43.748157139226024, -79.63744640350342),
new GLatLng(43.73401880746534, -79.62727546691895),
new GLatLng(43.73315055548809, -79.63362693786621),
new GLatLng(43.73705759025331, -79.63929176330566),
new GLatLng(43.707965772347045, -79.67156410217285),
new GLatLng(43.66849246700415, -79.68881607055664),
new GLatLng(43.63734857969663, -79.72816944122314),
new GLatLng(43.61414318728641, -79.7578239440918),
new GLatLng(43.600221867628214, -79.78799343109131),
new GLatLng(43.67476276157896, -79.88880157470703)
], "#7FFF00", 5, 0.5, "#7FFF00", 0.2);
map.addOverlay(polygon_Brampton1);
var polygon_Caledon1 = new GPolygon([
new GLatLng(43.67476276157896,
-79.88880157470703),
new GLatLng(43.72862303765891,
-79.83009338378906),
new GLatLng(43.73282495775122, -79.8357367515564),
new GLatLng(43.74161547529797, -79.8232913017273),
new GLatLng(43.73859242702497,
-79.81979370117188),
new GLatLng(43.84799142017673,
-79.69542503356934),
new GLatLng(43.97002477969861,
-79.86382484436035),
new GLatLng(43.921204366344426,
-80.08698463439941),
new GLatLng(43.86467097453703,
-80.14389038085938),
new GLatLng(43.67476276157896, -79.88880157470703)
], "#7FFF00", 5, 0.5, "#7FFF00", 0.2);
map.addOverlay(polygon_Caledon1);
GEvent.addListener(polygon_Mississauga1, "mouseover",
function() {
map.removeOverlay(polygon_Mississauga1);
var polygon_Mississauga2 = new GPolygon([
new GLatLng(43.600221867628214,
-79.78799343109131),
new GLatLng(43.61414318728641,
-79.7578239440918),
new GLatLng(43.63734857969663,
-79.72816944122314),
new GLatLng(43.66849246700415,
-79.68881607055664),
new GLatLng(43.707965772347045,
-79.67156410217285),
new GLatLng(43.73705759025331,
-79.63929176330566),
new GLatLng(43.73315055548809,
-79.63362693786621),
new GLatLng(43.73401880746534,
-79.62727546691895),
new GLatLng(43.670975830331784,
-79.57448959350586),
new GLatLng(43.64619968179377,
-79.6083927154541),
new GLatLng(43.626818728686395,
-79.56384658813477),
new GLatLng(43.5843700152048,
-79.54092979431152),
new GLatLng(43.48138690457062,
-79.62489366531372),
new GLatLng(43.52272572350131,
-79.68160629272461),
new GLatLng(43.508191880679064,
-79.69737768173218),
new GLatLng(43.59005851314322,
-79.80807781219482),
new GLatLng(43.600221867628214,
-79.78799343109131)
], "#FFFFFF", 5, 0.8, "#FFFFFF", 0.4);
map.addOverlay(polygon_Mississauga2);
GEvent.addListener(polygon_Mississauga2,
"mouseout", function() {
map.removeOverlay(polygon_Mississauga2);
map.addOverlay(polygon_Mississauga1);
});
GEvent.addListener(polygon_Mississauga2, "click",
function() {
map.removeOverlay(polygon_Mississauga2);
map.removeOverlay(polygon_Mississauga1);
});
});
GEvent.addListener(polygon_Brampton1, "mouseover",
function() {
map.removeOverlay(polygon_Brampton1);
var polygon_Brampton2 = new GPolygon([
new GLatLng(43.67476276157896,
-79.88880157470703),
new GLatLng(43.72862303765891,
-79.83009338378906),
new GLatLng(43.73282495775122,
-79.8357367515564),
new GLatLng(43.74161547529797,
-79.8232913017273),
new GLatLng(43.73859242702497,
-79.81979370117188),
new GLatLng(43.84799142017673,
-79.69542503356934),
new GLatLng(43.7510092049126,
-79.6402359008789),
new GLatLng(43.748157139226024,
-79.63744640350342),
new GLatLng(43.73401880746534,
-79.62727546691895),
new GLatLng(43.73315055548809,
-79.63362693786621),
new GLatLng(43.73705759025331,
-79.63929176330566),
new GLatLng(43.707965772347045,
-79.67156410217285),
new GLatLng(43.66849246700415,
-79.68881607055664),
new GLatLng(43.63734857969663,
-79.72816944122314),
new GLatLng(43.61414318728641,
-79.7578239440918),
new GLatLng(43.600221867628214,
-79.78799343109131),
new GLatLng(43.67476276157896,
-79.88880157470703)
], "#FFFFFF", 5, 0.8, "#FFFFFF", 0.4);
map.addOverlay(polygon_Brampton2);
GEvent.addListener(polygon_Brampton2, "mouseout",
function() {
map.removeOverlay(polygon_Brampton2);
map.addOverlay(polygon_Brampton1);
});
GEvent.addListener(polygon_Brampton2, "click",
function() {
map.removeOverlay(polygon_Brampton2);
});
});
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---