Google maps 谷歌地图添加图层
我开始开发一个应用程序,将谷歌地图 我研究了谷歌地图Api的帮助,我怀疑是否需要添加一个覆盖。以下是正确的方法: 创建地图Google maps 谷歌地图添加图层,google-maps,google-maps-api-3,Google Maps,Google Maps Api 3,我开始开发一个应用程序,将谷歌地图 我研究了谷歌地图Api的帮助,我怀疑是否需要添加一个覆盖。以下是正确的方法: 创建地图 function initialize() { var mapOptions = { center: new google.maps.LatLng(-34.397, 150.644), zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
}
添加重载:
function add() {
var myLatlng = new google.maps.LatLng(-34.397, 150.646);
var mapOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
}
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); /* It is correct?
var marker = new google.maps.Marker({
position: myLatlng,
title:"Hello World!"
});
marker.setMap(map);
};
有没有办法获取映射选项,或者更确切地说,没有完全重新获取映射,或者是这样做的?在
初始化()中创建映射时,删除var
-关键字
执行此操作时,map
-变量是全局可访问的,您可以调用marker.setMap(map)代码>内部添加()
,而不创建新的映射实例