GoogleMaps中更改标记文字

GoogleMaps中更改标记文字

本文介绍了在Android GoogleMaps中更改标记文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置完GoogleMap标记后是否可以更改文本?我现在使用MarkerOptions来设置标题和摘要,如下所示:

Is it possible to change the text inside a GoogleMap Marker after it's already been set? I'm using MarkerOptions to set the title and snippet originally like this:

SupportMapFragment theMapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
GoogleMap theMap = theMapFragment.getMap();
MarkerOptions theMarker = new MarkerOptions();
theMarker.position(theLatLng);
theMarker.title("My title");
theMarker.snippet("This is my snippet");
theMarker.visible(true);
theMap.addMarker(theMarker);

稍后,当用户点击某些内容时,我想执行反向地址解析查询,并更改标题/代码段以包含地址信息.

Later, when the user taps on something, I'd like to perform the reverse geocode lookup and change the title/snippet to contain address information.

推荐答案

Marker 具有 setTitle() setSnippet()方法.您将需要一个表示该标记的 Marker 对象,可能是您在 addMarker()调用中保留的对象.

Marker has setTitle() and setSnippet() methods. You will need a Marker object representing this marker, probably one that you held onto from the addMarker() call.

这篇关于在Android GoogleMaps中更改标记文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 02:04