0

I am trying to load google map v3 (Javascript) in a web view in android

It always gives error

user denied geolocation

Written using Ionic , it works fine in desktop chrome(ionic serve), and ios devices , error appears only in android

Git repo : https://github.com/aishwat/temp

Already done following:

  1. In manifest

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

  1. For webview

webView.getSettings().setGeolocationEnabled(true);

  1. Referred to following links

google-maps-javascript-geolocation-not-working-on-chrome

html-navigator-user-denied-geolocation

and few others

Nothing works plz help

Community
  • 1
  • 1
Aishwat Singh
  • 4,331
  • 2
  • 26
  • 48
  • Follow the instruction on [this link](http://stackoverflow.com/questions/33066876/cordova-ajax-call-not-working-on-ios-works-fine-on-android/33071460#33071460), it will solve your issue. If not, respond here. I will be traveling in a few minutes and may not respond for 24 hours. –  Oct 12 '15 at 00:10
  • Is the API key right and what do you see in https://console.developers.google.com/project? – Joerg Oct 12 '15 at 04:17
  • @JesseMonroy650 I tried ` ` But still doesn't work, this project doesn't have any dependency on cordova itself , I can remove cordova out of picture completely , still map loads but no geolocation @Joerg , It works fine if i do ionic run android --device , so not api key issue – Aishwat Singh Oct 12 '15 at 07:26

2 Answers2

1

Thanks @JesseMonroy650 for help but it did not fix my issue

Finally after a lot of searching i got this android webview geolocation

So issue was , i was using default web view client rather than chrome client and I had to override this method as mentioned in post onGeolocationPermissionsShowPrompt

Anyways thanks for help man !

Community
  • 1
  • 1
Aishwat Singh
  • 4,331
  • 2
  • 26
  • 48
0

@aishwat,
Ionic is using Cordova by default, so I'm not sure how you would do that. I do NOT use Ionic, not yet at least. I have used v3 of the Google maps with PhonegapBuild. I set my version as such in my config.xml

`<preference name="phonegap-version" value="3.5.0" />`

You should be able to set your Cordova compiler to some 3.x version. That will at least verify your code on the Android. After that, it should be a white-list issue.

FWIW: I looked at your code. YOU DO NOT HAVE the white-list plugin. You need ALL three things to use the white-list properly. You need:

  1. white-list
  2. white-list plugin
  3. CSP

Re-read that last link.

With the CLI version, if you do not assign a version for your platform (...) (and) If you are not lucky, you'll get a set of cascading errors.

Community
  • 1
  • 1