【发布时间】:2011-12-30 14:41:08
【问题描述】:
我有一个包含谷歌地图的 ASP.NET 网站。我正在使用由一些聪明而乐于助人的人制作的 GoogleMapForASPNet 框架。
任何人,我在插入两个图钉后无法居中地图。
基本上,我正在计算图钉的中点并将其设置为地图的中心点。
下面是我的代码:
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;
它工作一半一半,但不正确。比如,当我输入不同的 Pins 时,它并没有真正使地图居中,但足够接近。或者有时,另一个大头针会离开地图,但只有一英寸,这意味着地图根本没有居中。
缩放是静态的,因为大头针总是在附近,所以我不需要让它变成动态的。
非常非常非常感谢任何帮助。
谢谢。
【问题讨论】:
标签: google-maps