0
我有一個包含Google地圖的ASP.NET網站。我正在使用由一些聰明且有幫助的人員製作的GoogleMapForASPNet框架。根據針腳定位Google地圖
Anywho,我插入兩個引腳後居中地圖的問題。
基本上,我正在計算引腳的中點並將其設置爲地圖的中心點。
下面是我的代碼:
GooglePoint newPoint = new GooglePoint();
double newLat = 0;
double newLong = 0;
if (googlePointA.Latitude > googlePointB.Latitude)
{
newLat = googlePointA.Latitude - googlePointB.Latitude;
newPoint.Latitude = googlePointA.Latitude - newLat;
}
else
{
newLat = googlePointB.Latitude - googlePointA.Latitude;
newPoint.Latitude = googlePointB.Latitude + newLat;
}
if (googlePointA.Longitude > googlePointB.Longitude)
{
newLong = googlePointA.Longitude - googlePointB.Longitude;
newPoint.Longitude = googlePointA.Longitude - newLong;
}
else
{
newLong = googlePointB.Longitude - googlePointA.Longitude;
newPoint.Longitude = googlePointB.Longitude + newLong;
}
GoogleMapForASPNet1.GoogleMapObject.CenterPoint = newPoint;
GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 8;
它的工作原理各佔一半,但不正確。就像在我喂飼不同的引腳時,它並不是真正將地圖居中,但足夠接近。或者有時候,另一個銷將離開地圖,但只有一英寸,這意味着地圖根本不居中。
變焦是靜態的,因爲引腳總是靠近,所以沒有必要讓它變成動態的。
任何幫助是非常,非常,非常感激。
謝謝。
呃。我正在使用一個名爲GoogleMapForASPNet的預先構建的框架。我在這裏下載它:http://www.shabdar.org/asp-net/70-google-maps-control-for-aspnet-part-1.html 所以我必須使用它的內置函數。顯然,它沒有LatLngBounds。 所以...我該如何做到這一點?有了這個框架。 – Subby 2011-12-30 15:23:31
alcfeoh。我100%肯定,我沒有得到正確結果的唯一原因是因爲如果我的計算。不是因爲沒有使用Google的其他API或其他東西... – Subby 2011-12-30 15:33:52