I'm trying to use maps in my CMS but I'm very new to the Google Maps
API. I'd like the map to load based on a an address geocoded from a
PHP variable. I've figured it out in v2 but I'd prefer to do it in
v3. Based on the code found in <a href="http://code.google.com/apis/
maps/documentation/v3/services.html#Geocoding">this tutorial</a> ,
I've come up with the following which sort of works - it loads the
LatLng map first, then loads mine - but I know it's not right.
<script type="text/javascript">
<?php
$address = '1 california'.'San Francisco, CA';
?>
var geocoder;
var map;
var address = "<?php echo $address; ?>";
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-33.397, 150.644);
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);
}
});
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
</script>
And here's a link
<a href="http://stacefelder.com/maptest.php">http://stacefelder.com/
maptest.php</a>
I'm guessing this is one of those stupid fixes but I think I've been
staring at it too long and I can't figure it out. All thoughts and
suggestions welcomed.
Thanks
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.