-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGeoJson2GMapEditor.html
153 lines (144 loc) · 4.01 KB
/
GeoJson2GMapEditor.html
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
<html>
<head>
<title>Geofence Formatter - by Jenner Palacios</title><!--
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=yes, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="PokeMap">
<meta name="mobile-web-app-capable" content="yes">
<meta name="theme-color" content="#3b3b3b">
-->
<style>
html {
background: #000;
}
body {
margin: auto;
width: 60%;
background: #EFEFEF;
padding: 0.5em;
font-family: "Arial";
font-size: 0.9em;
}
button {
display: inline-block;
margin: 0.5em;
padding: 0.3em 0.8em;
font-weight: bold;
cursor: pointer;
font-size: 1.2em;
}
div {
display: inline-block;
vertical-align: top;
}
div:nth-child(1) {
width: 24em;
}
div:nth-child(2) {
width: 37.5em;
}
div:nth-child(3) {
width: 62em;
}
textarea {
width: 100%;
}
#GMAP {
font-size: 0.7em;
height: 30em;
}
#EDITOR {
font-size: 0.8em;
height: 60em;
}
b {
font-weight: normal;
background: #CCC;
padding: 0.2em 0.5em;
font-family: "Arial";
margin: 0.1em 0.2em;
display: inline-block;
}
h1,h2,h3,h4,p {
margin: 0;
padding: 0;
}
input, textarea {
padding: 0.2em 0.5em;
}
footer {
display: block;
margin: auto;
padding: 1em;
text-align: center;
}
footer b {
background: none;
padding: 0;
margin: 0;
}
</style>
<script>
function ClearAll() {
document.getElementById("GMAP").value = "";
document.getElementById("EDITOR").value = "";
}
var loadex = "no";
function loadcoords(){
var GMAPinPut = document.getElementById("GMAP");
var EDITOR = document.getElementById("EDITOR");
if(!GMAPinPut.value){
return alert("There is nothing to format...");
}
var GMAPdata = JSON.parse(GMAPinPut.value);
var EDITORdata = ""; var GMAPzones = "";
var GMAPinPutBlocks = ""; var GMAPinPutCoords = ""; var zoneLabel= ""; var zoneColor="";
EDITOR.value = "";
for (GMAPzones=0; GMAPzones < GMAPdata.features.length; GMAPzones++) {
zoneLabel = GMAPdata.features[GMAPzones].properties.label;
zoneColor = GMAPdata.features[GMAPzones].properties.color;
// get all the coords and group them
var coords = GMAPdata.features[GMAPzones].geometry.coordinates; coords = coords.toString(); coords = coords.split(",");
var coordcount=""; coordsA = coords.length; coordsA = coordsA - 2;
EDITORdata += "//################################################\n// ZONE NAME: "+ zoneLabel
+"\n//################################################\nvar loc_"+ GMAPzones +"=[";
// group all coords gmap format
for (coordcount=0; coordcount < coordsA ; coordcount++) {
EDITORdata += "{lng:" + coords[coordcount] + ",lat:";
coordcount++; EDITORdata += coords[coordcount] + "},";
}
EDITORdata = EDITORdata.slice(0,-1); EDITORdata += "];\n"
+"var zone_"+ GMAPzones +"=new google.maps.Polygon({paths: loc_"+ GMAPzones +",strokeColor: '#000000',"
+ "strokeOpacity: 0.7,strokeWeight: 1,fillColor: '"
+ zoneColor +"',fillOpacity: 0.35,label: '"+ zoneLabel +"',center: {lng: "+coords[0]+", lat: "+coords[1]+" }});\n"
+"zone_"+ GMAPzones +".setMap(map);\n"
+"zone_"+ GMAPzones +".addListener('click', function(event){infoWindow=new google.maps.InfoWindow;var infodata=zone_"
+ GMAPzones +".label;var label=zone_"+ GMAPzones +".label;var contentString='<div id=\"content\">'+ label + '</div>';"
+"infoWindow.setContent(contentString);infoWindow.setPosition(zone_"+ GMAPzones +".center); infoWindow.open(map);});\n\n";
}
EDITOR.value = EDITORdata;
}
</script>
</head>
<body>
<div>
<h1>gMaps to Gen ONLY!</h1>
<br />
<p>
Must be gMaps <b>FULL CODE!!!</b><br />
</p>
<br />
<button onClick="loadcoords()">CONVERT</button><button onClick="ClearAll()">CLEAR ALL</button>
</div>
<div><h2>gMaps <b>.geojson</b> code</h2>
<textarea id="GMAP"></textarea>
</div>
<div><h2>gMap Editor Output</h2>
<textarea id="EDITOR" onclick="javascript: this.select();"></textarea>
</div>
<footer>
© By: <b>Jenner Palacios</b>, July 2017
</footer>
</body>
</html>