java - 使用 Spring Boot 显示带有 openlayers 地图的图层
问题描述
我想在openlayers地图上显示一个图层(MultiPolygons),但我不知道如何使用spring boot来做到这一点,如果有人可以帮助我,我将非常感激。
PS:我正在使用 postrges
我读了一点关于休眠空间的信息,但我仍然不知道我该怎么做。
这就是我声明我的层的方式:
package com.example.demo;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="polygon")
public class Couche {
// pour indiquer la clé primaire
@Id
@Column(name = "gid" )
//L' @GeneratedValueannotation consiste à configurer le mode d'incrémentation de la colonne
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long gid ;
@Column(columnDefinition = "geometry(MultiPolygon,4326)")
private String geom ;
//geters seters pour gid
public Long getGid() {
return gid;
}
public void setGid(Long gid) {
this. gid = gid;
}
//geters seters pour Geom
public String getGeom() {
return geom;
}
public void setGeom(String geom) {
this.geom = geom;
}
}
这是我的包含地图的 HTML 页面:
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.5.0/css/ol.css" type="text/css">
<style>
.map {
height: 400px;
width: 100%;
}
</style>
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.5.0/build/ol.js"></script>
<title>OpenLayers example</title>
</head>
<body>
<h2>My Map</h2>
<div id="map" class="map"></div>
<script type="text/javascript">
//////////////////////////////////////////// zoomslider
var zoomslider = new ol.control.ZoomSlider();
// la carte
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: ol.proj.fromLonLat([37.41, 8.82]),
zoom: 4
}),
controls: ol.control.defaults().extend
([new ol.control.FullScreen(),
zoomslider
]),
});
</script>
</body>
</html>
解决方案
推荐阅读
- python - 如何让图像在 10 倍内变亮?蟒蛇,OpenCV
- assembly - 是否有任何寄存器来检查 armv8 机器上是否支持霓虹灯?
- android - 如何创建带圆角的圆形进度条
- python - 基本加密程序
- python - 如何发送一封电子邮件,其中包含由 python 中的不和谐机器人创建的邀请,以获得最大使用量?
- security - 如何防止 WiQL 注入
- powerbuilder - Powerbuilder 2019中如何获取主机名和ipv4地址?
- python - 如何根据列表中下一个项目的前两个字符合并列表中的项目
- php - Akeneo 捆绑包创建
- javascript - 如何在移动视图reactjs中隐藏软键盘?