mapview를 사용하여 몇 명의 사용자 위치를 표시합니다. 여기에 나열된 방법 중 하나를 사용하여지도 확대/축소 수준을 적절히 설정하여 모든 핀을 표시합니다.MapView가 전체 화면을 가져 오지 않습니다.
하지만 문제는 필자가 핀이 세계 곳곳에있을 때 확대/축소 레벨이 초과되어 mapview의 위와 아래에이 공백이 생기는 것입니다.
이 문제를 해결할 수있는 방법이 있습니까?지도 그리드에서 색상 대신 해당 영역을 채우기 만하면됩니다. 여기에 사진 및 XML
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="#061a2f"
android:clickable="true" android:apiKey=""/>
API 키가 debig 인증서되지는지도보기에만 그리드를 보여줍니다 이유 때문이다. 하지만 공백을 볼 수 있습니다. 확대하면 변경됩니다. 줌 로직을 확인해야합니까? 최대 축소가 여전히 사용 가능한 공간을 채울 것이라고 생각했습니다.
나는 그것이 확대와 관련이 있다고 생각한다. Google 워드 프로세서에서. 위도와 경도의 주어진 범위가 표시 될 수 있도록
zoomToSpan
시도는지도의 줌을 조정합니다. 줌은 만 이산 레벨을 달성 할 수 있기 때문에 맵 의 종횡비가 주어진 비율과 일치하지 않을 수 있기 때문에 적합의 품질이 다를 수 있습니다. 우리가 보증하는 것은 줌 후, 새로운 위도 또는 새로운 경도 중 하나가 에서 해당 매개 변수의 2 배가된다는 것입니다.
나는 종횡비가 문제라고 생각합니다. 더 신뢰할 수있는 방법이 있나요? 여기 내 자바 코드입니다.
for(Visitor visitor:mVisitors){
LiveMapOverlay overlay = new LiveMapOverlay(new
PinDrawable(mContext,color),mMapView);
GeoPoint point = new GeoPoint(
(int)(Double.valueOf(visitor.visitorInfo.latitude) * 1E6)
,(int)(Double.valueOf(visitor.visitorInfo.longitude) * 1E6));
minLatitude = minLatitude < point.getLatitudeE6() ? minLatitude :
point.getLatitudeE6();
maxLatitude = maxLatitude > point.getLatitudeE6() ? maxLatitude :
point.getLatitudeE6();
minLongitude = minLongitude< point.getLongitudeE6()? minLongitude:
point.getLongitudeE6();
maxLongitude = maxLongitude> point.getLongitudeE6()? maxLongitude:
point.getLongitudeE6();
}
mMapView.getController().setCenter(new GeoPoint((maxLatitude + minLatitude)/2 ,
(minLongitude + maxLongitude)/2));
mMapView.getController().zoomToSpan(maxLatitude - minLatitude, maxLongitude -
minLongitude);
내지도보기는 채우기 부모로 속성이있는 선형 레이아웃 안에 있습니다. 나는 XML에 그 것을 포함하지 않았다. – blessenm