Compare commits
2 Commits
dev
...
feature/co
Author | SHA1 | Date | |
---|---|---|---|
f834111e1f | |||
b33b131f96 |
@ -110,28 +110,17 @@
|
|||||||
return satellite;
|
return satellite;
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_geojson(name, url, active=1) {
|
function load_geojson(name, url, active=1, style = {}, onEachFeature = null, onClick=null) {
|
||||||
var xhttp_ps = new XMLHttpRequest();
|
var xhttp_ps = new XMLHttpRequest();
|
||||||
xhttp_ps.onreadystatechange = function() {
|
xhttp_ps.onreadystatechange = function() {
|
||||||
if (this.readyState == 4) {
|
if (this.readyState == 4) {
|
||||||
if (this.status == 200) {
|
if (this.status == 200) {
|
||||||
var geojson = L.geoJSON(JSON.parse(xhttp_ps.responseText), {
|
var geojson = L.geoJSON(JSON.parse(xhttp_ps.responseText), {
|
||||||
onEachFeature: function (feature, layer) {
|
style: style,
|
||||||
label = String(feature.properties.name)
|
onEachFeature: onEachFeature
|
||||||
layer.bindPopup(
|
|
||||||
'<h1><a href="https://wiki.linux-forks.de/mediawiki/index.php/'+feature.properties.name+'">'+feature.properties.name+'</a> ('+feature.geometry.coordinates+')</h1>'+
|
|
||||||
'<p><img style="width:100%" src="' + feature.properties.image + '"></p>' +
|
|
||||||
'<p>'+feature.properties.description+'</p>'
|
|
||||||
);
|
|
||||||
layer.bindTooltip(label, {permanent: true, direction: "center", className: "city-names"}).openTooltip();
|
|
||||||
}/*,
|
|
||||||
pointToLayer: function(feature,latlng){
|
|
||||||
label = String(feature.properties.name)
|
|
||||||
return new L.CircleMarker(latlng, {
|
|
||||||
radius: 1,
|
|
||||||
}).bindTooltip(label, {permanent: true, direction: "center", opacity: 0.7}).openTooltip();
|
|
||||||
}*/
|
|
||||||
});
|
});
|
||||||
|
if (onClick)
|
||||||
|
geojson.on('click', onClick)
|
||||||
layers.addOverlay(geojson, name);
|
layers.addOverlay(geojson, name);
|
||||||
if (active)
|
if (active)
|
||||||
geojson.addTo(mymap);
|
geojson.addTo(mymap);
|
||||||
@ -149,7 +138,53 @@
|
|||||||
load_tiles("Satellite (2019-05-04, wrong coords)", 'world-2019-05-04');
|
load_tiles("Satellite (2019-05-04, wrong coords)", 'world-2019-05-04');
|
||||||
|
|
||||||
//load_svg("Test", "./overlay.svg", 0);
|
//load_svg("Test", "./overlay.svg", 0);
|
||||||
load_geojson("Cities", "./geojson/cities.json");
|
load_geojson(
|
||||||
|
"Cities",
|
||||||
|
"./geojson/cities.json",
|
||||||
|
1,
|
||||||
|
{},
|
||||||
|
function (feature, layer) {
|
||||||
|
label = String(feature.properties.name)
|
||||||
|
layer.bindPopup(
|
||||||
|
'<h1><a href="https://wiki.linux-forks.de/mediawiki/index.php/'+feature.properties.name+'">'+feature.properties.name+'</a> ('+feature.geometry.coordinates+')</h1>'+
|
||||||
|
'<p><img style="width:100%" src="' + feature.properties.image + '"></p>' +
|
||||||
|
'<p>'+feature.properties.description+'</p>'
|
||||||
|
);
|
||||||
|
layer.bindTooltip(label, {permanent: true, direction: "center", className: "city-names"}).openTooltip();
|
||||||
|
},
|
||||||
|
null);
|
||||||
|
load_geojson(
|
||||||
|
"All Places",
|
||||||
|
"./geojson/all.json",
|
||||||
|
1,
|
||||||
|
{},
|
||||||
|
null,
|
||||||
|
onClick = function(e){
|
||||||
|
console.log(e.sourceTarget.feature);
|
||||||
|
popup
|
||||||
|
.setLatLng(e.latlng)
|
||||||
|
.setContent("Here is <a href=\"https://wiki.linux-forks.de/mediawiki/index.php/" + e.sourceTarget.feature.properties.name + "\">" + e.sourceTarget.feature.properties.name + "</a>")
|
||||||
|
.openOn(mymap);
|
||||||
|
});
|
||||||
|
load_geojson(
|
||||||
|
"Test",
|
||||||
|
"./geojson/test.json",
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
radius: 8,
|
||||||
|
fillColor: "#ff7800",
|
||||||
|
color: "blue",
|
||||||
|
opacity: 1,
|
||||||
|
fillOpacity: 0.5
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
onClick = function(e){
|
||||||
|
console.log(e.sourceTarget.feature);
|
||||||
|
popup
|
||||||
|
.setLatLng(e.latlng)
|
||||||
|
.setContent("You clicked on <a href=\"https://wiki.linux-forks.de/mediawiki/index.php/" + e.sourceTarget.feature.properties.name + "\">" + e.sourceTarget.feature.properties.name + "</a>")
|
||||||
|
.openOn(mymap);
|
||||||
|
});
|
||||||
|
|
||||||
L.control.scale().addTo(mymap);
|
L.control.scale().addTo(mymap);
|
||||||
|
|
||||||
@ -162,7 +197,7 @@
|
|||||||
.openOn(mymap);
|
.openOn(mymap);
|
||||||
}
|
}
|
||||||
|
|
||||||
mymap.on('click', onMapClick);
|
//mymap.on('click', onMapClick);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
5
scripts/geojson/fetch_all_points.sh
Executable file
5
scripts/geojson/fetch_all_points.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
json=`curl 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&format=json&list=search&redirects=1&converttitles=1&srsearch=%7B%7BCo%7C&srlimit=max&srwhat=text&srprop=snippet'`
|
||||||
|
echo "["
|
||||||
|
echo $json | json_reformat | grep -B 2 'coordinates' | sed -n -e 's#.*o</span>|\([0-9\\-]\+\)|[0-9\\-]*|\([0-9\\-]\+\).*#"geometry": {"type": "Point", "coordinates": [\1,\2]}},#p' -e 's/.*title": "\([^"]*\).*/{ "type": "Feature", "properties": {"name": "\1"},/p'
|
||||||
|
echo "{}]"
|
Loading…
Reference in New Issue
Block a user