Sam
Sam

Reputation: 2093

my maps in a webview launches in googlemaps

So it's a simple app showing a webview with a mymap, and, oh my, Google have made it wonderful. They've extracted all the markers and info boxes and sent them off to the Google maps app where they're displayed as cards.

But this creates problems.

  1. If the user presses the home button, when they relaunch the app they're met with a blank screen.
    enter image description here The map is fully loaded into googlemaps. They might not know.

I presume if Googlemaps is not installed the app will show the slightly clunky webview myMap. For those who have been redirected to Google maps,when they relaunch my app (without having closed it), or navigate back to it, I'd like a button to let them switch to where the map is, in the googlemaps app.

Any idea how to do this? Do you think it's reasonable to assume 90% of people have Googlemaps installed?

Is there a better way of handling things?

Forgive me if I ask too much.

Upvotes: 1

Views: 903

Answers (1)

Astrit Veliu
Astrit Veliu

Reputation: 1572

Maybe you can try to load an iframe to you webview with your location. For example

 String html ="<iframe src=\"https://www.google.com/maps/embed?....></iframe>";
        WebView webview;
        webview = (WebView) findViewById(R.id.webview);
        webview.getSettings().setJavaScriptEnabled(true);
        webview.loadData(html, "text/html", null);

This will allow you to load this iframe inside your application.

Upvotes: 1

Related Questions