Question - Google maps width
by spiderplant0
HTML
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false"></script>
<body onload="initialize()">
<div id="controls"
style="position: absolute; left: 10px; top 15px;
font-weight: bold;">
<a href="#" onclick="getMapDetails();">
getMapDetails</a></div>
<div id="map_canvas"
style="position: absolute; top: 35px; left: 0;
width:800px; height:500px;"></div>
<div id="results"
style="position: absolute; left: 0; top: 540px; "></div>
</body>
JavaScript
var map;
function initialize() {
map = new google.maps.Map(
document.getElementById("map_canvas"), {
zoom: 1,
center: new google.maps.LatLng(54.976, -2.021),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
}
function getMapDetails(){
var bounds = map.getBounds();
var center = map.getCenter();
var stg =
"sw=(" + bounds.getSouthWest().lat().toFixed(2) +
"," + bounds.getSouthWest().lng().toFixed(2) +
") ne=(" + bounds.getNorthEast().lat().toFixed(2) +
"," + bounds.getNorthEast().lng().toFixed(2) +
") dimensions=" + (bounds.getNorthEast().lat() -
bounds.getSouthWest().lat()).toFixed(2) +
"x"+ (bounds.getNorthEast().lng() -
bounds.getSouthWest().lng()).toFixed(2) +
" bounds-center=(" + ((bounds.getNorthEast().lat() +
bounds.getSouthWest().lat())/2).toFixed(2) +
"," + ((bounds.getNorthEast().lng() +
bounds.getSouthWest().lng())/2).toFixed(2) +
") getCenter=("+ center.lat().toFixed(2) +
"," + center.lng().toFixed(2) +
")<br>";
document.getElementById("results").innerHTML += stg;
}