zoom on api not working

89 views
Skip to first unread message

vic santoro

unread,
Oct 3, 2010, 9:07:06 PM10/3/10
to Google Maps JavaScript API v3
hi, we setup maps api. here is code. i keep changing zoom to show only
united states when page loads, but it doesnt work, zoom works for a
second then zooms right back out to entire world. help please.


<?php include("config.php"); ?>

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 80%; width: 70%; position: absolute; right:
10px; bottom: 10px; }
</style>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
function initialize() {


var myLatlng = new google.maps.LatLng(40.86700,-96.78222);
var myOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}

var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);

var georssLayer = new google.maps.KmlLayer('http://rentmycity.com/
layer.kml?key='+Math.random());
georssLayer.setMap(map);


}


</script>
</head>
<body onLoad="initialize()">
<div id="map_canvas"></div>
</body>
</html>

geoco...@gmail.com

unread,
Oct 4, 2010, 2:07:17 AM10/4/10
to Google Maps JavaScript API v3
On Oct 3, 6:07 pm, vic santoro <vsant...@gmail.com> wrote:
> hi, we setup maps api. here is code. i keep changing zoom to
> show only united states when page loads, but it doesnt work,
> zoom works for a second then zooms right back out to entire
> world. help please.

Sounds like you are looking for the preserveViewport option:
http://groups.google.com/group/google-maps-js-api-v3/search?group=google-maps-js-api-v3&q=preserveViewport&qt_g=Search+this+group


-- Larry
Reply all
Reply to author
Forward
0 new messages