What is the problem with Android emulator for displaying maps in Web View

I get a blank white screen in my emulator and the map does not appear.

Here's what you intend to display in your browser: [ http://code.google.com/apis/maps/documentation/javascript/examples/layer-georss.html]

Here is the code for the manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.apps.mylocations"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".MyLocations"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

Here is my layout xml file that has a webview :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">

    <WebView android:id="@+id/web_engine"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"/>

</LinearLayout>

Here is the Java code:

 package com.apps.mylocations;

        import android.app.Activity;
        import android.os.Bundle;
        import android.webkit.WebView;

        public class MyLocations extends Activity {
            /** Called when the activity is first created. */
            @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);


                WebView engine = (WebView) findViewById(R.id.web_engine);

                engine.getSettings().setJavaScriptEnabled(true);

                String data = "<html>" + 
        "<head>" + 
        "<meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable=no\" />" + 
        "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"/>" + 
        "<title>Google Maps JavaScript API v3 Example: KmlLayer GeoRSS</title>" + 
        "<link href=\"http://code.google.com/apis/maps/documentation/javascript/examples/default.css\" rel=\"stylesheet\" type=\"text/css\" />" + 
        "<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\"></script>" + 
        "<script type=\"text/javascript\">" + 
        "function initialize() {" +
          "var myLatlng = new google.maps.LatLng(49.496675,-102.65625);" +
          "var myOptions = {" +
            "zoom: 4," +
            "center: myLatlng," +
            "mapTypeId: google.maps.MapTypeId.ROADMAP" +
          "}" +

          "var map = new google.maps.Map(document.getElementById(\"map_canvas\"), myOptions);" +

          "var georssLayer = new google.maps.KmlLayer('http://api.flickr.com/services/feeds/geo/?g=322338@N20&lang=en-us&format=feed-georss');" +
          "georssLayer.setMap(map);" +
        "}" +
        "</script>" + 
        "</head>" + 
        "<body onload=\"initialize()\">" + 
          "<div id=\"map_canvas\"></div>" + 
        "</body>" + 
        "</html>";


           engine.loadData(data, "text/html", "UTF-8");


            }
        }
+3
source share
3 answers

Have you followed allusions to existing questions?

google map not showing after publishing android app.

Does anyone know why my maps only show the grid

  • Is internet permission allowed in the manifest?
  • ?
+3

:

engine.loadData(...)

. , HTML , . , . : http://developer.android.com/reference/android/webkit/WebView.html

, loadDataWithBaseURL ? . javascript, / HTML.

12.05.2010:

- (), HTML- loadUrl -. Google, API , :

http://code.google.com/apis/maps/articles/android_v3.html http://gmaps-samples.googlecode.com/svn/trunk/articles-android-webmap/

+1

Source: https://habr.com/ru/post/1777015/


All Articles