如何在不按下红色标记的情况下设置地址自动显示?粘贴 下面是我的javascript代码。拜托,我真的需要你的帮助。我真的 与代码混淆,真的希望你们能帮助我。谢谢你这么 得多。
var map;
map = new GMaps({
el: '#gmap2',
lat: 1.289701,
lng: 103.812879,
scrollwheel: false,
zoom: 18,
zoomControl: true,
panControl: true,
streetViewControl: true,
mapTypeControl: true,
overviewMapControl: true,
clickable: true
});
var image = '';
map.addMarker({
lat: 1.289701,
lng: 103.812879,
icon: image,
animation: google.maps.Animation.DROP,
verticalAlign: 'bottom',
horizontalAlign: 'center',
backgroundColor: '#d3cfcf',
});
var styles =[
{
"featureType": "road",
"stylers": [
{"color": "#ffffff"}
]
}, {
"featureType": "water",
"stylers": [
{"color": "#99b3cc"}
]
}, {
"featureType": "landscape",
"stylers": [
{"color": "#f2efe9"}
]
}, {
"elementType": "labels.text.fill",
"stylers": [
{"color": "#d3cfcf"}
]
}, {
"featureType": "poi",
"stylers": [
{"color": "#ded2ac"}
]
}, {
"elementType": "labels.text",
"stylers": [
{"saturation": 1},
{"weight": 0.1},
{"color": "#000000"}
]
}
];
map.addStyle({
styledMapName: "Styled Map",
styles: styles,
mapTypeId: "map_style"
});
map.setStyle("map_style");
}());
}
答案 0 :(得分:0)
我从这篇文章中提取答案,所以不是我最初的想法:Google maps-api v3 InfoWindow automatically open on page load
看起来您可以创建一个单独的方法(在此示例中称为initialize
)。此方法将创建一个新的infoWindow
并在页面加载时加载它。
var infoWindow = null;
function initialize()
{
infoWindow = new google.maps.InfoWindow();
var windowLatLng = new google.maps.LatLng(43.25,-68.03);
infoWindow.setOptions({
content: "<div>This is the html content.</div>",
position: windowLatLng,
});
infoWindow.open(map);
} // end initialize
google.setOnLoadCallback(initialize);