Skip to content

Commit 7020ae5

Browse files
added code for feature to show KML layer on google maps
1 parent 01bdbfc commit 7020ae5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

flask_googlemaps/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __init__(
4848
report_clickpos=False,
4949
clickpos_uri="",
5050
styles="",
51+
layer="",
5152
**kwargs
5253
):
5354
"""Builds the Map properties"""
@@ -89,6 +90,7 @@ def __init__(
8990

9091
self.fit_markers_to_bounds = fit_markers_to_bounds
9192
self.styles = styles
93+
self.layer = layer
9294

9395

9496
def build_markers(self, markers):

flask_googlemaps/templates/googlemaps/gmapjs.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
{% endif %}
1414

1515

16+
<script src="https://unpkg.com/deck.gl@^7.0.0/dist.min.js"></script>
17+
18+
<script src="https://maps.googleapis.com/maps-api-v3/api/js/42/6/kml.js"></script>
19+
1620
<style type="text/css">
1721
#{{gmap.identifier}} { {{gmap.style}} }
1822
</style>
@@ -53,6 +57,12 @@
5357
}
5458
{% endif %}
5559

60+
// add kml layer on map
61+
const ctaLayer = new google.maps.KmlLayer({
62+
url: "{{gmap.layer }}",
63+
map: {{gmap.varname}},
64+
});
65+
5666
// add gmap markers
5767
var raw_markers = {{gmap.markers|tojson|safe}};
5868
for(i=0; i<{{gmap.markers|length}};i++) {

0 commit comments

Comments
 (0)