Android 인스턴스 SDK 및 OffscreenRenderer를 사용하여지도 인스턴스를 렌더링합니다.여기 Android SDK OffscreenRenderer MapOverlay가 표시되지 않습니다.
MapOverlay를 사용하여 맞춤 버블보기를 그립니다. 내가 매뉴얼에서 설명하는 방법 객체 MapOverlay 추가 할 수 있습니다 (활동 내에서 MapFragment가와) 일반적으로 렌더링지도를 들면 다음과 같습니다
Button button = new Button(this);
button.setText("TEST");
myMap.addMapOverlay(new MapOverlay(button, destination));
으로 MapFragment를 들어이 잘 작동하지만, OffscreenRenderer 내가지도에 버튼이 표시되지 않습니다. 위의 다양한보기, 부풀린 레이아웃 및 단순한 버튼 코드를 시도했지만 모두 OffscreenRenderer가 아닌 일반지도에서 작동하는 것으로 보입니다. 이 기능은 SDK에서 사용할 수 있습니까? 어떻게 보이게 할 수 있습니까?
업데이트 : addMapOverlay가 true를 반환합니다. 업데이트 2 :
제안 된 해결 방법은 작업 코드 샘플을 게시하십시오. 우리는 view (view-shot =)에서 screen-shot을 가져 와서 MapMarker를 만들어야합니다.
public MapMarker makeTargetSmallBubbleMarker(Route route, Address address) {
// obtain view
View v = inflater.inflate(R.layout.info_bubble_small, null);
// get the value..
String destination = "";
// inflate value into view sub fields
((TextView) v.findViewById(R.id.destination)).setText(destination);
// if you use 9-patch bubble with donwside arrow for background of your marker
// you need to change anchor point of the marker, so that the arrow will point to location
// instead of bubble appears above the destination
// maybe someone knows a better solution..? Calculate rendered view size
v.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
int width = v.getMeasuredWidth();
int height = v.getMeasuredHeight();
// make view screen-shot
Image bubbleImg = new Image();
bubbleImg.setBitmap(loadBitmapFromView(v, width, height));
MapMarker bubble = new MapMarker(route.getDestination(), bubbleImg);
// here, I want my bubble arrow and whole marker get a 20% offset for down arrow
bubble.setAnchorPoint(new PointF(width/2f, height * 1.2f));
return bubble;
}
private static Bitmap loadBitmapFromView(View v, int width, int height) {
Bitmap b = Bitmap.createBitmap(width , height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
//v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
v.layout(0, 0, width, height);
v.draw(c);
return b;
}
네, 그게 효과가 있습니다. 지금 제안한대로 작동하는 코드 샘플로 내 질문을 업데이트했습니다. –
샘플을 가져 주셔서 감사합니다! –