如何获取地理代码更改侦听器Yandex mapkit android?
我使用yandex mapkit尝试获得准确的Latling,但它绘制准确,但未获取侦听器失败我使用了链接,但侦听器未调用如何在每个点移动时获取侦听器 谢谢,如何获取地理代码更改侦听器Yandex mapkit android?,android,geocode,yandex,yandex-maps,Android,Geocode,Yandex,Yandex Maps,我使用yandex mapkit尝试获得准确的Latling,但它绘制准确,但未获取侦听器失败我使用了链接,但侦听器未调用如何在每个点移动时获取侦听器 谢谢, Shabeer Mohamed如果您想在点击地图上的某个点后对其进行地理编码,则需要执行以下操作 扩展覆盖类并实现GeoCodeListener public class GeoCodeOverlay extends Overlay implements GeoCodeListener { public GeoCodeOverl
Shabeer Mohamed如果您想在点击地图上的某个点后对其进行地理编码,则需要执行以下操作
public class GeoCodeOverlay extends Overlay implements GeoCodeListener {
public GeoCodeOverlay(MapController mapController) {
super(mapController);
}
@Override
public boolean onFinishGeoCode(final GeoCode geoCode) {
if (geoCode != null) {
getMapController().getMapView().post(new Runnable() {
@Override
public void run() {
// show display name of the point
Toast.makeText(getMapController().getContext(),
geoCode.getDisplayName(), Toast.LENGTH_LONG).show();
}
});
}
return true;
}
@Override
public boolean onSingleTapUp(float x, float y) {
getMapController().getDownloader()
.getGeoCode(this, getMapController().getGeoPoint(new ScreenPoint(x, y)));
return true;
}
}
public class GeoCoderActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_geo_coder);
final MapView mapView = (MapView) findViewById(R.id.map);
mapView.getMapController().getOverlayManager()
.getMyLocation().setEnabled(true);
mapView.getMapController().getOverlayManager()
.addOverlay(new GeoCodeOverlay(mapView.getMapController()));
}
}
activity\u geo\u coder.xml
。别忘了添加API密钥
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.mapkittest.GeoCoderActivity">
<ru.yandex.yandexmapkit.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="PLACE_YOUR_API_HERE"
/>
</RelativeLayout>