例如,我想有一个图像和TextVIEw作为标记(不是d出窗口,而是标记本身).
我一直在使用谷歌地图工具库在谷歌地图上使用群集,但他们只是有一些例子,如何使用背景的常规白色标记(example)
让我们说我想要他们有什么,除了周围的白板.
你知道我怎么能做到这一点?
提前致谢.
编辑:
我正在尝试将this tutorial与Google Maps Utility library(Clusters)结合使用.
现在我有这个,但是没有用:
custom_cluster_marker_layout.xml
<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" > <ImageVIEw androID:ID="@+ID/image" androID:layout_wIDth="55dp" androID:layout_height="65dp" androID:src="@drawable/cluster" /> <TextVIEw androID:ID="@+ID/num_txt" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_marginleft="19dp" androID:layout_margintop="10dp" androID:gravity="center" androID:text="0" androID:textcolor="#ce8223" androID:textSize="25dp" androID:textStyle="bold" /></relativeLayout>
MeterRender.java
private class MeterRenderer extends DefaultClusterRenderer<MyMeter> { private TextVIEw mClusterTextVIEw; public MeterRenderer() { super(c,map,mClusterManager); VIEw custom_cluster_vIEw = ((LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.custom_cluster_marker_layout,null); mClusterTextVIEw = (TextVIEw) custom_cluster_vIEw.findVIEwByID(R.ID.num_txt); } @OverrIDe protected voID onBeforeClusterItemRendered(MyMeter meter,MarkerOptions markerOptions) { markerOptions.icon(BitmapDescriptorFactory .fromPath(createBillboardTexture("a","123"))); } @OverrIDe protected voID onBeforeClusterRendered(Cluster<MyMeter> cluster,MarkerOptions markerOptions) { VIEw custom_cluster_vIEw = ((LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.custom_cluster_marker_layout,null); mClusterTextVIEw = (TextVIEw) custom_cluster_vIEw.findVIEwByID(R.ID.num_txt); mClusterTextVIEw.setText(cluster.getSize()); markerOptions.icon(BitmapDescriptorFactory.fromBitmap(createDrawableFromVIEw(c,custom_cluster_vIEw))); } public Bitmap createDrawableFromVIEw(Context context,VIEw vIEw) { displayMetrics displayMetrics = new displayMetrics(); ((Activity) context).getwindowManager().getDefaultdisplay().getMetrics(displayMetrics); vIEw.measure(displayMetrics.wIDthPixels,displayMetrics.heightPixels); vIEw.layout(0,displayMetrics.wIDthPixels,displayMetrics.heightPixels); vIEw.buildDrawingCache(); Bitmap bitmap = Bitmap.createBitmap(vIEw.getMeasureDWIDth(),vIEw.getMeasuredHeight(),Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); vIEw.draw(canvas); return bitmap; }}解决方法 您可能已经在地图中添加了Marker,因此请尝试使用Marker而不是MarkerOptions
@OverrIDeprotected voID onBeforeClusterItemRendered(MyMeter meter,Marker marker) { marker.setIcon(BitmapDescriptorFactory .fromPath(createBillboardTexture("a","123")));}@OverrIDeprotected voID onBeforeClusterRendered(Cluster<MyMeter> cluster,Marker marker) { VIEw custom_cluster_vIEw = ((LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.custom_cluster_marker_layout,null); mClusterTextVIEw = (TextVIEw) custom_cluster_vIEw.findVIEwByID(R.ID.num_txt); mClusterTextVIEw.setText(cluster.getSize()); marker.setIcon(BitmapDescriptorFactory.fromBitmap(createDrawableFromVIEw(c,custom_cluster_vIEw))); }总结
以上是内存溢出为你收集整理的android – 在布局XML中定义的谷歌地图标记全部内容,希望文章能够帮你解决android – 在布局XML中定义的谷歌地图标记所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)