谷歌地图API找到角落坐标 [英] Google maps api locate corner coordinates
问题描述
放大
时,有没有一种方法可以找到Google地图角点的坐标值? ,缩小
或转移
地图? 关于我的意思:
在我的Google Maps API代码中,我给出了具体的宽度和高度:
< style>
#map {
width:400px;
height:300px;
}
< / style>
< script src =https://maps.googleapis.com/maps/api/js>< / script>
< div id =map>< / div>
< script>
var mapOptions = {
center:new google.maps.LatLng(37.7831,-122.4039),
zoom:12,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map'),mapOptions);
< / script>
现在,当用户使用滚动浏览地图中的更远或更远的地方时, hight显然保持不变,但是地图上的坐标位于
左上角
右上角角落
左下角
右下角
更改为用户转移地图。我试图找到一种方法来获得这些坐标,但在我的尝试中失败了。
map.getBounds()将返回一个包含地图的北,南,东和西边界的边界对象(如SouthWest,NorthEast)。QUESTION: Is there a way that I could locate what the coordinates are of corner points of the google map each time the I zooms in
, zooms out
, or shift
the map?
ELABORATING ON WHAT I MEAN:
In my google maps api code, I giving the map a specific width and height:
<style>
#map {
width:400px;
height:300px;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map"></div>
<script>
var mapOptions = {
center: new google.maps.LatLng(37.7831, -122.4039),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
</script>
Now when a user uses the scroll the look either further in the map or further out, this width and hight obviously stays the same, however the coordinates on the map located at the
top-left corner
top-right corner
bottom-left corner
bottom-right corner
change as the user shifts the map. I have been trying to find a way to obtain these coordinates but have failed in my attempts.
map.getBounds()
will return a bounds object containing the North, South, East and Western bounds of the map (as SouthWest, NorthEast).
这篇关于谷歌地图API找到角落坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!