-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditmap.php.old
134 lines (93 loc) · 4.09 KB
/
editmap.php.old
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
<!DOCTYPE html>
<html>
<head>
<title>Leaflet debug page</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <script src="./node_modules/leaflet/dist/leaflet-src.js"></script>
<link rel="stylesheet" href="./node_modules/leaflet/dist/leaflet.css" />-->
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v1.0.0-rc.1/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet/v1.0.0-rc.1/leaflet.js"></script>
<script src="http://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="inc/Leaflet.ImageOverlay.Rotated.js"></script>
</head>
<body>
<div id="map" style='width:1000px; height:800px;'></div>
<div>
Overlay opacity:
<button onclick='setOverlayOpacity(0.1)'>10%</button>
<button onclick='setOverlayOpacity(0.2)'>20%</button>
<button onclick='setOverlayOpacity(0.3)'>30%</button>
<button onclick='setOverlayOpacity(0.4)'>40%</button>
<button onclick='setOverlayOpacity(0.5)'>50%</button>
<button onclick='setOverlayOpacity(0.6)'>60%</button>
<button onclick='setOverlayOpacity(0.7)'>70%</button>
<button onclick='setOverlayOpacity(0.8)'>80%</button>
<button onclick='setOverlayOpacity(0.9)'>90%</button>
</div>
<form id="mapform" enctype="multipart/form-data" method="POST">
Point 1 Lat: <input type="text" name="lat1" />
Point 1 Lng: <input type="text" name="lng1" />
Point 2 Lat: <input type="text" name="lat2" />
Point 2 Lng: <input type="text" name="lng2" />
Point 3 Lat: <input type="text" name="lat3" />
Point 3 Lng: <input type="text" name="lng3" />
<input type="submit" value="Go" />
</form>
<script type="text/javascript">
var map = new L.Map('map');
var mbAttr = 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
var mbUrl = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'
var positron = L.tileLayer(mbUrl, {id: 'mapbox.streets', attribution: mbAttr, maxZoom:19}).addTo(map);
// var positron1 = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png').addTo(map);
var positron1 = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}.png').addTo(map);
// var positron = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', {
// maxNativeZoom: 18,
// maxZoom:24
// }).addTo(map);
<?PHP
if(array_key_exists('id',$_REQUEST))
{
$id=$_REQUEST['id'];
$pdo = new PDO('sqlite:'.getcwd().'/db/wims.sqlite');
$query = "SELECT name, file, lat1, lat2, lat3, lng1, lng2, lng3 FROM map WHERE id = $id";
$map = $pdo->query($query)->fetch();
if(is_array($map))
{
print "
var point1 = L.latLng(".$map['lat1'].", ".$map['lng1'].")
point2 = L.latLng(".$map['lat2'].", ".$map['lng2']."),
point3 = L.latLng(".$map['lat3'].", ".$map['lng3'].");
var marker1 = L.marker(point1, {draggable: true} ).addTo(map),
marker2 = L.marker(point2, {draggable: true} ).addTo(map),
marker3 = L.marker(point3, {draggable: true} ).addTo(map);
var bounds = new L.LatLngBounds(point1, point2).extend(point3);
map.fitBounds(bounds);
var overlay = L.imageOverlay.rotated(\"".$map['file']."\", point1, point2, point3, {
opacity: 0.4,
interactive: true,
});
function repositionImage() {
overlay.reposition(marker1.getLatLng(), marker2.getLatLng(), marker3.getLatLng());
$(\"input[name='lat1']\").val(marker1.getLatLng().lat);
$(\"input[name='lng1']\").val(marker1.getLatLng().lng);
$(\"input[name='lat2']\").val(marker2.getLatLng().lat);
$(\"input[name='lng2']\").val(marker2.getLatLng().lng);
$(\"input[name='lat3']\").val(marker3.getLatLng().lat);
$(\"input[name='lng3']\").val(marker3.getLatLng().lng);
};
repositionImage;
marker1.on('drag dragend', repositionImage);
marker2.on('drag dragend', repositionImage);
marker3.on('drag dragend', repositionImage);
map.addLayer(overlay);
function setOverlayOpacity(opacity) {
overlay.setOpacity(opacity);
}
";
}
}
?>
</script>
</body>
</html>