forked from mapbox/geojson.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iframe-test.html
42 lines (40 loc) · 1.54 KB
/
iframe-test.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
<html>
<body>
<button onclick="myFunction('John')">Click me</button>
<iframe id="iframeId"
src="https://geojson.thelocationapi.com/#disablerecover=true&hideeditor=true&editable=false"
width="100%" height="100%"></iframe>
<script>
function myFunction(name) {
//get an example polygon of a geojson object
let geojsonExample ={
type:"Feature",
properties: {
name: "Coors Field",
amenity: "Baseball Stadium",
popupContent: "This is where the Rockies play!"
},
geometry: {
type: "Point",
coordinates: [-104.99404, 39.75621]
}
};
//example geojson geometry with type polygon
const polygon = {
type: "Polygon",
coordinates: [
[
[-104.05, 39.76],
[-104.05, 39.79],
[-104.03, 39.79],
[-104.03, 39.76],
[-104.05, 39.76]
]
]
};
geojsonExample.geometry = polygon;
var o = document.getElementsByTagName('iframe')[0];
o.contentWindow.postMessage(JSON.stringify(geojsonExample),'*');
}
</script>
</html>