- Joined
- Dec 15, 2011
- Messages
- 3,407
I am displaying a map when the address is present in the db.
If I get the map using onclick (I would prefer an automatic render) it displays just fine.
If I get it using body onload, it displays the bottom-right-hand-corner in the top-left-hand-corner of the container
The js functions called to perform the displays are here...
here's the body onload...
and here's the onclick...
which is echo'd out - hence the escaping chars.
Any insights would be appreciated...
If I get the map using onclick (I would prefer an automatic render) it displays just fine.
If I get it using body onload, it displays the bottom-right-hand-corner in the top-left-hand-corner of the container
The js functions called to perform the displays are here...
HTML:
<script type="text/javascript">
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-26.204102800000000000, 28.047305100000017000);
var myOptions = {
zoom: 12,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
function codeAddress() {
var address = document.getElementById("address").value;
geocoder.geocode({'address': address},function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
</script>
HTML:
<body onLoad="javascript:preloader();initialize();codeAddress();">
HTML:
<input type=\"button\" value=\"Generate Map\" onclick=\"initialize();codeAddress();\">
Any insights would be appreciated...