I would like to load a google map using a WebView and show some markers on it. Due to some limitations I can only use WebView for loading the map and not MapFragment. So I create a webview and loadurl for a html file stored in the assets folder. (Btw these html files all load perfectly on a PC browser but do not render on the tablet.). I am NOT able to find out the root of the error and why the html/javascript renders on the PC but throws error on the mobile. Please help!! -Thanks
mapinit.html
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>Example</title>
<script src="http://maps.google.com/maps/api/js?v=3.exp&sensor=true"></script>
<script type="text/javascript" charset="utf-8">
function initializeMap() {
var mapOptions = {
zoom : 12,
center : new google.maps.LatLng(37.401324, -122.053624),
mapTypeId : google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
}
function myOnLoad() {
initializeMap();
}
</script>
</head>
<body onload=myOnLoad()>
<div id="demo"></div>
<div id="map-canvas" style="height: 1500px; width: 1500px;"></div>
</body>
Android code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview_activity_main);
mWebView = (WebView) findViewById(R.id.webview);
mWebView.loadUrl("file:///android_asset/mapinit.html");
mWebView.getSettings().setJavaScriptEnabled(true);
}
Error:
[INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
07-09 18:56:11.405: I/chromium(14502): [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
07-09 18:56:11.465: I/chromium(14502): [INFO:CONSOLE(1)] "Uncaught ReferenceError: google is not defined", source: (1)
0 comments:
Post a Comment