私は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 =)から取り出し、そこから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;
}
はい、それは機能しました。あなたの提案通りに動作するコードサンプルで質問を更新しました。 –
サンプルをいただきありがとうございます! –