本文介绍了kmlLayer导致焦点更改(google map api v3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将NOAA雷达信息分层放置在焦点为8的地图上.页面加载后,地图最初以8渲染,然后立即重新绘制自身以显示整个区域.

I'm layering NOAA radar information over a map with a focus of 8. When the page loads, the map initially renders at 8, then immediately redraws itself to show an entire region.

我正在使用的KML文件包含用于绘制雷达图像的最小/最大纬度/经度坐标(本例中为美国东南部地区).如果我更改这些坐标以覆盖较小的区域,则可以按照我的意愿调整Google地图的大小,但会根据KML文件裁剪雷达活动.如果用户缩小或滚动到默认地图区域之外,这将是一个问题.

The KML file I'm using contains min/max lat/long coordinates which are used to draw the radar image (in this case over the southeast US area). If I change those coordinates to cover a smaller area, the google map is resized like I want, but radar activity is clipped per the KML file. This is a problem if users zoom out or scroll outside of the default map area.

示例地图: http://georgiaoffroad.com/map2.html

示例KML文件: http://georgiaoffroad.com/includes/southeastradar.kml

是否有办法使雷达图像保持较大,但将地图聚焦在可用雷达图像的较小区域上,以便用户可以缩放或滚动查看周围地区的天气?

Is there a way to keep the radar image large, but focus the map on a smaller area of the available radar image so users could zoom or scroll around to see weather for surrounding areas?

推荐答案

将图层的选项preserveViewport设置为true:

set the option preserveViewport of the layer to true:

new google.maps
     .KmlLayer({url:'http://georgiaoffroad.com/includes/southeastradar.kml',
                preserveViewport:true});

这篇关于kmlLayer导致焦点更改(google map api v3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 19:45