Hi,
I added a Google Maps API to a Silverstripe site - it works well in Internet Explorer, but not in Firefox. At first I thought that this is a Google API problem, but the code works if I take it out of the Silverstripe context. So I guess that the problem is either a Google/Silverstripe Javascript conflict or the Google API is not completely downloaded for some reason. But I may be completely wrong.
The link to the temporary development site is e.g.:
http://clients.nugob.org/sginz/a-test-event-with-map/#map
Below is the Google API code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
<head>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAgDhSzdPEyxxJiKPLQn6uGxTI_RQfTzmVDUbcO_9FMUYPBP_s7RQKyu8bt9LN14YdoCf9TzkKwbkKTw" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
var map = null;
var geocoder = null;
function initialize_map() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("MapHolder"));
var address = "40 eaglehurst rd auckland";
map.setCenter(new GLatLng(-36.805032,174.752523), 14);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
geocoder = new GClientGeocoder();
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " not found");
} else {
map.setCenter(point, 14);
var marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml("<b>Test Event</b><br />24/09/2008 10:00am<br />SGI NZ Culture Centre Auckland<br />40 Eaglehurst Rd, Ellerslie, Auckland");
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml("<b>Test Event</b><br />24/09/2008 10:00am<br />SGI NZ Culture Centre Auckland<br />40 Eaglehurst Rd, Ellerslie, Auckland");
});
}
}
)
}
}
}
//]]>
</script>
</head>
<body onload="initialize_map()" onunload="GUnload()">
<div id="MapHolder" style="height: 400px;"></div>
</body>
</html>
This code is just copied out of the generated Silverstripe html source code. It works by itself: http://clients.nugob.org/sginz/maptest.html
But it does not work in Firefox with the complete Silverstripe source code. The error message I get is "GMap2 is not defined". There is quite some information on that error message in Google Maps API forums, but the point is that Firefox itself can not be the problem.
If anyone could give me a hint I would be very grateful.
Cheers!
Anatol