问题描述
我们正在使用Mapnik,Mapproxy和Openlyer6来开发基于GIS的Web解决方案。来自启用了Postgis的postgresql DB的GIS数据。我们正在使用epsg:32643投影并获得了地图输出,但是当我们尝试在地图上添加未显示的点时。代码在此处发布...我在地图区域内添加了2个点,但未显示任何内容。
<!DOCTYPE html>
<html lang="en">
<head>
<Meta charset="utf-8"/>
<link rel="stylesheet" href="https://openlayers.org/en/v6.4.3/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<script src="https://openlayers.org/en/v6.4.3/build/ol.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.6.1/proj4.js"></script>
<style>
html,body,.map {
margin: 0;
padding: 0;
width: 99%;
height: 99%;
border:1px solid #ccc;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script>
proj4.defs("epsg:32643","+proj=utm +zone=43 +datum=wgs84 +units=m +no_defs");
ol.proj.proj4.register(proj4);
const iconFeature = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.fromLonLat([614971.473,1218630.894])),projection: "epsg:32643",name: 'Somewhere near Nottingham',});
var map = new ol.Map({
target: 'map',layers: [
new ol.layer.Tile({
source: new ol.source.XYZ({
url: "http://192.168.3.32:8081/tms/1.0.0/district/distgrid" + "/{z}/{x}/{-y}.png",}),new ol.layer.Tile({
source: new ol.source.XYZ({
url: "http://192.168.3.32:8081/tms/1.0.0/road/roadgrid" + "/{z}/{x}/{-y}.png",new ol.layer.Tile({
source: new ol.source.XYZ({
url: "http://192.168.3.32:8081/tms/1.0.0/Landmark/landmarkgrid" + "/{z}/{x}/{-y}.png",new ol.layer.Vector({
source: new ol.source.Vector({
features: [iconFeature],renderBuffer: 200,style: new ol.style.Style({
image: new ol.style.Icon({
anchor: [0.5,46],anchorXUnits: 'fraction',anchorYUnits: 'pixels',src: 'https://openlayers.org/en/latest/examples/data/icon.png'
})
})
}),],view: new ol.View({
projection: "epsg:32643",units:"m",//extent: [485266.3703,917118.208000001,764929.9067,1414398.9922],zoom:1,maxZoom:15,minZoom:1,center:[0,0],})
});
var layer = new ol.layer.Vector({
source: new ol.source.Vector({
features: [
new ol.Feature({
geometry: new ol.geom.Point(ol.proj.fromLonLat([584658.379776645,1246789.46624421])),})
]
})
});
map.addLayer(layer);
map.getView().setZoom(map.getView().getZoom() - 6);
</script>
</body>
</html>
需要知道代码是否正确。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)