Hello guys,
I have little problem trying to switch Google Maps types. I use very simple code from Google Maps help:
function initialize() {
var mapCent = new google.maps.LatLng(10, 10);
var myOptions = {
zoom: 10,
center: mapCent,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(
document.getElementById("map_canvas"),
myOptions);
}
...
The map works fine, but when I try to switch map type, I get error (Chrome console):
Uncaught ReferenceError: map is not defined
My code of link to switch map type and the function which is inside:
<a href="#" onclick="perekluchitSputnik(); return false;">
function perekluchitSputnik() {
map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
}
What am I doing wrong?