Google지도가 포함 된 ASP.NET 웹 사이트가 있습니다. 일부 영리하고 도움이되는 개인이 만든 GoogleMapForASPNet 프레임 워크를 사용하고 있습니다.핀에 따라 Google지도 중앙 정렬
두 개의 핀을 삽입 한 후지도를 가운데에 배치하는 데 문제가 있습니다.
기본적으로 핀의 중간 지점을 계산하여지도의 중심점으로 설정하고 있습니다.
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;
그것은 절반의 절반을 작동하지만 제대로 :
다음은 내 코드입니다. 마찬가지로, 내가 다른 핀을 먹이로, 그것은 정말로지도를 중심으로하지 않지만 충분히 가깝습니다. 또는 때로는 다른 핀이 맵에서 벗어나지 만 1 인치 만됩니다. 즉,지도가 전혀 가운데에 있지 않습니다.
핀이 항상 가까이 있기 때문에 확대/축소가 고정되어 있으므로 동적으로 만들 필요가 없습니다.
모든 도움은 극도로, 극단적으로 높이 평가됩니다.
감사합니다.
Erm. GoogleMapForASPNet이라는 사전 제작 된 프레임 워크를 사용하고 있습니다. 여기에서 다운로드했습니다 : http://www.shabdar.org/asp-net/70-google-maps-control-for-aspnet-part-1.html 그래서 내장 함수를 사용해야합니다. 그리고 분명 LatLngBounds가 없습니다. 그럼 ... 어떻게해야합니까? 이 프레임 워크. – Subby
alcfeoh. 나는 올바른 계산 결과를 얻지 못하는 유일한 이유는 100 % 내 계산 때문입니다. Google의 다른 API 또는 다른 것을 사용하지 않기 때문에가 아니라 ... – Subby