Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 负载图Lon&;html内部的Lat脚本不起作用_Javascript_Html_Map - Fatal编程技术网

Javascript 负载图Lon&;html内部的Lat脚本不起作用

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

从数据库到脚本和加载到脚本的映射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 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