简体   繁体   中英

Get Current Location in WebView Google maps

I have a link of my custom made map in Google which includes marker to several destinations , what i want is to get the current Location of user and show a marker or something on that location without disturbing my other markers in google map.

i have following Google map which i want to show in webView : https://www.google.com/maps/d/u/0/viewer?mid=1Wm3cIfP77Z8av8wGOi7xzQvrVxY

what modifications i should do in URL or android code to make it work?

my attempt: https://www.google.com/maps/d/u/0/dir/Current+Location/viewer?mid=1qriRe112Bm54KPXEgtfeA6n2la8&z=5 [FAILED]

Edited:

https://www.google.com/maps/d/u/0/viewer?mid=1qriRe112Bm54KPXEgtfeA6n2la8&z=5&saddr=Current+Location [FAILED]

You can create an instance of a WebView and load the URL of the Google Maps site. You can add parameters to the URL which allows you to use more functionality than is available using the Java-based Google Maps API .

Below code snippet shows how to create instance of a WebView to display a mobile Google Maps URL with parameters in an Android App. The main activity of your app should contain the following lines in its onCreate() method.

@Override
public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);

      WebView webView = (WebView) findViewById(R.id.mywebview);
      webView.getSettings().setJavaScriptEnabled(true);
      webView.loadUrl("http://maps.googleapis.com/maps/api/staticmap?
       ll=36.97,%20-122&lci=bike&z=13&t=p&size=500x500&sensor=true");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM