> I would question what "mLatLng" is.
I thougt to put the return value of marker.getLatLng() into the variable mLatLng and feed this to map.setCenter(new GLatLng(mLatLng), 16). Sorry about providing the code, but I can not upload the map yet... But of course I can provide the code: <!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>First try of an DMU-AQ station map</title> <script src="http://maps.google.com/maps? file=api&v=2key=ABQIAAAAbhQdLr54KYlWtOWOH_f1RRSphJq-9ndHxPDA4ttR_kd_zY4wsxRN1H6ZooKwSimQhriGA_9NJTZSxQ" type="text/javascript"></script> </head> <body onunload="GUnload()"> <table border=1> <tr> <td> <div id="map" style="width: 700px; height: 600px"></div> </td> <td width = 250 valign="top"> <div id="side_bar"></div> </td> </tr> </table> <script type="text/javascript"> if (GBrowserIsCompatible()) { // this variable will collect the html which will eventually be placed in the side_bar var side_bar_html = ""; // arrays to hold copies of the markers and html used by the side_bar // because the function closure trick doesnt work there var gmarkers = []; var htmls = []; var i = 0; // A function to create the marker and set up the event window function createMarker(point,name,html) { var marker = new GMarker(point); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); map.setCenter(new GLatLng(marker.getLatLng(), 16)); }); // save the info we need to use later for the side_bar gmarkers[i] = marker; htmls[i] = html; // add a line to the side_bar html side_bar_html += '<a href="javascript:myclick(' + i + ')">' + name + '</a><br>'; i++; return marker; } // This function picks up the click and opens the corresponding info window function myclick(i) { gmarkers[i].openInfoWindowHtml(htmls[i]); } // This function picks up the click and zooms to the corresponding marker // create the map var map = new GMap2(document.getElementById("map")); map.setMapType(G_NORMAL_MAP); map.removeMapType(G_SATELLITE_MAP); map.setCenter(new GLatLng(56.170023, 11.502686), 7); // controls map.addControl(new GScaleControl()); map.addControl(new GMapTypeControl()); map.addControl(new GLargeMapControl()); // events map.enableScrollWheelZoom(); map.enableContinuousZoom(); var side_bar_html = ""; // === Define the function thats going to process the text file === process_it = function(doc) { // === split the document into lines === lines = doc.split("\n"); for (var i=0; i<lines.length; i++) { if (lines[i].length > 1) { // === split each line into parts separated by "|" and use the contents === parts = lines[i].split("|"); var lat = parseFloat(parts[0]); var lng = parseFloat(parts[1]); var html = parts[2]; var label = parts[3]; var point = new GLatLng(lat,lng); // create the marker var marker = createMarker(point,label,html); map.addOverlay(marker); } } // put the assembled side_bar_html contents into the side_bar div document.getElementById("side_bar").innerHTML = side_bar_html; } GDownloadUrl("locations.txt", process_it); } // ====== Restricting the range of Zoom Levels ===== // Get the list of map types var mt = map.getMapTypes(); // Overwrite the getMinimumResolution() method for (var i=0; i<mt.length; i++) { mt[i].getMinimumResolution = function() {return 7;} } // Add a move listener to restrict the bounds range GEvent.addListener(map, "move", function() { checkBounds(); }); // The allowed region which the whole map must be within var allowedBounds = new GLatLngBounds(new GLatLng(54.8, 5), new GLatLng(57.88, 15.2)); // If the map position is out of range, move it back function checkBounds() { // Perform the check and return if OK if (allowedBounds.contains(map.getCenter())) { return; } // It`s not OK, so find the nearest allowed point and move there var C = map.getCenter(); var X = C.lng(); var Y = C.lat(); var AmaxX = allowedBounds.getNorthEast().lng(); var AmaxY = allowedBounds.getNorthEast().lat(); var AminX = allowedBounds.getSouthWest().lng(); var AminY = allowedBounds.getSouthWest().lat(); if (X < AminX) {X = AminX;} if (X > AmaxX) {X = AmaxX;} if (Y < AminY) {Y = AminY;} if (Y > AmaxY) {Y = AmaxY;} //alert ("Restricting "+Y+" "+X); map.setCenter(new GLatLng(Y,X)); } </script> </body> </html> Thanks, Thomas --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
