Nik*_*las 0 html javascript google-maps-api-3
我的谷歌地图标记不会第一次加载(但它确实以地址为中心),除非我将以下代码添加到底部...
marker.setPosition(latlng);
Run Code Online (Sandbox Code Playgroud)
为什么会这样?在我测试的FF,IE和Chrome等所有浏览器中都是一样的
谢谢你的帮助.
var geocoder;
var map;
var marker;
function initialize(){
//MAP
var latlng = new google.maps.LatLng('xxxxx','xxxxx');
var options = {
zoom: 16,
center: latlng,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
map = new google.maps.Map(document.getElementById("map_canvas"), options);
//GEOCODER
geocoder = new google.maps.Geocoder();
markerImg = google.maps.MarkerImage({
url: "newIcon.png"
});
marker = new google.maps.Marker({
map: map,
icon: markerImg,
draggable: true
});
;
}
$(document).ready(function() {
initialize();
etc
Run Code Online (Sandbox Code Playgroud)
marker = new google.maps.Marker({
map: map,
icon: markerImg,
draggable: true,
position: latlng
});
Run Code Online (Sandbox Code Playgroud)
在构建标记时,您没有为标记提供任何位置.
| 归档时间: |
|
| 查看次数: |
582 次 |
| 最近记录: |