gpt4 book ai didi

javascript - 传单不显示 map

转载 作者:行者123 更新时间:2023-11-30 04:59:49 25 4
gpt4 key购买 nike

我想在安卓设备上显示 map 。我看到变焦 Controller 和市场。但是 map 没有显示。

我遵循 leftlet 示例,如果我在 html 中传递我的代码, map 会显示但不会在 android 中显示。

Image of the problem

Activity :

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_map)
Log.d("----->Map", "")
// init webView

// displaying content in WebView from html file that stored in assets folder
webView = map_location
//webView.clearCache(true)
//webView.clearHistory()


webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/map.html");



}

HTML:

<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<script src="./leaflet.js"></script>
<link rel="stylesheet" href="./leaflet.css">


<style>
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
width: 100vw; }

</style>


</head>
<body>
<div id="map"></div>
<script>

var map = L.map('map').setView([41.66, -4.72], 10);

L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
maxZoom: 18,
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
id: 'mapbox.streets'
}).addTo(map);

map.locate({setView: true, maxZoom: 16});

//L.control.scale().addTo(map);
L.marker([41.66, -4.71], {draggable: true}).addTo(map);


</script>

</body>
</html>

我希望可以显示完整的 map

最佳答案

你能试试这个吗?

width: 100%;
height: auto;
}

关于javascript - 传单不显示 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58438514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com