Simple android program using GOOGLE MAP API

前端 未结 2 1313
故里飘歌
故里飘歌 2021-01-28 10:03

Trying to work on Google Map\'s

  • Its my first program in using google Map API
  • I am not able to execute because of log error
  • Where i need to corr
2条回答
  •  春和景丽
    2021-01-28 11:00

    You have to declare fragment class of map in your xml layout as below: Which is used to load the GoogleMap in your fragment.

    Have your referred Add a Map in your Application ?

    
    

    EDITED:

    The error is because your application contains the API level below 12 . And Please note that the code below is only useful for testing your settings in an application targeting Android API 12 or later, Below code should not be used in a production application.

          googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    

    So instead try as below:

       mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                    .getMap();
    

提交回复
热议问题