-
Notifications
You must be signed in to change notification settings - Fork 0
/
myJS.js
64 lines (50 loc) · 2.66 KB
/
myJS.js
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
$(document).ready(function () {
//wczytywanie mapy
//deklaracja map podkładowych
var lyrOSM = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png'),
lyrORTO = L.tileLayer.wms("http://mapy.geoportal.gov.pl/wss/service/img/guest/ORTO/MapServer/WMSServer", {layers: "Raster", format: 'image/png', transparent : 'true', version : '1.1.1'}),
lyrSozo = L.tileLayer.wms("http://mapy.geoportal.gov.pl/wss/service/img/guest/SOZO/MapServer/WMSServer", {layers: "Raster", format: 'image/png', transparent : 'true', version : '1.1.1'}),
lyrBDOT = L.tileLayer.wms("http://localhost:8080/geoserver/Proj1/wms", {layers: "Proj1:BUBD_A", format: 'image/png', transparent : 'true', version : '1.1.1'}),
// przypisuję do zmiennej mymap obiekt mapa z klasy map
mymap = L.map('mymap', {center: [52.1289, 22.227], zoom: 10, zoomControl: false, attributionControl: false});
mymap.addLayer(lyrOSM);
var baseMaps = {
"Openstreetmap": lyrOSM,
"Ortofotomapa": lyrORTO,
"Mapa Sozologiczna": lyrSozo,
"BDOT Siedlce": lyrBDOT
};
//polecenie dodania ikonki
L.control.layers(baseMaps).addTo(mymap);
//Działa ale zamula w chuj bo geoportal jest mało wydajny
//tworze zmienna w postacie mojej ikonki.
var myicon=L.icon({
iconUrl: 'img/platoon.png',
iconSize: [50, 50],
iconAnchor: [25,25],
popupAnchor: [0, 0],
});
//dodaje skale
L.control.scale().addTo(mymap);
//okodowanie ppm
mymap.on('contextmenu', function (e) {
L.marker(e.latlng, {icon: myicon}).addTo(mymap).bindPopup('wspolrzedne: <br>' + e.latlng);
// okodowanie zeby ppm automatycznie wpisywal wspolrzedne markera do diva po prawej stornie
var szer = e.latlng.lat.toFixed(2);
var dl = e.latlng.lng.toFixed(2);
$("#tekst").html('<br> [szer], [dl]');
$("#tekst").append('<br> [' + szer + '], [' + dl + ']');
//wysłanie zmiennej do php za pomocą uproszczonego ajax z biblioteki jquery
$.ajax({
url: "connect.php",
type: 'POST', //deklaracja sposobu przekazywania zmiennych
data: { szer: szer, dl: dl }, //opis argumentów do przekazania musi być zgodny z json
success: function(msg){
console.log('Server response :\n '+msg); //argument funkcji to odpowiedz serwera i docelowo ma isc do console log żeby odczytać komunikat
},
error: function (ajaxContext){
console.log(ajaxContext.responseText); //odpowiedz ma isc do console log
}
});
}); // koniec ppm
});