Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change map type from simple to satellite of PlacePicker from Google Places API?

I'm using PlacePicker API in my app and want to change it's map type from simple to satellite.

PlacePicker is an API offered by Google.

Here's how I'm using it:

// 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();
                    // ...
                }

and then in 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);
        }
    }

It only shows the simple map type. I want to show satellite type map.

Please let me know how to?

like image 379
Hammad Nasir Avatar asked Nov 24 '16 02:11

Hammad Nasir


People also ask

What is a maptype object in the API?

The API uses a MapType object to hold information about these maps. A MapType is an interface that defines the display and usage of map tiles and the translation of coordinate systems from screen coordinates to world coordinates (on the map).

How do I modify the map type in use by the map?

You modify the map type in use by the Map by setting its mapTypeId property, either within the constructor via setting its Map options object, or by calling the map's setMapTypeId () method. The mapTypeID property defaults to roadmap.

How do I find the map mode in Google Earth?

Try searching or browse recent questions. Community content may not be verified or up-to-date. Learn more. There isn't really a 'map' mode in Google Earth.

How are map types displayed in mappane?

All map types (base and overlay) are rendered within the mapPane layer. Overlay map types will display on top of the base map they are attached to, in the order in which they appear in the Map.overlayMapTypes array (overlays with higher index values are displayed in front of overlays with lower index values).


1 Answers

It's not currently possible to change the map type in Place Picker. You can add a feature request on the Place API's public issue tracker.

like image 61
AndrewR Avatar answered Oct 02 '22 14:10

AndrewR