提交 d37e93d6 编写于 作者: S Serge Rider 提交者: GitHub

Merge pull request #5627 from Sertarus/PostGIS-development

Looks good

Former-commit-id: 3a5ef869
<!DOCTYPE html> <!DOCTYPE html>
<html> <html style="height: 100%;">
<head> <head>
<title>Quick Start - Leaflet</title> <title>Quick Start - Leaflet</title>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="inc/leaflet.css"/> <link rel="stylesheet" href="inc/leaflet.css" />
<script src="inc/leaflet.js"></script> <script src="inc/leaflet.js"></script>
<script src="inc/wkx.min.js"></script> <script src="inc/wkx.min.js"></script>
</head> </head>
<body>
<div id="mapid" style="width: 100%; height: 400px;"></div>
<script>
var wkx = require('wkx');
var mymap = L.map('mapid');//.setView([51.505, -0.09], 13);
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(mymap);
const geojsonMarkerOptions = { <body style="height: 100%; margin: 0;">
radius: 4,
weight: 3,
};
const geojsonStyle = {
weight: 2,
};
const popupOption = {
closeButton: false,
minWidth: 260,
maxWidth: 300,
maxHeight: 300,
};
var vectorLayer = L.geoJSON([], { <div id="mapid" style="width: 100%; height: 100%;"></div>
style: geojsonStyle, <script>
pointToLayer: function (feature, latlng) { var wkx = require('wkx');
return L.circleMarker(latlng, geojsonMarkerOptions); var mymap = L.map('mapid'); //.setView([51.505, -0.09], 13);
},
});
vectorLayer.addTo(mymap);
var polyTest = wkx.Geometry.parse('${geomValue}'); L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
var geoJSON = polyTest.toGeoJSON(); maxZoom: 18,
var SRID = geoJSON.selectedSRID; attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors ' +
vectorLayer.addData(geoJSON); '<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(mymap);
var bounds = vectorLayer.getBounds(); const geojsonMarkerOptions = {
/* radius: 4,
bounds = bounds.pad(0.1); weight: 3,
let maxLength = Math.max(bounds.getNorth() - bounds.getSouth(), };
bounds.getEast() - bounds.getWest()); const geojsonStyle = {
if (SRID === 4326) { weight: 2,
alert("setEPSG3857"); };
setEPSG3857(); const popupOption = {
} else { closeButton: false,
//setSimpleCRS(); minWidth: 260,
if (maxLength >= 180) { maxWidth: 300,
// calculate the min zoom level to enable the map to fit the whole geometry. maxHeight: 300,
let minZoom = Math.floor(Math.log2(360 / maxLength)) - 2; };
mymap.setMinZoom(minZoom);
} else {
mymap.setMinZoom(0);
}
}
*/
mymap.setView(bounds.getCenter(), 13);//mymap.getZoom()); var vectorLayer = L.geoJSON([], {
style: geojsonStyle,
pointToLayer: function(feature, latlng) {
return L.circleMarker(latlng, geojsonMarkerOptions);
},
});
vectorLayer.addTo(mymap);
var popup = L.popup(); var polyTest = wkx.Geometry.parse('${geomValue}');
var geoJSON = polyTest.toGeoJSON();
var SRID = geoJSON.selectedSRID;
vectorLayer.addData(geoJSON);
function onMapClick(e) { var bounds = vectorLayer.getBounds();
popup mymap.fitBounds(bounds);
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(mymap);
}
mymap.on('click', onMapClick);
</script>
var popup = L.popup();
function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(mymap);
}
mymap.on('click', onMapClick);
</script>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册