我在这个问题上需要帮助,请
我正在尝试将Google Map
缩放级别设置为 15 ,但这会导致地图无法完全呈现,而是呈现为灰色区域
这是地图的截图,以明白我的意思
这是我的代码:
<script type="text/javascript">
var geocoder;
var map;
var markersArray = [];
function initialize() {
geocoder = new google.maps.Geocoder();
var zoomLevel = 6;
//(38.5923884129755, 31.0229229927063)39.86619, 35.44768
var latlng = new google.maps.LatLng(38.5923884129755, 31.0229229927063);
var mapOptions = {
zoom: zoomLevel,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById('GoogleMap_Div'), mapOptions);
google.maps.event.addListener(map, 'click', function(event) {
addMarker(event.latLng);
});
var hdnZoom = $("input[id$='hdnZoom']")[0];
var hdnLocation = $("input[id$='hdnLocation']")[0];
if (hdnZoom && hdnLocation) {
setMarker(hdnZoom.value, hdnLocation.value);
}
}
function setMarker(zoom, location) {
if (zoom && zoom != '' && location && location != '') {
var loc = location.split(",");
var latlng = new google.maps.LatLng(loc[0].substring(1), loc[1].substring(0, (loc[1].length - 1)));
if (latlng) {
addMarker(latlng)
}
map.setZoom(parseInt(zoom)); //zoom = 15
}
}
function addMarker(location) {
clearOverlays();
var hdnZoom = $("input[id$='hdnZoom']")[0];
if (hdnZoom) {
hdnZoom.value = map.getZoom();
}
var hdnLocation = $("input[id$='hdnLocation']")[0];
if (hdnLocation) {
hdnLocation.value = location;
}
marker = new google.maps.Marker({
position: location,
map: map
});
markersArray.push(marker);
}
如果缩放级别小于或等于8,此代码可以正常工作。
答案 0 :(得分:0)
未完全渲染的地图不是由缩放级别引起的,请检查您的latlng