当我们初始化 map 时,我们将基础层设置为“reduced.day”。
我们目前面临一个问题,当用户将 map 类型从“ map View ”更改为“卫星”并返回“ map View ”时,图 block 会更改为标准而不是“缩小” .日”。
我查阅了文档,但找不到任何有关如何防止该问题的提示。
所以我的问题是,如何使用 UI 控件设置 map View 图 block 以减少日数。
非常感谢。
最佳答案
我终于可以解决我的问题了。
解决方案是为每种 map 类型传递具有请求的 map 样式的自定义对象。
请参阅下面编辑 map 控件的完整代码。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Here Custom Controlls</title>
<script src="http://js.api.here.com/v3/3.0/mapsjs-core.js" type="text/javascript" charset="utf-8"
></script>
<script src="http://js.api.here.com/v3/3.0/mapsjs-service.js" type="text/javascript" charset="utf-8"
></script>
<script src="http://js.api.here.com/v3/3.0/mapsjs-ui.js" type="text/javascript" charset="utf-8"
></script>
<link rel="stylesheet" type="text/css" href="http://js.api.here.com/v3/3.0/mapsjs-ui.css"
/>
</head>
<body>
<div id="map" style="height: 800px; width: 800px;"></div>
<script type="text/javascript" charset="utf-8">
//Initialize the Platform object:
const platform = new H.service.Platform({
app_id: {YOUR_APP_ID},
app_code: {YOUR_APP_CODE}
});
// Get the default map types from the Platform object:
const defaultLayers = platform.createDefaultLayers();
// Instantiate the map:
const map = new H.Map(
document.getElementById("map"),
defaultLayers.normal.map,
{
zoom: 10,
center: { lng: 13.4, lat: 52.51 }
}
);
const mapTileService = platform.getMapTileService({ type: "base" });
var reduce = mapTileService.createTileLayer(
"maptile",
"reduced.day",
256,
"png8"
);
map.setBaseLayer(reduce);
// Create the custom UI:
const ui = H.ui.UI.createDefault(
map,
{
...defaultLayers,
normal: {
map: reduce
}
},
"de-DE"
);
</script>
</body>
</html>
关于javascript - 如何更改 ui 控件上的 map 图 block 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55684365/