Reputation: 522
When you are on google maps, there's a button like this
You use it to change the type of map you're viewing, and as you move it updates where you are.
I'm developing an android app and I'm using google maps, now I'm using a simple button to change the type of the map, but I'd like to know if it's possible to add a button like this with the same behavior on my app.
EDIT
What I really want is to have a button that shows the live satellite as the google maps does, as you can see in the picture.
Upvotes: 0
Views: 1210
Reputation: 418
On button Click set this line to change normal to satellite.
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
Upvotes: 1
Reputation: 3511
To change map types on button click in google maps, add mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
on your button. Example:
maps.xml
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onNormalMap"
android:text="Normal" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onSatelliteMap"
android:text="Satellite" />
Now add the following methods in your activity file which.
public void onNormalMap(View view) {
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
public void onSatelliteMap(View view) {
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
}
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
to show normal google map. mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
to show google satellite map. mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
to show terrain google map. mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
to show hybrid google map.
Upvotes: 0