gpt4 book ai didi

java - Vaadin 添加 HTML 传单 map

转载 作者:行者123 更新时间:2023-11-30 01:55:48 25 4
gpt4 key购买 nike

我想向我的 vaadin 页面添加传单 map 。我尝试使用标签并将所有 html 代码添加到其中,但这只给了我一个空字段。通过使用标签添加 map 是否可能?或者还有其他办法吗?

这是我正在使用的相关代码,该 map 不是我制作的,它只是一个用于测试的虚拟 map :

public class MerchantSearchView extends CustomComponent implements View {
private VerticalLayout rootlayout;
private HorizontalLayout buttonlayout;
private CustomLayout testing = new CustomLayout();

private Label mapLabel = new Label(" <html>
<head>
<title>My First Leaflet Map</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" />
<![endif]-->
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>

</head>
<body>

<!-- define a the area the map will go into. Feel free to change the size as needed -->
<div id="map" style="width:800px; height: 500px;"></div>
<script>
var coords = [37.69, -59.23]; // the geographic center of our map
var zoomLevel = 3; // the map scale. See: http://wiki.openstreetmap.org/wiki/Zoom_levels
var map = L.map('map').setView(coords, zoomLevel);
// we need to provide the map with some base map tiles. There are few free options.
// we'll use Stamen Acetate, a muted base map good for overlaying data.
var tiles = 'http://acetate.geoiq.com/tiles/acetate-hillshading/';
// if you'd like to explore other base maps, see: http://developer.mapquest.com/web/products/open/map
// if you use different tiles, be sure to update the attribution :)
L.tileLayer(tiles+'{z}/{x}/{y}.png', {
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery &copy; <a href="http://FortiusOne.com">FortiusOne</a> and <a href="http://stamen.com">Stamen</a>',
maxZoom: 18
}).addTo(map);
</script>

</body>
</html>", ContentMode.HTML);

public MerchantSearchView(View endview) {
buttonlayout.addComponents(search, cancel);
rootlayout.addComponents(address, buttonlayout, testing);

setCompositionRoot(rootlayout);
}

就像我说的,它确实添加了 800 x 500 帧,并且确实将标题更改为“我的第一张传单 map ”,但该帧是空的。

最佳答案

一种可能的方法是使用合适的 map 插件,而不是从头开始构建它。

如果您使用 Vaadin 8,您可以考虑这个 Leaflet 插件

https://vaadin.com/directory/component/v-leaflet

如果您有 Vaadin 10 或更高版本,还有这个(它还不具备 Vaadin 8 版本的所有功能)

https://vaadin.com/directory/component/leafletjs-for-flow

关于java - Vaadin 添加 HTML 传单 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54564018/

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