【问题标题】:How to change map type from simple to satellite of PlacePicker from Google Places API?如何从 Google Places API 将地图类型从简单更改为 PlacePicker 的卫星?
【发布时间】:2017-04-08 05:05:03
【问题描述】:

我在我的应用程序中使用PlacePicker API,并希望将其地图类型从简单更改为卫星。

PlacePicker 是 Google 提供的 API。

这是我的使用方法:

// Construct an intent for the place picker
                try {
                    PlacePicker.IntentBuilder intentBuilder =
                            new PlacePicker.IntentBuilder();
                    Intent intent = intentBuilder.build(this);
                    // Start the intent by requesting a result,
                    // identified by a request code.
                    startActivityForResult(intent, PLACE_PICKER_REQUEST);

                } catch (GooglePlayServicesRepairableException e) {
                    Snackbar snackbar = Snackbar
                            .make(coordinatorLayout, e.getMessage(), Snackbar.LENGTH_SHORT);
                    snackbar.show();
                    // ...
                } catch (GooglePlayServicesNotAvailableException e) {
                    Snackbar snackbar = Snackbar
                            .make(coordinatorLayout, e.getMessage(), Snackbar.LENGTH_SHORT);
                    snackbar.show();
                    // ...
                }

然后在onActivityResult():

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == PLACE_PICKER_REQUEST
                && resultCode == Activity.RESULT_OK) {

            // The user has selected a place. Extract the name and address.
            final Place place = PlacePicker.getPlace(data, this);

            final CharSequence name = place.getName();
            final CharSequence address = place.getAddress();
            LatLng latLng = place.getLatLng();
            final double lat = latLng.latitude;
            final double lng = latLng.longitude;
            String attributions = PlacePicker.getAttributions(data);
            if (attributions == null) {
                attributions = "";
            }

//            mViewName.setText(name);
//            mViewAddress.setText(address);
//            mViewAttributions.setText(Html.fromHtml(attributions));

        } else {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }

它只显示简单的地图类型。我想显示卫星类型的地图。

请告诉我怎么做?

【问题讨论】:

  • 我认为没有给出这样的选项。因为如果您看到有关此的文档,则在任何地方都没有提到有关地点 api 的地图类型。知道这是否可能很有趣。

标签: java android google-maps android-studio google-places-api


【解决方案1】:

目前无法在 Place Picker 中更改地图类型。您可以在 Place API 的 public issue tracker 上添加功能请求。

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-01-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多