Javascript 负载图Lon&;html内部的Lat脚本不起作用
从数据库到脚本和加载到脚本的映射lat&lon值工作正常,但映射未显示 这是剧本Javascript 负载图Lon&;html内部的Lat脚本不起作用,javascript,html,map,Javascript,Html,Map,从数据库到脚本和加载到脚本的映射lat&lon值工作正常,但映射未显示 这是剧本 var geocoder; var map; function initialize() { geocoder = new google.maps.Geocoder(); var loc= document.getElementById('loc'); alert(loc.innerHTML); var latlng = new google.maps.LatLng('+loc+'); var myOption
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var loc= document.getElementById('loc');
alert(loc.innerHTML);
var latlng = new google.maps.LatLng('+loc+');
var myOptions = {
zoom: 8,
center: latlng,
mapTypeControl: false,
mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
navigationControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
if (geocoder) {
geocoder.geocode( { }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
map.setCenter(results[0].geometry.location);
var infowindow = new google.maps.InfoWindow(
{
size: new google.maps.Size(150,50)
});
var marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title:address
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
} else {
}
} else {
}
});
}
}
HTML
警报显示的值为10.52722212213278、76.20814598432844
但是地图没有加载
如果您知道这一点,请分享答案替换此
var latlng = new google.maps.LatLng("Lat", "Long");
借
如代码所示,添加带有两个独立坐标的行,即“Lat”、“Long”
var latlng = new google.maps.LatLng("Lat", "Long");
var loc= document.getElementById('loc'); //Remove This
var latlng = new google.maps.LatLng('+loc+'); //Remove This