Skip to content
Permalink
Browse files

[modify] googlemaps : use idle event in resetting zoom level (#2208)

* [modify] googlemaps : use idle event in resetting zoom level

* [fix] remove initialZoom
  • Loading branch information...
itowtips committed Jun 7, 2018
1 parent a3c1a2b commit 8c709521a4a990bfc5f72820a2ff2af4efda8985
@@ -162,13 +162,10 @@ class @Map_Form
Map_Form.dataID += 1

if Googlemaps_Map.markers.length > 0
zoomChangeBoundsListener = google.maps.event.addListener Googlemaps_Map.map, 'bounds_changed', ( event ) ->
if this.getZoom() > 13 && this.initialZoom == true
google.maps.event.addListenerOnce Googlemaps_Map.map, 'idle', (event) ->
if this.getZoom() > 13
this.setZoom(13)
this.initialZoom = false
google.maps.event.removeListener(zoomChangeBoundsListener)

Googlemaps_Map.map.initialZoom = true
Googlemaps_Map.map.fitBounds(markerBounds)
return

@@ -103,12 +103,9 @@ class @Googlemaps_Map
return

unless $.isEmptyObject(Googlemaps_Map.markers)
zoomChangeBoundsListener = google.maps.event.addListener Googlemaps_Map.map, 'bounds_changed', (event) ->
if this.getZoom() > 13 && this.initialZoom == true
google.maps.event.addListenerOnce Googlemaps_Map.map, 'idle', (event) ->
if this.getZoom() > 13
this.setZoom(13)
this.initialZoom = false
google.maps.event.removeListener(zoomChangeBoundsListener)

Googlemaps_Map.map.initialZoom = true
Googlemaps_Map.map.fitBounds(markerBounds)
return
@@ -88,13 +88,10 @@ class @Member_Photo_Form
Member_Photo_Form.dataID += 1

if Googlemaps_Map.markers.length > 0
zoomChangeBoundsListener = google.maps.event.addListener Googlemaps_Map.map, 'bounds_changed', ( event ) ->
if this.getZoom() > 13 && this.initialZoom == true
google.maps.event.addListenerOnce Googlemaps_Map.map, 'idle', (event) ->
if this.getZoom() > 13
this.setZoom(13)
this.initialZoom = false
google.maps.event.removeListener(zoomChangeBoundsListener)

Googlemaps_Map.map.initialZoom = true
Googlemaps_Map.map.fitBounds(markerBounds)
return

0 comments on commit 8c70952

Please sign in to comment.
You can’t perform that action at this time.