File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -142,10 +142,11 @@ Also controls True or False:
142142- scale_control
143143- scale_control
144144- streetview_control
145- - rorate_control
145+ - rotate_control
146146- fullscreen_control
147147- scroll_wheel
148148- collapsible (map collapses by click on ** varname** _ collapse button)
149+ - center on user location (using HTML5 Geolocation)
149150
150151#### 2. Template
151152
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ def __init__(self,
3939 cluster_imagepath = DEFAULT_CLUSTER_IMAGE_PATH ,
4040 cluster_gridsize = 60 ,
4141 fit_markers_to_bounds = False ,
42+ center_on_user_location = False ,
4243 ** kwargs ):
4344 """Builds the Map properties"""
4445 self .cls = cls
@@ -68,6 +69,7 @@ def __init__(self,
6869 self .scroll_wheel = scroll_wheel
6970 self .fullscreen_control = fullscreen_control
7071 self .collapsible = collapsible
72+ self .center_on_user_location = center_on_user_location
7173
7274 self .cluster = cluster
7375 self .cluster_imagepath = cluster_imagepath
@@ -726,6 +728,7 @@ def as_json(self):
726728 'cluster_imagepath' : self .cluster_imagepath ,
727729 'cluster_gridsize' : self .cluster_gridsize ,
728730 'collapsible' : self .collapsible ,
731+ 'center_on_user_location' : self .center_on_user_location ,
729732 'js' : dumps (self .js ),
730733 'html' : dumps (self .html ),
731734 'fit_markers_to_bounds' : self .fit_markers_to_bounds ,
Original file line number Diff line number Diff line change 4242 fullscreenControl : { % if gmap . fullscreen_control % } true { % else % } false { % endif % }
4343 } ) ;
4444
45+ //center map location on user location
46+ { % if gmap . center_on_user_location % }
47+ if ( navigator . geolocation ) {
48+ navigator . geolocation . getCurrentPosition ( function ( position ) {
49+ initialLocation = new google . maps . LatLng ( position . coords . latitude , position . coords . longitude ) ;
50+ map . setCenter ( initialLocation ) ;
51+ } ) ;
52+ }
53+ { % endif % }
54+
4555 // add gmap markers
4656 var raw_markers = { { gmap . markers | tojson | safe} } ;
4757 for ( i = 0 ; i < { { gmap . markers | length } } ; i ++ ) {
You can’t perform that action at this time.
0 commit comments