-
Notifications
You must be signed in to change notification settings - Fork 1
/
htmltemplate2.txt
206 lines (203 loc) · 8.07 KB
/
htmltemplate2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<div id="mapid" class="left col-sm-9" style="height: 500px;">
</div>
<script>
function toggle_visibility(id)
{
var e = document.getElementById(id);
if (e.style.display == 'block' || e.style.display=='')
{
e.style.display = 'none';
}
else
{
e.style.display = 'block';
}
}
if(epsg!="" && epsg!="EPSG:4326" && epsg in epsgdefs){
geojson=convertGeoJSON(geojson,epsgdefs[epsg])
console.log(geojson);
}
var colorcodes={}
var map = L.map('mapid',{fullscreenControl: true,fullscreenControlOptions: {position: 'topleft'}}).setView([51.505, -0.09], 16);
var wmsLayer = L.tileLayer.wms('https://sgx.geodatenzentrum.de/wms_topplus_web_open', {
layers: 'web',
format: 'image/png',
transparent: true,
attribution: '© Bundesamt für Kartographie und Geodäsie 2017, <a href="http://sg.geodatenzentrum.de/web_public/Datenquellen_TopPlus_Open.pdf">Datenquellen</a>'
});
var layer=L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',maxZoom: 20});
var baseMaps = {"OSM": layer,"BKG":wmsLayer}; baseMaps["BKG"].addTo(map); L.control.scale({
position: 'bottomright',
imperial: false
}).addTo(map);
$( document ).ready(function() {
$('#queryres').DataTable({"scrollX":"100%","scrollCollapse": true});
});
function isArray(what) {
return Object.prototype.toString.call(what) === '[object Array]';
}
function saveTextAsFile(tosave,fileext,filename)
{
var a = document.createElement('a');
a.style = "display: none";
var blob= new Blob([tosave], {type:'text/plain'});
var url = window.URL.createObjectURL(blob);
var filename = filename+fileext;
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function(){
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 1000);
}
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
console.log(color)
return color;
}
var colormap={}
var layercontrol=L.control.layers(baseMaps,overlayMaps).addTo(map);
var geojsonlayer=L.geoJSON.css(geojson, {
style: function(feature){
return {
fillColor: 'blue',
weight: 2,
opacity: 1,
color: 'white', //Outline color
fillOpacity: 0.7
};
},
coordsToLatLng: function (coords) {
console.log(coords)
console.log(coords[0])
console.log(coords[1])
if(typeof coords[0] !== 'undefined' && typeof coords[1] !== 'undefined'){
return new L.LatLng(coords[1], coords[0]);
}else if(typeof coords[0] !== 'undefined' && typeof coords[0][1]!== 'undefined'){
return new L.LatLng(coords[0][1], coords[0][0]);
}
return new L.LatLng(0, 0);
},
pointToLayer: function(feature, latlng){
var color="";
if(typeColumn==""){
if(!("" in colormap)){
colormap[""]=getRandomColor();
}
color=colormap[""];
}else{
if(typeColumn in feature.properties){
if(!(feature.properties[typeColumn] in colormap)){
colormap[feature.properties[typeColumn]]=getRandomColor();
}
color=colormap[feature.properties[typeColumn]]
}else{
if(!("" in colormap)){
colormap[""]=getRandomColor();
}
color=colormap[""];
}
}
var greenIcon = L.divIcon({
className: "my-custom-pin",
iconAnchor: [0, 24],
labelAnchor: [-6, 0],
popupAnchor: [0, -36],
html: "<span style=\"background-color: "+color+"; width: 1.5rem;height: 1.5rem;display: block;left: -1rem;top: 0rem;position: relative;border-radius: 3rem 3rem 0;transform: rotate(45deg);border: 1px solid #FFFFFF;\"/>"
});
return L.marker(latlng,{icon: greenIcon})
},
onEachFeature: function (feature, layer) {
if("style" in feature && "hatch" in feature.style){
stripes = new L.StripePattern(feature.style.hatch);
stripes.addTo(map);
}
var popup="Item: <a href='"+feature.id+"' target='_blank'>"+
(feature.id.includes('#')?feature.id.substring(feature.id.lastIndexOf('#')+1):feature.id)+"</a>"
if("http://www.w3.org/1999/02/22-rdf-syntax-ns#type" in feature.properties){
if(feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].includes("http") && feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].includes("#")){
ns=feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].substring(0,feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].indexOf('#'))
if(!(ns in colorcodes)){
colorcodes[ns]=getRandomColor();
}
popup+="(<a href='"+feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]+"' target='_blank' style='color:"+colorcodes[ns]+"'>"+feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].substring(feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].lastIndexOf('#')+1)+"</a>)"
}else if(feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].includes("http")){
ns=feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].substring(0,feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].indexOf('/'))
if(!(ns in colorcodes)){
colorcodes[ns]=getRandomColor();
}
popup+="(<a href='"+feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]+"' target='_blank' style='color:"+colorcodes[ns]+"'>"+feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].substring(feature.properties["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].lastIndexOf('/')+1)+"</a>)"
}
}
if(typeof stripes !== 'undefined'){
poly=L.polygon(feature["geometry"]["coordinates"],{"fillPattern":stripes}).addTo(map);
}else {
layer.bindPopup(popup,{maxWidth : 560});
}
popup+="<br/>Properties:<ul>"
Object.keys(feature.properties).sort().forEach(function(prop) {
if(prop=="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"){
return;
}
if(prop.includes("http") && prop.includes("#")){
ns=prop.substring(0,prop.indexOf('#'))
if(!(ns in colorcodes)){
colorcodes[ns]=getRandomColor();
}
popup+="<li><a href='"+prop+"' target='_blank' style='color:"+colorcodes[ns]+"'>"+prop.substring(prop.lastIndexOf('#')+1)+"</a> - "
}else if(prop.includes("http")){
ns=prop.substring(0,prop.indexOf('/'))
if(!(ns in colorcodes)){
colorcodes[ns]=getRandomColor();
}
popup+="<li><a href='"+prop+"' target='_blank' style='color:"+colorcodes[ns]+"'>"+prop.substring(prop.lastIndexOf('/')+1)+"</a> - "
}else{
popup+="<li>"+prop+" - "
}
if(!isArray(feature.properties[prop])){
array=[feature.properties[prop]]
}else{
array=feature.properties[prop]
popup+="<a href=\"#\" onclick=\"toggle_visibility('"+prop+"')\">[x]</a><br/><span id=\""+prop+"\">"
}
for(elem in array){
if(array[elem].includes("http") && array[elem].includes("^^")){
ns=array[elem].substring(0,array[elem].indexOf('^^'))
if(!(ns in colorcodes)){
colorcodes[ns]=getRandomColor();
}
popup+="<a href='"+array[elem]+"' target='_blank' style='color:"+colorcodes[ns]+"'>"+array[elem].substring(0,array[elem].lastIndexOf('^')-1)+"</a><br/>"
}else if(array[elem].includes("http") && array[elem].includes("#")){
ns=array[elem].substring(0,array[elem].indexOf('#'))
if(!(ns in colorcodes)){
colorcodes[ns]=getRandomColor();
}
popup+="<a href='"+array[elem]+"' target='_blank' style='color:"+colorcodes[ns]+"'>"+array[elem].substring(array[elem].lastIndexOf('#')+1)+"</a><br/>"
}else if(array[elem].includes("http") || array[elem].includes("file:/")){
ns=array[elem].substring(0,array[elem].indexOf('/'))
if(!(ns in colorcodes)){
colorcodes[ns]=getRandomColor();
}
popup+="<a href='"+array[elem]+"' target='_blank' style='color:"+colorcodes[ns]+"'>"+array[elem].substring(array[elem].lastIndexOf('/')+1)+"</a><br/>"
}else{
popup+=array[elem]+"<br/>"
}
}
popup+="</li>"
});popup+="</ul>"
console.log(feature)
layer.on('click', function (e) {
$('#contentdesc').html(popup)
});
}}).addTo(map);
try {
map.fitBounds(geojsonlayer.getBounds());
}catch (e) {
}
</script>