【发布时间】:2014-05-26 07:35:43
【问题描述】:
从数据库到脚本和加载到脚本的地图纬度和经度值工作正常,但地图没有显示
这是脚本
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
<div id="map_canvas" style="width: 270px; height: 267px;">
</div>
警报显示值 10.52722212213278, 76.20814598432844
但地图没有加载
如果你知道这个请分享答案
【问题讨论】:
标签: javascript html map