我有这样的代码:Android的谷歌地图添加标记自己的标记
protected void onPostExecute(final ArrayList<HashMap<String, String>> adapter) {
for (final HashMap<String, String> a : adapter) {
LatLng pos = new LatLng(Double.valueOf(a.get(TAG_latitude)), Double.valueOf(a.get(TAG_longitude)));
Log.e("pppppos", String.valueOf(pos.latitude));
Marker m = map.addMarker(new MarkerOptions().position(pos)
.title(a.get(TAG_NAME))
.snippet("Kiel is cool"));
map.setOnInfoWindowClickListener(
new OnInfoWindowClickListener(){
public void onInfoWindowClick(Marker marker){
Intent nextScreen = new Intent(SearchExchangerActivity.this, BankExchangersListActivity.class);
nextScreen.putExtra("exchanger_id", id);
startActivityForResult(nextScreen, 0);
}
});
}
但是发送额外的信息给其他的时候,我需要设置为不可见,以用户字段例如Tag_id
每个标记,并用这个ID,然后在活动,如:
protected void onPostExecute(final ArrayList<HashMap<String, String>> adapter) {
for (final HashMap<String, String> a : adapter) {
LatLng pos = new LatLng(Double.valueOf(a.get(TAG_latitude)), Double.valueOf(a.get(TAG_longitude)));
Marker m = map.addMarker(new MarkerOptions().position(pos)
.title(a.get(TAG_NAME))
.snippet("Kiel is cool")
.Tag_id(TAG_ID));
map.setOnInfoWindowClickListener(
new OnInfoWindowClickListener(){
public void onInfoWindowClick(Marker marker){
Intent nextScreen = new Intent(SearchExchangerActivity.this, BankExchangersListActivity.class);
nextScreen.putExtra("exchanger_id", marker.get(TAG_ID));
startActivityForResult(nextScreen, 0);
}
});
}
是真的吗?我怎么能在听众中得到我点击的标记?
而且它可以通过标题字段来实现......但我发现了错误的书写marker.getTitle()
时...
UPD
for (final HashMap<String, String> a : adapter) {
LatLng pos = new LatLng(Double.valueOf(a.get(TAG_latitude)), Double.valueOf(a.get(TAG_longitude)));
Log.e("pppppos", String.valueOf(pos.latitude));
HashMap<Marker, String> m = new HashMap<Marker, String>();
m.put(map.addMarker(new MarkerOptions().position(pos)
.title(a.get(TAG_NAME))
.snippet("Kiel is cool")), "1");
}
map.setOnInfoWindowClickListener(
new OnInfoWindowClickListener(){
public void onInfoWindowClick(HashMap<Marker, String> marker){
Intent nextScreen = new Intent(SearchExchangerActivity.this, BankExchangersListActivity.class);
nextScreen.putExtra("exchanger_id", "1");
startActivityForResult(nextScreen, 0);
}
});
你能给例如使用地图<打标,串>的? – 2013-05-05 14:55:50
当我尝试写地图<标记,字符串> M = m.put(map.addMarker(新的MarkerOptions()。位置(POS) \t \t \t \t .title伪(a.get(TAG_NAME)) \t \t \t (“Kiel is cool”)),“1”); \t东西不好 – 2013-05-05 15:07:14
@ValdisAzamaris请看这里使用'Map'解决方法:http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 – 2013-05-05 15:26:46