Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a satellite view in android studio?

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));
like image 829
joey Avatar asked Dec 18 '15 04:12

joey


People also ask

How can I view satellite on Android?

Open the Maps app on your Android smartphone or tablet and tap your profile icon in the top-right corner. Next, select “Settings” from the menu. Scroll down and toggle the switch for “Start Maps in Satellite View.”

What is mapview Android studio?

A View which displays a map (with data obtained from the Google Maps service). When focused, it will capture keypresses and touch gestures to move the map.


2 Answers

Try with setting the type of map tiles as below

        mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
like image 153
SachinS Avatar answered Oct 06 '22 10:10

SachinS


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 images
  • MapTypeId.HYBRID displays a mixture of normal and satellite views
  • MapTypeId.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
}
like image 23
Mr Robot Avatar answered Oct 06 '22 10:10

Mr Robot