在Google Map v2自定义标记中写入文本-Android
在我的地图中,我有一些标记列表,现在我需要实现如下输出 i、 e.带有索引号的标记 我在谷歌上搜索过,但没有找到任何解决方案,请帮我想一个办法来实现这一点。对于自定义标记:在Google Map v2自定义标记中写入文本-Android,android,google-maps-markers,Android,Google Maps Markers,在我的地图中,我有一些标记列表,现在我需要实现如下输出 i、 e.带有索引号的标记 我在谷歌上搜索过,但没有找到任何解决方案,请帮我想一个办法来实现这一点。对于自定义标记: 您可以创建一个自定义图像和绘图索引编号 那个图像 请检查此示例以了解更多信息 对于标记窗口: 您可以创建一个自定义的xml文件,其中包含ImageView和textview: 类似于customMapView.xml: <RelativeLayout xmlns:android="http://schemas.an
- 您可以创建一个
和自定义图像
索引编号 那个绘图
图像
- 请检查此示例以了解更多信息
xml
文件,其中包含ImageView
和textview
:
类似于customMapView.xml
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/white_full"
android:layout_width="match_parent"
android:padding="@dimen/padding_micro"
android:layout_height="match_parent">
<ImageView
android:id="@+id/img"
android:layout_gravity="left"
android:src="@drawable/ic_launcher"
android:textColor="@color/black_full"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:gravity="right"
android:id="@+id/name"
android:text="test"
android:textColor="@color/black_full"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- Other TextViews or Whatever you want-->
</RelativeLayout>
用谷歌地图标记做任何你想做的事
我已经做了一个非常灵活和有趣的黑客实现任何类型的标记你想要的
我所做的是
感谢您提供custommarker链接。这提供了一个线索,以获得解决方案:)请问你是如何做的图标与数字?Thanks@ItuokeAjanlekoko首先将标记转换为位图,然后使用绘画和画布在标记上书写数字。
private void customizeMarkerInfoWindow(){
//Setting custom info window
mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
//Use default infoWindow frame
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
// Getting view from the layout file
View view = mActivity.getLayoutInflater().inflate(R.layout.customMapView, null);
// Getting the position from the marker
LatLng latLng = marker.getPosition();
//UI elements
ImageView img = (TextView) view.findViewById(R.id.img);
TextView coord = (TextView) view.findViewById(R.id.name);
mukAdTv.setText(mukAd);
//You set the image here depending on how you want to set it, if you are downloading from internet you can use PICASSO for it and set it to img
//With picasso
Picasso.with(mActivity).load(YOUR_IMAGE_URL).into(img);
//From drawables
//img.setBackground(yourDrawable);
name.setText(latLng.latitude + ", " + latLng.longitude);
return view;
}
});
}