Reputation: 434
I'm trying to figure out how to make my google maps embed default to the "Terrain View" and disable other options like Satellite view and Street View. Can anyone point me in the right direction? Here's my code...
Here's how it currently renders: http://img842.imageshack.us/img842/7299/screenshot20111220at125.png
var map;
var middle_earth_MORADOR = new google.maps.LatLng(38, 0);
function initialize() {
// Define Styles
var styles = [
{
//featureType: "all", elementType: "all", stylers: [ { visibility: "on" }, { hue: "#e5f5fb" } ]
}
];
// Default map options
var mapOptions = {
zoom: 2,
center: middle_earth_MORADOR,
backgroundColor: "#000"
};
var locations = [
<?php foreach ($Projects as $Project) {
$oProjectPhotos = new clsProjectPhotos($Project['idProject']);
$photos = $oProjectPhotos->getProjectPhotos();
echo '["'.$Project["Name"].'", '.$Project["gmapslat"].', '.$Project["gmapslng"].', "'.$Project["CountryName"].'"],';
echo "\n";
echo "\t\t";
}
?>
];
map = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);
var styledMapOptions = {
map: map,
name: "map"
}
var build = new google.maps.StyledMapType(styles,styledMapOptions);
map.mapTypes.set('map', build);
map.setMapTypeId('map');
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});
google.maps.event.addListener(marker, 'mouseover', (function(marker, i) {
return function() {
infowindow.setContent(
'<div>' + locations[i][0] + '</div>'+
'<div>' + locations[i][4] + '</div>'+
'<div>' + locations[i][5] + '</div>'+
'<div>' + locations[i][6] + '</div>'
);
infowindow.open(map, marker);
}
})(marker, i));
}
}
Upvotes: 1
Views: 2426
Reputation: 2755
You can specify the map types those your user can choose:
var mapOptions = {
zoom: 12,
//center: brooklyn,
center: new google.maps.LatLng(-23.565, -46.6565),
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.TERRAIN]
},
mapTypeId: google.maps.MapTypeId.TERRAIN
};
map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
Where mapTypeControlOptions is the type control options, and mapTypeId is the default map type.
Upvotes: 3