Code: Select all
<script type="text/javascript">
var map = null;
var geocoder = null;
var latlngbounds = new GLatLngBounds( );
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
<?php if(!isset($_POST['viewed'])){
echo 'map.setCenter(new GLatLng(36.879621, -95.537109), 2);';}
else
{
echo 'function fitMap( GMap2, points ) {
var bounds = new GLatLngBounds();
for (var i=0; i< points.length; i++) {
bounds.extend(points[i]);
}
map.setZoom(map.getBoundsZoomLevel(bounds));
map.setCenter(bounds.getCenter());
}';
fitMap();
}
?>
map.addControl(new GLargeMapControl());
geocoder = new GClientGeocoder();
}
}
I'm trying to use this guy's code, but I can't implement it right:
Code: Select all
function fitMap( map, points ) {
var bounds = new GLatLngBounds();
for (var i=0; i< points.length; i++) {
bounds.extend(points[i]);
}
map.setZoom(map.getBoundsZoomLevel(bounds));
map.setCenter(bounds.getCenter());
}
I'm fairly well-versed with PHP, but Java is very new to me. Sorry for the long post, but I'd appreciate any help.
[EDIT: SOLVED]
I fixed this using this code: http://econym.org.uk/gmap/basic14.htm
I also changed
Code: Select all
var latlngbounds = new GLatLngBounds( );Code: Select all
var bounds = new GLatLngBounds( );