How to add a satellite view in android studio?
Solution 1
Try with setting the type of map tiles as below
mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
Solution 2
There are four types of maps available within the Google Maps API. In addition to the familiar "painted" road map tiles, the Google Maps API also supports other maps types.
The following map types are available in the Google Maps API:
MapTypeId.ROADMAP
displays the default road map view. This is the default map type.MapTypeId.SATELLITE
displays Google Earth satellite imagesMapTypeId.HYBRID
displays a mixture of normal and satellite viewsMapTypeId.TERRAIN
displays a physical map based on terrain information.
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 MapTypeId.ROADMAP
.
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng location = new LatLng(x,y);
mMap.addMarker(new MarkerOptions().position(ReduitBusStop).title("you are here!"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(location));
mMap.setMapType(mMap.MAP_TYPE_SATELLITE); // Here is where you set the map type
}
Solution 3
Use the below function to set the satellite view
setMapType(com.google.android.gms.maps.GoogleMap.MAP_TYPE_SATELLITE);
Related videos on Youtube
joey
Updated on June 23, 2022Comments
-
joey about 2 years
My map is working fine.However, i want to add a satellite view along with my normal view? How can i achieve that?
public class MainActivity extends FragmentActivity implements OnMapReadyCallback { private GoogleMap mMap; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); } @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; LatLng location = new LatLng(x,y); mMap.addMarker(new MarkerOptions().position(ReduitBusStop).title("you are here!")); mMap.moveCamera(CameraUpdateFactory.newLatLng(location));
-
Leukipp over 6 yearsNote:
MAP_TYPE_SATELLITE
is static. -
Jesus Almaral - Hackaprende almost 4 yearsGreat answer, you have to use GoogleMap.MAP_TYPE instead of mMap.MAP_TYPE