home *** CD-ROM | disk | FTP | other *** search
- if (GBrowserIsCompatible()) {
-
- var docmap = document.getElementById("map");
- var map = new GMap2(docmap);
- var iFocused = -1;
-
- // ====== Restricting the range of Zoom Levels =====
- // Get the list of map types
- var mt = map.getMapTypes();
- // Overwrite the getMinimumResolution() and getMaximumResolution() methods
- for (var i = 0; i < mt.length; i++) {
- mt[i].getMinimumResolution = function() { return 2; }
- //mt[i].getMaximumResolution = function() { return 11; }
- }
-
- map.addControl(new GLargeMapControl());
- map.addControl(new GMapTypeControl());
-
- // ==== It is necessary to make a setCenter call of some description before adding markers ====
- // ==== At this point we dont know the real values ====
- map.setCenter(new GLatLng(0,0),0);
-
- //window.alert(qsParm['file']);
- var side_bar_html = "";
- var gmarkers = [];
- var htmls = [];
- var i = 0;
-
-
- function createMarker(point,name,html,focused) {
- var gicon;
- if (focused == 1)
- gicon = new GIcon(G_DEFAULT_ICON, "images/icon_focused_photo.png");
- else
- gicon = new GIcon(G_DEFAULT_ICON, "images/icon_photo.png");
-
- gicon.iconSize = new GSize(18,17);
- gicon.shadow = "images/icon_photo_shadow.png";
- gicon.shadowSize = new GSize(28,17);
- var marker = new GMarker(point, gicon);
- GEvent.addListener(marker, "click", function() {
- marker.openExtInfoWindow(
- map,
- "custom_info_window",
- html,
- { beakOffset: 3 }
- );
- });
- gmarkers[i] = marker;
- htmls[i] = html;
- i++;
- return marker;
- }
-
-
- // ===== Start with an empty GLatLngBounds object =====
- var bounds = new GLatLngBounds();
-
-
- function myclick(i) {
-
- // ===== determine the zoom level from the bounds =====
- map.setZoom(map.getBoundsZoomLevel(bounds));
-
- // ===== determine the centre from the bounds ======
- map.setCenter(bounds.getCenter());
-
- //
- gmarkers[i].openExtInfoWindow(
- map,
- "custom_info_window",
- htmls[i],
- { beakOffset: 3 }
- );
- }
-
- // Read the data from example.xml
- var request = GXmlHttp.create();
- var fullURL = parent.document.URL;
- var infoXML = fullURL.substring(fullURL.indexOf('?') + 3, fullURL.length);
- request.open("GET", infoXML, true);
- request.onreadystatechange = function() {
- if (request.readyState == 4) {
- var xmlDoc = GXml.parse(request.responseText);
- // obtain the array of markers and loop through it
- var markers = xmlDoc.documentElement.getElementsByTagName("marker");
-
- for (var i = 0; i < markers.length; i++) {
- // obtain the attribues of each marker
- var lat = parseFloat(markers[i].getAttribute("lat"));
- var lng = parseFloat(markers[i].getAttribute("lng"));
- var point = new GLatLng(lat, lng);
- var html = markers[i].getAttribute("html");
- var label = markers[i].getAttribute("label");
- var focused = markers[i].getAttribute("focused");
- if (focused == 1)
- iFocused = i;
- // create the marker
- var marker = createMarker(point, label, html, focused);
- map.addOverlay(marker);
-
- // ==== Each time a point is found, extent the bounds ato include it =====
- bounds.extend(point);
- }
-
- //document.getElementById("side_bar").innerHTML = side_bar_html;
-
- // ===== determine the zoom level from the bounds =====
- var zoomlevel = map.getBoundsZoomLevel(bounds);
- if (zoomlevel > 9)
- zoomlevel = 9;
- map.setZoom(zoomlevel);
-
- // ===== determine the centre from the bounds ======
- map.setCenter(bounds.getCenter());
-
-
- }
- }
- request.send(null);
-
- if (iFocused >= 0)
- myclick(iFocused);
- }
-
- // display a warning if the browser was not compatible
- else {
- alert("Sorry, the Google Maps API is not compatible with this browser");
- }
-
-
-
-
-