从Google地图返回标记数据到应用程序



是否可以让单击事件打开Google Maps应用程序,供用户设置标记并将标记信息返回应用程序?

我正在创建一个listView和列表项,请单击我要打开Google Maps应用程序,用户可以将标记放置,然后将标记返回到该应用程序中以存储在DB中。

是的,您可以尝试使用此代码。

int PLACE_PICKER_REQUEST = 1;
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);

您可以访问OnActivityResult方法的位置

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == PLACE_PICKER_REQUEST) {
    if (resultCode == RESULT_OK) {
        Place place = PlacePicker.getPlace(data, this);
        String toastMsg = String.format("Place: %s", place.getName());
        Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
    }
  }
}

有关更多详细信息,请检查place picker的Android开发人员文档

最新更新