지도 내에서 나침반 위치를 변경할 수있는 사람은 누구입니까?Android Google지도 API를 이동하는 방법 나침반 위치
찾을 수있는 것은 how to enable or disable입니다. 하지만 오버레이가 방해하지 않도록 조금 아래로 이동해야합니다.
지도 내에서 나침반 위치를 변경할 수있는 사람은 누구입니까?Android Google지도 API를 이동하는 방법 나침반 위치
찾을 수있는 것은 how to enable or disable입니다. 하지만 오버레이가 방해하지 않도록 조금 아래로 이동해야합니다.
사용 GoogleMap.setPadding() 메소드 :
https://developers.google.com/maps/documentation/android/map#map_padding
난 당신이 나침반 위치를 변경할 수 있지만, 당신이 그것을 해제하고 당신에게 개인 하나를 구축 할 수 있습니다 아시다시피.
+1 흥미 롭습니다. 누군가가 해결 방법을 제시하는지 보자. 그렇지 않으면 크레딧이 모두 당신 것이 아니다. – capdragon
그러나 MapView를 사용하고 있습니다. MapFragment에 대한 아이디어가 있습니까? –
나는 문제가 아니 었 느냐는 오랜 시간이 지났 알고 있지만, 내가 몇 일 전에이 문제에 대한 FELD I 다음과 같이 문제를 해결했습니다.
try {
assert mapFragment.getView() != null;
final ViewGroup parent = (ViewGroup) mapFragment.getView().findViewWithTag("GoogleMapMyLocationButton").getParent();
parent.post(new Runnable() {
@Override
public void run() {
try {
for (int i = 0, n = parent.getChildCount(); i < n; i++) {
View view = parent.getChildAt(i);
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) view.getLayoutParams();
// position on right bottom
rlp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0);
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP,0);
rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
rlp.rightMargin = rlp.leftMargin;
rlp.bottomMargin = 25;
view.requestLayout();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
예 : 오른쪽 구석에 나침반을 넣습니다. 이 작업을 수행 할 때 mapFragment가 작성되었는지 확인해야합니다. MapFragment의 "onMapReady"메소드에서 코드를 실행하는 것이 좋습니다.
인데 이것은 bottm left rof에 배치됩니다! – Paschalis
@Override
public void onMapReady(GoogleMap map) {
try {
final ViewGroup parent = (ViewGroup) mMapView.findViewWithTag("GoogleMapMyLocationButton").getParent();
parent.post(new Runnable() {
@Override
public void run() {
try {
Resources r = getResources();
//convert our dp margin into pixels
int marginPixels = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, r.getDisplayMetrics());
// Get the map compass view
View mapCompass = parent.getChildAt(4);
// create layoutParams, giving it our wanted width and height(important, by default the width is "match parent")
RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(mapCompass.getHeight(),mapCompass.getHeight());
// position on top right
rlp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 0);
rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
//give compass margin
rlp.setMargins(marginPixels, marginPixels, marginPixels, marginPixels);
mapCompass.setLayoutParams(rlp);
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
지도에서 2.0 API.
// change compass position
if (mapView != null &&
mapView.findViewById(Integer.parseInt("1")) != null) {
// Get the view
View locationCompass = ((View) mapView.findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("5"));
// and next place it, on bottom right (as Google Maps app)
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)
locationCompass.getLayoutParams();
// position on right bottom
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
layoutParams.setMargins(0, 160,30, 0); // 160 la truc y , 30 la truc x
}
OMG !!! 고맙습니다!!! – capdragon
매력처럼 작동합니다! – sud007
좋은 해결책이 아니므로 카메라 위치가 –