[英]Change marker in Google maps on Android
I'am developing an application that add markers to a map. 我正在开发一个向地图添加标记的应用程序。 But use the default marker is some heavy and show unclear information. 但是使用默认标记会比较沉重并且显示不清楚的信息。 I'd like to add just small points with a number. 我想在数字上加点。 How can I do this? 我怎样才能做到这一点? O found some tutorials to add image in the placer of the default icon of the marker, but I don't thinks that is the case here. O找到了一些教程,以在标记的默认图标的放置器中添加图像,但我认为情况并非如此。
This is the code i'm using now. 这是我现在使用的代码。
Marker marked = mMap.addMarker(new MarkerOptions()
.position(ltlt)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
.title("Numero:" + i)
.snippet("Snippet")
);
My code do this: 我的代码这样做:
I need to do this: 我需要这样做:
This work to me: 这项工作对我来说:
Configure the iconGenerator 配置iconGenerator
IconGenerator iconFactory = new IconGenerator(this);
iconFactory.setContentPadding(0, 0, 0, 0);
iconFactory.setBackground(Drawable.createFromPath("R.drawable.nada.jpg")); // transparent image 10px x 10px
iconFactory.setTextAppearance(R.style.iconGenText);
Style used: 使用的样式:
<style name="iconGenText">
<item name="android:textSize">12sp</item>
<item name="android:textColor">#000000</item>
</style>
and my markeradd: 和我的标记添加:
Marker marked = mMap.addMarker(new MarkerOptions()
.position(ltlt)
.icon(BitmapDescriptorFactory.fromBitmap(iconFactory.makeIcon("" + i)))
.title("Numero:" + i)
.snippet("Snippet")
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.