Use Google Maps API MapView without permission

↘锁芯ラ 提交于 2019-12-20 05:23:27

问题


Does anyone know if it's possible to use the Google Maps API for Android's MapView without giving it location permission? I just want to render a map and place a marker on it. I am not asking for the user's location in any way.

I cannot use the MapFragment because I am housing this view inside another Fragment, and nested fragments aren't supported until Android 4.2.


回答1:


Per the specify Android permissions section:

The following location permissions are recommended, but you can omit them if your application doesn't access the user's current location, either programmatically or by enabling the My Location layer.

The only case where it should request the permission is if you are calling setMyLocationEnabled(true).




回答2:


If your just want to show a map with a marker, I'd suggest using the Google Maps Static Maps API. Using this you can display an image of the map with markers and lot of other maps option. You can then open the actual Google Maps when the user clicks on the image. This would require the internet permission though.

<uses-permission android:name="android.permission.INTERNET" /> 


来源:https://stackoverflow.com/questions/31174216/use-google-maps-api-mapview-without-permission

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!