(紧急求救)关於android google map 既java问题(marker snippet)
时间:2014-01-10
来源:互联网
想问下如果用marker 既snippet去打一d资料
好似
final LatLng place = new LatLng(100,-100);<----呢个我系随便打
Marker place1 = mMap.addMarker(new MarkerOptions()
.position(place)
.title("A restaurant")
.snippet("Open time"));
我想出黎既野如果系
Open time
Mon - Fri 9am - 11pm
Sat 12am - 6pm
Sun close
咁可以点打
因为试过
.snippet("Open time")
.snippet("Mon - Fri 9am - 11pm")
.snippet(" Sat 12am - 6pm")
.snippet(" Sun close")
佢显示就剩系得个Sun close
如果.snippet("Open time"+"Mon - Fri 9am - 11pm"+" Sat 12am - 6pm"+" Sun close")
又会变做Open time Mon - Fri 9am - 11pm Sat 12am - 6pm Sun close
点可以令佢隔行或者定系唔同snippet而用其他command??
[ 本帖最后由 petroscheung 於 2013-12-5 09:34 AM 编辑 ]
好似
final LatLng place = new LatLng(100,-100);<----呢个我系随便打
Marker place1 = mMap.addMarker(new MarkerOptions()
.position(place)
.title("A restaurant")
.snippet("Open time"));
我想出黎既野如果系
Open time
Mon - Fri 9am - 11pm
Sat 12am - 6pm
Sun close
咁可以点打
因为试过
.snippet("Open time")
.snippet("Mon - Fri 9am - 11pm")
.snippet(" Sat 12am - 6pm")
.snippet(" Sun close")
佢显示就剩系得个Sun close
如果.snippet("Open time"+"Mon - Fri 9am - 11pm"+" Sat 12am - 6pm"+" Sun close")
又会变做Open time Mon - Fri 9am - 11pm Sat 12am - 6pm Sun close
点可以令佢隔行或者定系唔同snippet而用其他command??
[ 本帖最后由 petroscheung 於 2013-12-5 09:34 AM 编辑 ]
作者: petroscheung 发布时间: 2014-01-10
佢本身title及snippet都只容许一行.
如果想改变佢预设方式,要自订info window adapter.
e.g. 假设你用番你现时activity或fragment做你个adapter及预备一个layout file.
...
map.setInfoWindowAdapter(this);
...
LAYOUT FILE: map_info.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
androidrientation="horizontal">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="2dip"
android:src="@drawable/ic_launcher"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android
rientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"/>
<TextView
android:id="@+id/snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
你个activity/fragment 要implements InfoWindowAdapter, 会有两个method
@Override
public View getInfoContents(Marker marker) {
View v = this.getLayoutInflater(null).inflate(R.layout.map_info_window , null);
// set 番D title 及 snippet
TextView txtTitle = (TextView) v.findViewById( R.id.title );
tvTitle.setText( marker.getTitle() );
TextView txtSnippet = (TextView) v.findViewById( R.id.snippet );
tvSnippet.setText( marker.getSnippet() );
return v;
}
@Override
public View getInfoWindow(Marker arg0) {
// TODO Auto-generated method stub
return null;
}
用左 textview, 你可以用 \n 做每行分隔,e.g.
marker.setTitle("Title 1\nTitle 2\nTitle 3");
marker.setSnippet("line 1\nline2\nline3");
既然infowindow用左layout file,玩唛花款随你喜欢.

[ 本帖最后由 laputafish 於 2013-12-7 03:35 PM 编辑 ]
如果想改变佢预设方式,要自订info window adapter.
e.g. 假设你用番你现时activity或fragment做你个adapter及预备一个layout file.
...
map.setInfoWindowAdapter(this);
...
LAYOUT FILE: map_info.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
androidrientation="horizontal">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="2dip"
android:src="@drawable/ic_launcher"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"/>
<TextView
android:id="@+id/snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
你个activity/fragment 要implements InfoWindowAdapter, 会有两个method
@Override
public View getInfoContents(Marker marker) {
View v = this.getLayoutInflater(null).inflate(R.layout.map_info_window , null);
// set 番D title 及 snippet
TextView txtTitle = (TextView) v.findViewById( R.id.title );
tvTitle.setText( marker.getTitle() );
TextView txtSnippet = (TextView) v.findViewById( R.id.snippet );
tvSnippet.setText( marker.getSnippet() );
return v;
}
@Override
public View getInfoWindow(Marker arg0) {
// TODO Auto-generated method stub
return null;
}
用左 textview, 你可以用 \n 做每行分隔,e.g.
marker.setTitle("Title 1\nTitle 2\nTitle 3");
marker.setSnippet("line 1\nline2\nline3");
既然infowindow用左layout file,玩唛花款随你喜欢.

[ 本帖最后由 laputafish 於 2013-12-7 03:35 PM 编辑 ]
作者: laputafish 发布时间: 2014-01-10
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28