I followed this tutorial: http://android-er.blogspot.com/2013/03/embed-google-map-in-webview.html
I'm trying to just use the Google Map in the WebView, but it can't get my current location. I've enabled JavaScript on the WebView. What else do I have to enable?
Does anyone know why that might be? Shouldn't it prompt me to use my current location?
Note that I am not interested in using a MapView as an alternative whatsoever. I'm trying to find out what I need to set on the WebView or maybe on the device's location services?
You'd have to enable
android.permission.ACCESS_FINE_LOCATION
andandroid.permission.INTERNET
,Create a
LocationManager
instance andLocationListener
instanceand add
onLocationChanged(Location loc)
method that inside of it have yourloc
generate the longitude and latitude (String long = loc.getLongitude(); String lat = loc.getLatitude();
)and now use
long, lat
to generate yourmapPath
string and continue to generate theWebView
You can use this for ref: http://www.rdcworld-android.blogspot.in/2012/01/get-current-location-coordinates-city.html
You should permit the web view to access your location by overriding the method
onGeolocationPermissionsShowPrompt
like this:On API 5.x and below, you will need
in your
AndroidManifest.xml
.But to allow permissions for geolocation on API 6.0+, you have to request the permission at runtime.
To do this, use
and receive the result:
in your activity.
You can try GreenDroid with Google Maps.
Checkt it out: https://github.com/cyrilmottier/GreenDroid