-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
127 lines (122 loc) · 3.58 KB
/
index.php
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
<?php
session_start();
?>
<!DOCTYPE html >
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>PCMR User Map</title>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="gmaps.js"></script>
<style type="text/css">
body {
font-family: 'Roboto', sans-serif;
margin: 0px;
padding: 0px;
}
#header {
color: #FFFFFF;
position: absolute;
left: 0;
top: 0;
height: 100px;
right: 0;
background: #333333;
padding-top:2px;
padding-bottom: 2px;
border-bottom: 2px solid #FACA04;
}
#header img {
float: left;
margin-right: 10px;
margin-left: 10px;
}
#header input {
font-size: 2em;
display: block;
border-radius: 10px;
}
#map {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 100px;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js"
type="text/javascript"></script>
<script type="text/javascript">
lastmarker = '';
$(document).ready(function(){
infoWindow = new google.maps.InfoWindow({});
map = new GMaps({
div: '#map',
lat: 0,
lng: 0,
zoom: 2,
click: function(e){
addMarker(JSON.stringify(e.latLng));
$("#save").show();
}
});
map.loadFromKML({
url: 'http://www.eegras.com/map/phpsqlajax_genxml.php?rand='+Math.random(),
suppressInfoWindows: true,
preserveViewport:true,
click: function(e){
console.log(JSON.stringify(e.latLng));
}
});
$('#save').click(function(){
$.ajax({
url: 'phpsqlajax_insert.php?rand='+Math.random(),
type: 'post',
data: {'lat': lastmarker.getPosition().lat(), 'lng': lastmarker.getPosition().lng(), 'submitted': 'yes'},
success: function(){
map.loadFromKML({
url: 'http://www.eegras.com/map/phpsqlajax_genxml.php?rand='+Math.random(),
suppressInfoWindows: true,
preserveViewport:true
});
location.reload();
}
});
$('#save').hide();
});
$("#clear").click(function(){
$.ajax({
url: 'phpsqlajax_insert.php?rand='+Math.random(),
type: 'post',
data: {'clr': 'yes'},
success: function(){
map.loadFromKML({
url: 'http://www.eegras.com/map/phpsqlajax_genxml.php?rand='+Math.random(),
suppressInfoWindows: true,
preserveViewport:true
});
location.reload();
}
});
});
});
function addMarker(latLng){
latLng = JSON.parse(latLng);
map.removeMarker(lastmarker);
lastmarker = map.addMarker({
lat: latLng.lat,
lng: latLng.lng,
title: 'New',
click: function(e){
console.log(e);
}
});
}
</script>
</head>
<body>
<div id="map"></div>
<div id="header"><img src="logostrokeroboto.png" /><input type="button" value="Clear my marker" id="clear" /><input type="button" value="Save!" id="save" style="display: none;"></div>
</body>
</html>