Can you post a link to the page so we can see the generated source code? That'd make it a million times easier.
The tutorial page here shows the technique you need to use though: http://econym.org.uk/gmap/basic14.htm Martin. On 21 Oct, 22:38, vanner <[email protected]> wrote: > I have some api code to pull co-ords (and other data) from our > database and display as markers on a map, this all works but I want it > to move to the center of the co-ordinates and zoom in > > I have read up on GLatLngBounds which looks like what I need, but I > can't figure out how to integrate it into my code (I only do php > coding and not really javascript) > > my code is:- > > $sql="SELECT id, Name, Town, Submitted, ImageUrl, XCoord, YCoord, > FROM test WHERE County='$County'"; > $resultmap = $db->sql_query($sql); > > echo "<table border=\"0\" width=\"600\" height=\"600\" id=\"table1\"> > <tr> > <td align=\"center\"> > > <script > src=\"http://maps.google.com/maps? > file=api&v=2&key=$apikey\" type=\"text/javascript\"></script> > > <div id=\"map\" style=\"width: 600; > height: 600; color:black\"></ > div ><br /> > > <script type=\"text/javascript\"> > //<![CDATA[ > > var icon = new GIcon(); > icon.image = > \"modules/Database/icons/marker.png\"; > icon.iconSize = new GSize(25, 25); > icon.iconAnchor = new GPoint(9, 20); > icon.infoWindowAnchor = new GPoint(9, > 2); > icon.infoShadowAnchor = new > GPoint(18, 25); > > function > createMarker(point,html,style) > { > // FF 1.5 fix > html = '<div align=\"left\" > style=\"white-space:nowrap;\">' + > html + '</div>'; > icon.image = > 'modules/Database/icons/' + style + '.png'; > var marker = new > GMarker(point, icon); > GEvent.addListener(marker, > \"click\", function() > {marker.openInfoWindowHtml(html);}); > return marker; > } > > function loadMap() > { > var map = new > GMap2(document.getElementById(\"map\")); > map.setCenter(new > GLatLng(53.69670647530323,-3.8232421875), > 6); > map.addControl(new GLargeMapControl()); > map.addControl(new GMapTypeControl()) > map.addControl(new GScaleControl()); > map.addControl(new GOverviewMapControl()); > > // Hides the info windows when the map is clicked > GEvent.addListener(map, \"click\", function(marker, point){ > if (!marker) { > map.closeInfoWindow(); > } > }); > > // This is where we add the > list of users to the map > "; > > if ( $row = > $db->sql_fetchrow($resultmap) ) > { > do > { > if ( > $row['XCoord'] == "") > { > // No > location > } > else > { > $Name > = $row['Name']; > > $Submitted = $row['Submitted']; > $id = > $row['id']; > > $PhotoLink1 = $row['ImageUrl']; > > if($PhotoLink1!='') { > > $userpic = "http://www.test.com/images/" . $row['ImageUrl']; > } > else { > > $userpic=''; > } > $Town > = $row['Town']; > > $TelephoneNumber = $row['TelephoneNumber']; > > $Details = "http://www.test.com&id=$id"; > > > $XCoord = $row['XCoord']; > > $YCoord = $row['YCoord']; > > if > (!preg_match("/[.]/", $XCoord)) { > $XCoord = > stripslashes($row['XCoord']); > list($degrees,$minutes,$seconds) = > explode(" ", > $XCoord); > $minutesconverted=$minutes*60; > > $totalseconds=$minutesconverted+$seconds; > > $totalsecondsconverted=$totalseconds/3600; > $totalsecondsrounded = > number_format($totalsecondsconverted, 6, ".", ","); > $degrees += 0; > list($rubbish,$totalsecondsrounded) = > explode(".",$totalsecondsrounded); > $DecimalXCoord="$degrees" . "." . > "$totalsecondsrounded"; > } else { > $DecimalXCoord = $XCoord; > } > > if (!preg_match("/[.]/", $YCoord)) { > $YCoord = > stripslashes($row['YCoord']); > list($degrees,$minutes,$seconds) = > explode(" ", > $YCoord); > $minutesconverted=$minutes*60; > > $totalseconds=$minutesconverted+$seconds; > > $totalsecondsconverted=$totalseconds/3600; > $totalsecondsrounded = > number_format($totalsecondsconverted, 6, ".", ","); > $degrees += 0; > list($rubbish,$totalsecondsrounded) = > explode(".",$totalsecondsrounded); > $DecimalYCoord="$degrees" . "." . > "$totalsecondsrounded"; > } else { > $DecimalYCoord = $YCoord; > } > > > $userlat = $DecimalXCoord; > > $userlong = $DecimalYCoord; > > // > Remove bad chars from the name and location > $Name > = htmlspecialchars($Name, ENT_QUOTES); > $Town > = htmlspecialchars($Town, ENT_QUOTES); > > $Submitted = htmlspecialchars($Submitted, ENT_QUOTES); > > $TelephoneNumber = htmlspecialchars($TelephoneNumber, > ENT_QUOTES); > > // Setup the marker colour > $iconstyle="marker"; > > if > ($username==$Submitted) { > > $modlink = "<a href=\"test&op=modify&id=$id\"><img src=/ > images/book_edit.gif align=\"absmiddle\" border=0 title=\"Edit $Name > \"></a>"; > } > elseif(is_deputyadmin($user)) { > > $modlink = "<a href=\"test&op=modify&id=$csid\"><img > src=modules/Campsites/images/book_edit.gif align=\"absmiddle\" > border=0 title=\"Edit $Name\"></a>"; > } > else { > > $modlink=''; > } > > > if($userpic!='') { > > $markertext = "<table border=\"0\" width=\"300\" cellspacing= > \"0\" cellpadding=\"0\" id=\"mapinfo\"><tr><td width=\"80\" valign= > \"top\"><img width=\"80\" border=\"0\" src=\"$userpic\" align=\"left > \"></td>"; > > $markertext.= "<td>Type: <b>$Type</b><br>"; > > $markertext.= "Name:<b>$Name</b><br>"; > > $markertext.= "Town: <b>$Town</b><br>"; > > $markertext.= "Phone:<b>$TelephoneNumber</b><br>"; > > $markertext.= "Submitted: <b>$Submitted</b><br>"; > > $markertext.= "Full Details: <b><a target=blank.html href= > $Details>Click HERE</a><br>"; > > $markertext.= "$modlink</td></tr></table>"; > } > else { > > $markertext = "<table border=\"0\" width=\"300\" cellspacing= > \"0\" cellpadding=\"0\" id=\"mapinfo\"><tr><td>Type: <b>$Type</ > b><br>Name:<b>$Name</b><br>Town: <b>$Town</b><br>Phone: <b> > $TelephoneNumber</b><br>Submitted By: <b>$Submitted</b></td></tr></ > table>"; > } > > echo > "var point = new GPoint($userlong, $userlat);"; > echo > "var marker = createMarker(point, '$markertext', > '$iconstyle' , 'tooltip');"; > echo > "map.addOverlay(marker);"; > } > } > > while ( $row = > $db->sql_fetchrow($resultmap) ); > } > > echo " > } > > // arrange for our onload handler to > 'listen' for onload events > if (window.attachEvent) > { > > window.attachEvent(\"onload\", function() > { > loadMap(); // > Internet Explorer > } > ); > } > else > { > > window.addEventListener(\"load\", function() > { > loadMap(); // Firefox > and standard browsers > }, false); > } > //]]> > </script> > </td> > </tr> > </table> > "; -- You received this message because you are subscribed to the Google Groups "Google Maps API V2" 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.
