出于某种原因,我无法在Google地图上显示标记 - 地图本身加载正常 - 它只是我缺少的标记。我试着移动所有的代码,以防万一它是一个范围问题,到目前为止还没有运气。谷歌地图不显示标记
$(document).ready(function ($) {
var myLatLng = new google.maps.LatLng(document.getElementById('Latitude').value, document.getElementById('Longitude').value);
var marker = new google.maps.Marker({ position: myLatLng, visible: true });
function init_map() {
var myOptions = {
zoom: 14,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("gmap_canvas"), myOptions);
marker.setMap(map);
$(window).resize(function() {
google.maps.event.trigger(map, 'resize');
});
$('#accordion > .panel').on('show.bs.collapse', function (e) {
google.maps.event.trigger(map, 'resize');
google.maps.event.addListener(marker, "click", function() { infowindow.open(map, marker); });
var heading = $(this).find('.panel-heading');
heading.addClass("active-panel");
});
$('#accordion > .panel').on('hidden.bs.collapse', function (e) {
var heading = $(this).find('.panel-heading');
heading.removeClass("active-panel");
google.maps.event.trigger(map, 'resize');
google.maps.event.addListener(marker, "click", function() { infowindow.open(map, marker); });
})
}
google.maps.event.addDomListener(window, 'load', init_map);
});
请创建一个小提琴,标志代码看起来是正确的 - 猜测LAT长的部分不能正常工作。 –
https://jsfiddle.net/w8ekcjj8/ –
你的小提琴HTML不包含任何“纬度”或“经度”元素 – duncan