自定义标记选项在谷歌地图 [英] Custom Marker Options in google map
本文介绍了自定义标记选项在谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以在Google中制作Custom MarkerOptions吗?
我想使用Custom MarkerOptions在对话框中显示图像,如
$
解决方案
您必须使用 setInfoWindowAdapter
GoogleMap
类的方法。
GoogleMap mMap; //你必须初始化它。
mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter(){
@Override
public View getInfoWindow(Marker marker){
return null;
}
@Override
public View getInfoContents(标记标记){
/ *
在这里你将夸大你想用于标记的自定义布局。根据我的要求定制视图
* /
View v = getLayoutInflater()。inflate(R.layout.custom_marker_info_window,null);
TextView textView =(TextView)v.findViewById(R .id.text);
textView.setSelected(true);
textView.setText(poiPlayerData.getName());
return v;
}
}) ;
Can we make Custom MarkerOptions in google?
I want to use Custom MarkerOptions to show image in Dialog box like Containng Name as title, and two image within it.
<ImageView
android:id="@+id/badge"
android:layout_width="18dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:src="@drawable/image_2"
android:adjustViewBounds="true"></ImageView>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="20dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:ellipsize="end"
android:text="harish"
android:singleLine="true"
android:textColor="#ff000000"
android:textSize="7dp"
android:textStyle="bold" />
<ImageView
android:id="@+id/snippet"
android:layout_width="10dp"
android:layout_height="10dp"
android:ellipsize="end"
android:src="@drawable/icon_location2"
android:singleLine="true"
android:textColor="#ff7f7f7f"
android:textSize="14dp" />
</LinearLayout>
With default MarkerOption i can only get Title , Snippet in dialog box like this:
public void addMarkersToMap() {
mArun = mMap.addMarker(new MarkerOptions()
.position(ARUN)
.title("Arun")
.snippet("Match stat:")
.icon(BitmapDescriptorFactory.defaultMarker
(BitmapDescriptorFactory.HUE_AZURE)));
help me with some suggestion .
解决方案
You will have to use the setInfoWindowAdapter
method of GoogleMap
class.
GoogleMap mMap;//You have to initialise it.
mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
/*
Here you will inflate the custom layout that you want to use for marker. I have inflate the custom view according to my requirements.
*/
View v = getLayoutInflater().inflate(R.layout.custom_marker_info_window, null);
TextView textView = (TextView) v.findViewById(R.id.text);
textView.setSelected(true);
textView.setText(poiPlayerData.getName());
return v;
}
});
这篇关于自定义标记选项在谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文