Marcelo,
Thanks for your response - and your tolerance of an amateur!!
I can see what you mean but I can't work out how to implement it with
my limited knowledge!!
Below is my code, cobbled together from various different sources, but
it works and displays the infoWindow and the Polygons.
What I want to do is to show all the markers all of the time and the
polygons only when a marker is clicked on (or hovered over if at all
possible...)
var iconBlue = new GIcon();
iconBlue.image = 'images/mm_20_lblue.png';
iconBlue.shadow = 'images/mm_20_shadow.png';
iconBlue.iconSize = new GSize(12, 20);
iconBlue.shadowSize = new GSize(22, 20);
iconBlue.iconAnchor = new GPoint(6, 20);
iconBlue.infoWindowAnchor = new GPoint(5, 1);
var customIcons = [];
customIcons["<?php echo $year; ?>"] = iconBlue;
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(<?php echo $latlong; ?>), 14);
GDownloadUrl("get-xml.php", function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName
("photo");
var coords =
xml.documentElement.getElementsByTagName("photo");
for (var i = 0; i < markers.length; i++) {
var FilmFrame = markers[i].getAttribute("FilmFrame");
var Year = markers
[i].getAttribute("Year");
var PhotoDate = markers[i].getAttribute("PhotoDate");
var North = markers[i].getAttribute("N");
var South = markers[i].getAttribute("S");
var West = markers[i].getAttribute("W");
var East = markers[i].getAttribute("E");
var point = new GLatLng
(parseFloat(markers[i].getAttribute("Lat")),
parseFloat(markers[i].getAttribute("Lon")));
var polygons = new GPolygon([
new GLatLng(North, West),
new GLatLng(North, East),
new GLatLng(South, East),
new GLatLng(South, West),
new GLatLng(North, West)
], "#444444", 2, 1, "#000000",
0);
var marker =
createMarker(point, FilmFrame, Year, PhotoDate);
map.addOverlay(marker);
map.addOverlay(polygons);
}
});
}
}
function createMarker(point, FilmFrame, Year, PhotoDate) {
var marker = new GMarker(point, customIcons[Year]);
var html = "<font face=verdana size=2>Frame Ref.: " + FilmFrame
+ "<br/>Year: " + Year + "<br/>Taken On: " + PhotoDate + "</font>";
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindow(html);
});
return marker;
}
Suggestions welcome!!
-Andrew
On 22 Oct, 18:45, Marcelo <[email protected]> wrote:
> On Oct 22, 6:14 pm, Andyroo1000 <[email protected]>
> wrote:
>
>
>
> > Does anyone know of any way of doing this?
>
> hmmm ...I wonder if anyone knows.
> You happen to be in a group dedicated to the Google Maps API, so I'd
> put my money on a "yes" for an answer to that question. ;-)
>
> You could add the polygon to its marker as a property, and then add a
> click event handler that opens the infoWindow, (not speech bubble),
> and in that same event handler toggle the polygon with something like
>
> if (marker.polygon.isHidden()) {}
> marker.polygon.show();
> marker.openIngoWindow(html);}
>
> else {
> marker.polygon.hide();
> map.closeInfoWindow();
>
> }
>
> Of course you'd need to pass the relevant content of the html variable
> to the function that creates the marker and attaches the event
> listener.
>
> --
> Marcelo -http://maps.forum.nu
> --
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---