Skip to content

Commit dd40e72

Browse files
Create demo.html
1 parent dd9e4d8 commit dd40e72

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

demo.html

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
6+
<meta charset="utf-8">
7+
<title>KML Click Capture Sample</title>
8+
<style>
9+
html,
10+
body {
11+
height: 370px;
12+
padding: 0;
13+
margin: 0;
14+
}
15+
16+
#map {
17+
height: 600px;
18+
width: 100%;
19+
overflow: hidden;
20+
float: left;
21+
border: thin solid #333;
22+
}
23+
24+
#capture {
25+
height: 300px;
26+
width: 300px;
27+
overflow: hidden;
28+
float: left;
29+
background-color: #ECECFB;
30+
border: thin solid #333;
31+
border-left: none;
32+
}
33+
</style>
34+
</head>
35+
36+
<body>
37+
<div>
38+
<div id="map"></div>
39+
<div id="capture">
40+
<h1>Click on Items!</h1>
41+
</div>
42+
43+
</div>
44+
<script>
45+
var map;
46+
47+
// var src = 'https://mr-man7352.github.io/emedding-map/jharkhand.kml';
48+
var src = 'https://raw.githubusercontent.com/Mr-man7352/emedding-map/main/poc.kml';
49+
// var src = 'https://raw.githubusercontent.com/aviklai/react-leaflet-kml/master/src/assets/example1.kml'
50+
51+
function initMap() {
52+
map = new google.maps.Map(document.getElementById('map'), {
53+
center: new google.maps.LatLng(23.76701003454233, 86.25580163665583),
54+
zoom: 7,
55+
mapTypeId: 'roadmap'
56+
});
57+
58+
var kmlLayer = new google.maps.KmlLayer(src, {
59+
// suppressInfoWindows: true,
60+
// preserveViewport: false,
61+
map: map
62+
});
63+
console.log('kml', kmlLayer);
64+
// console.log(kmlLayer.kml.metadata);
65+
kmlLayer.addListener('click', function (event) {
66+
console.log('hi click');
67+
var content = event.featureData.infoWindowHtml;
68+
var testimonial = document.getElementById('capture');
69+
testimonial.innerHTML = content;
70+
});
71+
}
72+
</script>
73+
<script async
74+
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDR3FVKoE4t-H4yFqcGLC70uep_Vb6w3JA&callback=initMap">
75+
</script>
76+
</body>
77+
78+
</html>

0 commit comments

Comments
 (0)