Is there any sample design that shows how to use the flyer to show the online map in the android app. Because I tried a lot of samples, but every time I have a blank webview in my application. this is my code:
private WebView mWebView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWebView= (WebView)findViewById(R.id.map); mWebView.setWebChromeClient(new WebChromeClient()); mWebView.loadUrl("file:///android_asset/www/map.html"); }
and this is an HTML object:
<head> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <link rel="stylesheet" href="css/leaflet-0.5.css" /> <script>L_PREFER_CANVAS = true;</script> <script type="text/javascript" charset="utf-8" src="js/leaflet-src-0.5.js"></script> <style> body { padding: 0; margin: 0; } html, body, #map { height: 100%; } </style> </head> <body> <div id="map"></div> <script> var map = L.map('map'); L.tileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', { attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery Β© <a href="http://cloudmade.com">CloudMade</a>', maxZoom: 18 }).addTo(map); map.locate({setView: true, maxZoom: 16}); function onLocationFound(e) { var radius = e.accuracy / 2; L.marker(e.latlng).addTo(map) .bindPopup("You are within " + radius + " meters from this point").openPopup(); L.circle(e.latlng, radius).addTo(map); } map.on('locationfound', onLocationFound); function onLocationError(e) { alert(e.message); } map.on('locationerror', onLocationError); </script> </body>
source share