Search code examples
androidandroid-maps

Whats the issue with the android emulator to display map in Web View


I am getting a blank white screen in my emulator and the map is not getting displayed.

Here is what is suppose to be displayed in a browser: [http://code.google.com/apis/maps/documentation/javascript/examples/layer-georss.html]

Here's the code for 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 which 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 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");


            }
        }

Solution

  • You have followed the hints on existing questions?

    google map not showing after publishing android application?

    Does anyone know why my maps only show grid

    • internet permission given in manifest?
    • maps key correct?