Category Archives: Google Maps

Geocode google map address

Easy job if you have the address.

[php]

function geocode_googlemap_address($address){
$link = "http://maps.google.com/maps/api/geocode/xml?address=".$address."&sensor=false";
$file = simplexml_load_file($link);
if(!$file)  {
echo "Err: No access to Google service: ".$a."<br/>n";
}else {
if ($file->status == "OK") {
$lat = (float) $file->result->geometry->location->lat;
$long = (float) $file->result->geometry->location->lng;
echo $lat.",".$long;
}else{
//echo "Err: address not found: ".$a."<br/>n";
}
}
}

[/php]

Change map type

To change the map type when initializing the map:

[js]
$(‘#map_canvas’).gmap( {
‘zoom’: 3,
‘center’: new google.maps.LatLng(my_lat, my_lng),
‘callback’: function(map) {
$(‘#map_canvas’).gmap(‘option’, ‘mapTypeId’, google.maps.MapTypeId.TERRAIN);
//rest of the code
}
});
[/js]