Commit eafbc427d84894266998445b486cb6b9c09f10ca
Committed by
Andrew Shvayka
1 parent
51bec36d
realize fitBounds add new property useDefaultZoom
Showing
4 changed files
with
10 additions
and
10 deletions
... | ... | @@ -421,8 +421,8 @@ export default class TbGoogleMap { |
421 | 421 | |
422 | 422 | |
423 | 423 | /* eslint-disable no-undef */ |
424 | - fitBounds(bounds) { | |
425 | - if (this.dontFitMapBounds && this.defaultZoomLevel) { | |
424 | + fitBounds(bounds, useDefaultZoom) { | |
425 | + if ((this.dontFitMapBounds || useDefaultZoom) && this.defaultZoomLevel) { | |
426 | 426 | this.map.setZoom(this.defaultZoomLevel); |
427 | 427 | this.map.setCenter(bounds.getCenter()); |
428 | 428 | } else { | ... | ... |
... | ... | @@ -732,7 +732,7 @@ export default class TbMapWidgetV2 { |
732 | 732 | } |
733 | 733 | }); |
734 | 734 | |
735 | - tbMap.map.fitBounds(bounds); | |
735 | + tbMap.map.fitBounds(bounds, tbMap.isEdit && tbMap.markers.length === 1); | |
736 | 736 | } |
737 | 737 | |
738 | 738 | function mapPolygonArray (rawArray) { |
... | ... | @@ -781,7 +781,7 @@ export default class TbMapWidgetV2 { |
781 | 781 | return !(!ds[tbMap.locationSettings.latKeyName] && !ds[tbMap.locationSettings.lngKeyName]); |
782 | 782 | }); |
783 | 783 | tbMap.initBounds = !dataValid; |
784 | - tbMap.map.fitBounds(bounds); | |
784 | + tbMap.map.fitBounds(bounds, tbMap.isEdit && tbMap.markers.length === 1); | |
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
... | ... | @@ -845,7 +845,7 @@ export default class TbMapWidgetV2 { |
845 | 845 | }) |
846 | 846 | } |
847 | 847 | } |
848 | - map.fitBounds(bounds); | |
848 | + map.fitBounds(bounds, map.isEdit && map.markers.length === 1); | |
849 | 849 | } |
850 | 850 | } |
851 | 851 | } | ... | ... |
... | ... | @@ -273,9 +273,9 @@ export default class TbOpenStreetMap { |
273 | 273 | polygon.redraw(); |
274 | 274 | } |
275 | 275 | |
276 | - fitBounds(bounds) { | |
276 | + fitBounds(bounds, useDefaultZoom) { | |
277 | 277 | if (bounds.isValid()) { |
278 | - if (this.dontFitMapBounds && this.defaultZoomLevel) { | |
278 | + if ((this.dontFitMapBounds || useDefaultZoom) && this.defaultZoomLevel) { | |
279 | 279 | this.map.setZoom(this.defaultZoomLevel, {animate: false}); |
280 | 280 | this.map.panTo(bounds.getCenter(), {animate: false}); |
281 | 281 | } else { | ... | ... |
... | ... | @@ -58,7 +58,7 @@ export default class TbTencentMap { |
58 | 58 | |
59 | 59 | |
60 | 60 | if (initCallback) { |
61 | - initCallback(); | |
61 | + setTimeout(initCallback, 0);// eslint-disable-line | |
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
... | ... | @@ -427,8 +427,8 @@ export default class TbTencentMap { |
427 | 427 | } |
428 | 428 | |
429 | 429 | /* eslint-disable no-undef ,no-unused-vars*/ |
430 | - fitBounds(bounds) { | |
431 | - if (this.dontFitMapBounds && this.defaultZoomLevel) { | |
430 | + fitBounds(bounds, useDefaultZoom) { | |
431 | + if ((this.dontFitMapBounds || useDefaultZoom) && this.defaultZoomLevel) { | |
432 | 432 | this.map.setZoom(this.defaultZoomLevel); |
433 | 433 | this.map.setCenter(bounds.getCenter()); |
434 | 434 | } else { | ... | ... |