Commit 6a54e2ff1eb69c7333038bd2b66dda64505bc3e9
Committed by
Igor Kulikov
1 parent
03631c83
New fixed center func for maps (#1910)
* maps widget bundle changes (trip_animation configs) * UI Added fixed map center settings for (openstreet, google, tencent) maps * UI open street center minor fix * fix * UI fixed commit * UI fixed commit * Delete leaflet-geometryutil.js * Delete Leaflet.MultiOptionsPolyline.js
Showing
4 changed files
with
82 additions
and
51 deletions
@@ -19,7 +19,7 @@ var gmGlobals = { | @@ -19,7 +19,7 @@ var gmGlobals = { | ||
19 | } | 19 | } |
20 | 20 | ||
21 | export default class TbGoogleMap { | 21 | export default class TbGoogleMap { |
22 | - constructor($containerElement, utils, initCallback, defaultZoomLevel, dontFitMapBounds, disableScrollZooming, minZoomLevel, gmApiKey, gmDefaultMapType) { | 22 | + constructor($containerElement, utils, initCallback, defaultZoomLevel, dontFitMapBounds, disableScrollZooming, minZoomLevel, gmApiKey, gmDefaultMapType, defaultCenterPosition) { |
23 | 23 | ||
24 | var tbMap = this; | 24 | var tbMap = this; |
25 | this.utils = utils; | 25 | this.utils = utils; |
@@ -28,6 +28,7 @@ export default class TbGoogleMap { | @@ -28,6 +28,7 @@ export default class TbGoogleMap { | ||
28 | this.minZoomLevel = minZoomLevel; | 28 | this.minZoomLevel = minZoomLevel; |
29 | this.tooltips = []; | 29 | this.tooltips = []; |
30 | this.defaultMapType = gmDefaultMapType; | 30 | this.defaultMapType = gmDefaultMapType; |
31 | + this.defaultCenterPosition = defaultCenterPosition; | ||
31 | 32 | ||
32 | function clearGlobalId() { | 33 | function clearGlobalId() { |
33 | if (gmGlobals.loadingGmId && gmGlobals.loadingGmId === tbMap.mapId) { | 34 | if (gmGlobals.loadingGmId && gmGlobals.loadingGmId === tbMap.mapId) { |
@@ -42,13 +43,12 @@ export default class TbGoogleMap { | @@ -42,13 +43,12 @@ export default class TbGoogleMap { | ||
42 | } | 43 | } |
43 | 44 | ||
44 | function initGoogleMap() { | 45 | function initGoogleMap() { |
45 | - | ||
46 | tbMap.map = new google.maps.Map($containerElement[0], { // eslint-disable-line no-undef | 46 | tbMap.map = new google.maps.Map($containerElement[0], { // eslint-disable-line no-undef |
47 | scrollwheel: !disableScrollZooming, | 47 | scrollwheel: !disableScrollZooming, |
48 | mapTypeId: getGoogleMapTypeId(tbMap.defaultMapType), | 48 | mapTypeId: getGoogleMapTypeId(tbMap.defaultMapType), |
49 | - zoom: tbMap.defaultZoomLevel || 8 | 49 | + zoom: tbMap.defaultZoomLevel || 8, |
50 | + center: new google.maps.LatLng(tbMap.defaultCenterPosition[0], tbMap.defaultCenterPosition[1]) // eslint-disable-line no-undef | ||
50 | }); | 51 | }); |
51 | - | ||
52 | if (initCallback) { | 52 | if (initCallback) { |
53 | initCallback(); | 53 | initCallback(); |
54 | } | 54 | } |
@@ -53,6 +53,12 @@ export default class TbMapWidgetV2 { | @@ -53,6 +53,12 @@ export default class TbMapWidgetV2 { | ||
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | + if (angular.isUndefined(settings.defaultCenterPosition)) { | ||
57 | + settings.defaultCenterPosition = [0,0]; | ||
58 | + } else if (angular.isString(settings.defaultCenterPosition)) { | ||
59 | + settings.defaultCenterPosition = settings.defaultCenterPosition.split(',').map(x => +x); | ||
60 | + } | ||
61 | + | ||
56 | this.dontFitMapBounds = settings.fitMapBounds === false; | 62 | this.dontFitMapBounds = settings.fitMapBounds === false; |
57 | 63 | ||
58 | if (!useDynamicLocations) { | 64 | if (!useDynamicLocations) { |
@@ -78,9 +84,9 @@ export default class TbMapWidgetV2 { | @@ -78,9 +84,9 @@ export default class TbMapWidgetV2 { | ||
78 | tbMap.tooltipActionsMap[descriptor.name] = descriptor; | 84 | tbMap.tooltipActionsMap[descriptor.name] = descriptor; |
79 | }); | 85 | }); |
80 | 86 | ||
81 | - let openStreetMapProvider = {}; | 87 | + let openStreetMapProvider = {}; |
82 | if (mapProvider === 'google-map') { | 88 | if (mapProvider === 'google-map') { |
83 | - this.map = new TbGoogleMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, settings.gmApiKey, settings.gmDefaultMapType); | 89 | + this.map = new TbGoogleMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, settings.gmApiKey, settings.gmDefaultMapType, settings.defaultCenterPosition); |
84 | } else if (mapProvider === 'openstreet-map') { | 90 | } else if (mapProvider === 'openstreet-map') { |
85 | if (settings.useCustomProvider && settings.customProviderTileUrl) { | 91 | if (settings.useCustomProvider && settings.customProviderTileUrl) { |
86 | openStreetMapProvider.name = settings.customProviderTileUrl; | 92 | openStreetMapProvider.name = settings.customProviderTileUrl; |
@@ -88,19 +94,20 @@ export default class TbMapWidgetV2 { | @@ -88,19 +94,20 @@ export default class TbMapWidgetV2 { | ||
88 | } else { | 94 | } else { |
89 | openStreetMapProvider.name = settings.mapProvider; | 95 | openStreetMapProvider.name = settings.mapProvider; |
90 | } | 96 | } |
91 | - this.map = new TbOpenStreetMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, openStreetMapProvider); | 97 | + this.map = new TbOpenStreetMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, openStreetMapProvider, null,settings.defaultCenterPosition); |
92 | } else if (mapProvider === 'here') { | 98 | } else if (mapProvider === 'here') { |
93 | openStreetMapProvider.name = settings.mapProvider; | 99 | openStreetMapProvider.name = settings.mapProvider; |
94 | - this.map = new TbOpenStreetMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, openStreetMapProvider, settings.credentials); | 100 | + this.map = new TbOpenStreetMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, openStreetMapProvider, settings.credentials, settings.defaultCenterPosition); |
95 | } else if (mapProvider === 'image-map') { | 101 | } else if (mapProvider === 'image-map') { |
96 | this.map = new TbImageMap(this.ctx, $element, this.utils, initCallback, | 102 | this.map = new TbImageMap(this.ctx, $element, this.utils, initCallback, |
97 | settings.mapImageUrl, | 103 | settings.mapImageUrl, |
98 | settings.disableScrollZooming, | 104 | settings.disableScrollZooming, |
99 | settings.posFunction, | 105 | settings.posFunction, |
100 | settings.imageEntityAlias, | 106 | settings.imageEntityAlias, |
101 | - settings.imageUrlAttribute); | 107 | + settings.imageUrlAttribute, |
108 | + settings.useDefaultCenterPosition ? settings.defaultCenterPosition: null); | ||
102 | } else if (mapProvider === 'tencent-map') { | 109 | } else if (mapProvider === 'tencent-map') { |
103 | - this.map = new TbTencentMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, settings.tmApiKey, settings.tmDefaultMapType); | 110 | + this.map = new TbTencentMap($element, this.utils, initCallback, this.defaultZoomLevel, this.dontFitMapBounds, settings.disableScrollZooming, minZoomLevel, settings.tmApiKey, settings.tmDefaultMapType, settings.defaultCenterPosition); |
104 | } | 111 | } |
105 | 112 | ||
106 | 113 | ||
@@ -156,7 +163,8 @@ export default class TbMapWidgetV2 { | @@ -156,7 +163,8 @@ export default class TbMapWidgetV2 { | ||
156 | 163 | ||
157 | this.locationSettings.showLabel = this.ctx.settings.showLabel !== false; | 164 | this.locationSettings.showLabel = this.ctx.settings.showLabel !== false; |
158 | this.locationSettings.displayTooltip = this.ctx.settings.showTooltip !== false; | 165 | this.locationSettings.displayTooltip = this.ctx.settings.showTooltip !== false; |
159 | - this.locationSettings.displayTooltipAction = this.ctx.settings.showTooltipAction && this.ctx.settings.showTooltipAction.length ? this.ctx.settings.showTooltipAction : "click"; | 166 | + this.locationSettings.useDefaultCenterPosition = this.ctx.settings.useDefaultCenterPosition === true; |
167 | + this.locationSettings.displayTooltipAction = this.ctx.settings.showTooltipAction && this.ctx.settings.showTooltipAction.length ? this.ctx.settings.showTooltipAction : "click"; | ||
160 | this.locationSettings.autocloseTooltip = this.ctx.settings.autocloseTooltip !== false; | 168 | this.locationSettings.autocloseTooltip = this.ctx.settings.autocloseTooltip !== false; |
161 | this.locationSettings.showPolygon = this.ctx.settings.showPolygon === true; | 169 | this.locationSettings.showPolygon = this.ctx.settings.showPolygon === true; |
162 | this.locationSettings.labelColor = this.ctx.widgetConfig.color || '#000000'; | 170 | this.locationSettings.labelColor = this.ctx.widgetConfig.color || '#000000'; |
@@ -455,8 +463,8 @@ export default class TbMapWidgetV2 { | @@ -455,8 +463,8 @@ export default class TbMapWidgetV2 { | ||
455 | } | 463 | } |
456 | 464 | ||
457 | function createUpdatePolygon(location, dataMap) { | 465 | function createUpdatePolygon(location, dataMap) { |
458 | - if (location.settings.showPolygon && dataMap.dsDataMap[location.dsIndex][location.settings.polygonKeyName] !== null) { | ||
459 | - let polygonLatLngsRaw = angular.fromJson(dataMap.dsDataMap[location.dsIndex][location.settings.polygonKeyName]); | 466 | + if (location.settings.showPolygon && dataMap.dsDataMap[location.dsIndex][location.settings.polygonKeyName] !== null) { |
467 | + let polygonLatLngsRaw = angular.fromJson(dataMap.dsDataMap[location.dsIndex][location.settings.polygonKeyName]); | ||
460 | let polygonLatLngs = !polygonLatLngsRaw || mapPolygonArray(polygonLatLngsRaw); | 468 | let polygonLatLngs = !polygonLatLngsRaw || mapPolygonArray(polygonLatLngsRaw); |
461 | if (!location.polygon && polygonLatLngs.length > 0) { | 469 | if (!location.polygon && polygonLatLngs.length > 0) { |
462 | location.polygon = tbMap.map.createPolygon(polygonLatLngs, location.settings, location, function (event) { | 470 | location.polygon = tbMap.map.createPolygon(polygonLatLngs, location.settings, location, function (event) { |
@@ -476,7 +484,7 @@ export default class TbMapWidgetV2 { | @@ -476,7 +484,7 @@ export default class TbMapWidgetV2 { | ||
476 | } | 484 | } |
477 | 485 | ||
478 | function loadLocations(data, datasources) { | 486 | function loadLocations(data, datasources) { |
479 | - var bounds = tbMap.map.createBounds(); | 487 | + var bounds = tbMap.locationSettings.useDefaultCenterPosition ? tbMap.map.createBounds().extend(tbMap.map.map.getCenter()) : tbMap.map.createBounds(); |
480 | tbMap.locations = []; | 488 | tbMap.locations = []; |
481 | var dataMap = toLabelValueMap(data, datasources); | 489 | var dataMap = toLabelValueMap(data, datasources); |
482 | var currentDatasource = null; | 490 | var currentDatasource = null; |
@@ -521,12 +529,13 @@ export default class TbMapWidgetV2 { | @@ -521,12 +529,13 @@ export default class TbMapWidgetV2 { | ||
521 | } | 529 | } |
522 | tbMap.locations.push(location); | 530 | tbMap.locations.push(location); |
523 | updateLocation(location, data, dataMap); | 531 | updateLocation(location, data, dataMap); |
524 | - | ||
525 | - if (location.polyline) { | ||
526 | - tbMap.map.extendBounds(bounds, location.polyline); | ||
527 | - } else if (location.marker) { | ||
528 | - tbMap.map.extendBoundsWithMarker(bounds, location.marker); | ||
529 | - } | 532 | + if (!tbMap.locationSettings.useDefaultCenterPosition) { |
533 | + if (location.polyline) { | ||
534 | + tbMap.map.extendBounds(bounds, location.polyline); | ||
535 | + } else if (location.marker) { | ||
536 | + tbMap.map.extendBoundsWithMarker(bounds, location.marker); | ||
537 | + } | ||
538 | + } | ||
530 | latIndex = -1; | 539 | latIndex = -1; |
531 | lngIndex = -1; | 540 | lngIndex = -1; |
532 | } | 541 | } |
@@ -548,7 +557,9 @@ export default class TbMapWidgetV2 { | @@ -548,7 +557,9 @@ export default class TbMapWidgetV2 { | ||
548 | }); | 557 | }); |
549 | tbMap.locations.push(location); | 558 | tbMap.locations.push(location); |
550 | createUpdatePolygon(location, dataMap); | 559 | createUpdatePolygon(location, dataMap); |
551 | - tbMap.map.extendBounds(bounds, location.polygon); | 560 | + if (!tbMap.locationSettings.useDefaultCenterPosition) { |
561 | + tbMap.map.extendBounds(bounds, location.polygon); | ||
562 | + } | ||
552 | } | 563 | } |
553 | }); | 564 | }); |
554 | 565 | ||
@@ -576,19 +587,21 @@ export default class TbMapWidgetV2 { | @@ -576,19 +587,21 @@ export default class TbMapWidgetV2 { | ||
576 | 587 | ||
577 | function updateLocations(data, datasources) { | 588 | function updateLocations(data, datasources) { |
578 | var locationsChanged = false; | 589 | var locationsChanged = false; |
579 | - var bounds = tbMap.map.createBounds(); | 590 | + var bounds = tbMap.locationSettings.useDefaultCenterPosition ? tbMap.map.createBounds().extend(tbMap.map.map.getCenter()) : tbMap.map.createBounds(); |
580 | var dataMap = toLabelValueMap(data, datasources); | 591 | var dataMap = toLabelValueMap(data, datasources); |
581 | for (var p = 0; p < tbMap.locations.length; p++) { | 592 | for (var p = 0; p < tbMap.locations.length; p++) { |
582 | var location = tbMap.locations[p]; | 593 | var location = tbMap.locations[p]; |
583 | locationsChanged |= updateLocation(location, data, dataMap); | 594 | locationsChanged |= updateLocation(location, data, dataMap); |
584 | - createUpdatePolygon(location, dataMap); | ||
585 | - if (location.polyline) { | ||
586 | - tbMap.map.extendBounds(bounds, location.polyline); | ||
587 | - } else if (location.marker) { | ||
588 | - tbMap.map.extendBoundsWithMarker(bounds, location.marker); | ||
589 | - } else if (location.polygon) { | ||
590 | - tbMap.map.extendBounds(bounds, location.polygon); | ||
591 | - } | 595 | + createUpdatePolygon(location, dataMap); |
596 | + if (!tbMap.locationSettings.useDefaultCenterPosition) { | ||
597 | + if (location.polyline) { | ||
598 | + tbMap.map.extendBounds(bounds, location.polyline); | ||
599 | + } else if (location.marker) { | ||
600 | + tbMap.map.extendBoundsWithMarker(bounds, location.marker); | ||
601 | + } else if (location.polygon) { | ||
602 | + tbMap.map.extendBounds(bounds, location.polygon); | ||
603 | + } | ||
604 | + } | ||
592 | } | 605 | } |
593 | if (locationsChanged && tbMap.initBounds) { | 606 | if (locationsChanged && tbMap.initBounds) { |
594 | let dataReceived = datasources.every( | 607 | let dataReceived = datasources.every( |
@@ -626,7 +639,8 @@ export default class TbMapWidgetV2 { | @@ -626,7 +639,8 @@ export default class TbMapWidgetV2 { | ||
626 | if (this.subscription.data) { | 639 | if (this.subscription.data) { |
627 | if (!this.locations) { | 640 | if (!this.locations) { |
628 | loadLocations(this.subscription.data, this.subscription.datasources); | 641 | loadLocations(this.subscription.data, this.subscription.datasources); |
629 | - } else { | 642 | + |
643 | + } else { | ||
630 | updateLocations(this.subscription.data, this.subscription.datasources); | 644 | updateLocations(this.subscription.data, this.subscription.datasources); |
631 | } | 645 | } |
632 | var tooltips = this.map.getTooltips(); | 646 | var tooltips = this.map.getTooltips(); |
@@ -644,22 +658,24 @@ export default class TbMapWidgetV2 { | @@ -644,22 +658,24 @@ export default class TbMapWidgetV2 { | ||
644 | let map = this.map; | 658 | let map = this.map; |
645 | if (this.locations && this.locations.length > 0) { | 659 | if (this.locations && this.locations.length > 0) { |
646 | map.invalidateSize(); | 660 | map.invalidateSize(); |
647 | - var bounds = map.createBounds(); | ||
648 | - if (this.markers && this.markers.length>0) { | ||
649 | - this.markers.forEach(function (marker) { | ||
650 | - map.extendBoundsWithMarker(bounds, marker); | ||
651 | - }); | ||
652 | - } | ||
653 | - if (this.polylines && this.polylines.length>0) { | ||
654 | - this.polylines.forEach(function (polyline) { | ||
655 | - map.extendBounds(bounds, polyline); | ||
656 | - }) | ||
657 | - } | ||
658 | - if (this.polygons && this.polygons.length > 0) { | ||
659 | - this.polygons.forEach(function (polygon) { | ||
660 | - map.extendBounds(bounds, polygon); | ||
661 | - }) | ||
662 | - } | 661 | + var bounds = this.locationSettings.useDefaultCenterPosition ? map.createBounds().extend(map.map.getCenter()) : map.createBounds(); |
662 | + if (!this.locationSettings.useDefaultCenterPosition) { | ||
663 | + if (this.markers && this.markers.length > 0) { | ||
664 | + this.markers.forEach(function (marker) { | ||
665 | + map.extendBoundsWithMarker(bounds, marker); | ||
666 | + }); | ||
667 | + } | ||
668 | + if (this.polylines && this.polylines.length > 0) { | ||
669 | + this.polylines.forEach(function (polyline) { | ||
670 | + map.extendBounds(bounds, polyline); | ||
671 | + }) | ||
672 | + } | ||
673 | + if (this.polygons && this.polygons.length > 0) { | ||
674 | + this.polygons.forEach(function (polygon) { | ||
675 | + map.extendBounds(bounds, polygon); | ||
676 | + }) | ||
677 | + } | ||
678 | + } | ||
663 | map.fitBounds(bounds); | 679 | map.fitBounds(bounds); |
664 | } | 680 | } |
665 | } | 681 | } |
@@ -962,6 +978,16 @@ const commonMapSettingsSchema = | @@ -962,6 +978,16 @@ const commonMapSettingsSchema = | ||
962 | "title": "Default map zoom level (1 - 20)", | 978 | "title": "Default map zoom level (1 - 20)", |
963 | "type": "number" | 979 | "type": "number" |
964 | }, | 980 | }, |
981 | + "useDefaultCenterPosition": { | ||
982 | + "title": "Use default map center position", | ||
983 | + "type": "boolean", | ||
984 | + "default": false | ||
985 | + }, | ||
986 | + "defaultCenterPosition": { | ||
987 | + "title": "Default map center position (0,0)", | ||
988 | + "type": "string", | ||
989 | + "default" : "0,0" | ||
990 | + }, | ||
965 | "fitMapBounds": { | 991 | "fitMapBounds": { |
966 | "title": "Fit map bounds to cover all markers", | 992 | "title": "Fit map bounds to cover all markers", |
967 | "type": "boolean", | 993 | "type": "boolean", |
@@ -1116,6 +1142,8 @@ const commonMapSettingsSchema = | @@ -1116,6 +1142,8 @@ const commonMapSettingsSchema = | ||
1116 | }, | 1142 | }, |
1117 | "form": [ | 1143 | "form": [ |
1118 | "defaultZoomLevel", | 1144 | "defaultZoomLevel", |
1145 | + "useDefaultCenterPosition", | ||
1146 | + "defaultCenterPosition", | ||
1119 | "fitMapBounds", | 1147 | "fitMapBounds", |
1120 | "disableScrollZooming", | 1148 | "disableScrollZooming", |
1121 | "latKeyName", | 1149 | "latKeyName", |
@@ -19,7 +19,7 @@ import 'leaflet-providers'; | @@ -19,7 +19,7 @@ import 'leaflet-providers'; | ||
19 | 19 | ||
20 | export default class TbOpenStreetMap { | 20 | export default class TbOpenStreetMap { |
21 | 21 | ||
22 | - constructor($containerElement, utils, initCallback, defaultZoomLevel, dontFitMapBounds, disableScrollZooming, minZoomLevel, mapProvider, credentials) { | 22 | + constructor($containerElement, utils, initCallback, defaultZoomLevel, dontFitMapBounds, disableScrollZooming, minZoomLevel, mapProvider, credentials, defaultCenterPosition) { |
23 | 23 | ||
24 | this.utils = utils; | 24 | this.utils = utils; |
25 | this.defaultZoomLevel = defaultZoomLevel; | 25 | this.defaultZoomLevel = defaultZoomLevel; |
@@ -38,7 +38,8 @@ export default class TbOpenStreetMap { | @@ -38,7 +38,8 @@ export default class TbOpenStreetMap { | ||
38 | credentials.app_code = credentials.app_code || "p6NPiITB3Vv0GMUFnkLOOg"; | 38 | credentials.app_code = credentials.app_code || "p6NPiITB3Vv0GMUFnkLOOg"; |
39 | } | 39 | } |
40 | 40 | ||
41 | - this.map = L.map($containerElement[0]).setView([0, 0], this.defaultZoomLevel || 8); | 41 | + defaultCenterPosition = defaultCenterPosition || [0,0]; |
42 | + this.map = L.map($containerElement[0]).setView(defaultCenterPosition, this.defaultZoomLevel || 8); | ||
42 | 43 | ||
43 | if (disableScrollZooming) { | 44 | if (disableScrollZooming) { |
44 | this.map.scrollWheelZoom.disable(); | 45 | this.map.scrollWheelZoom.disable(); |
@@ -19,7 +19,7 @@ var tmGlobals = { | @@ -19,7 +19,7 @@ var tmGlobals = { | ||
19 | } | 19 | } |
20 | 20 | ||
21 | export default class TbTencentMap { | 21 | export default class TbTencentMap { |
22 | - constructor($containerElement, utils, initCallback, defaultZoomLevel, dontFitMapBounds, disableScrollZooming, minZoomLevel, tmApiKey, tmDefaultMapType) { | 22 | + constructor($containerElement, utils, initCallback, defaultZoomLevel, dontFitMapBounds, disableScrollZooming, minZoomLevel, tmApiKey, tmDefaultMapType, defaultCenterPosition) { |
23 | var tbMap = this; | 23 | var tbMap = this; |
24 | this.utils = utils; | 24 | this.utils = utils; |
25 | this.defaultZoomLevel = defaultZoomLevel; | 25 | this.defaultZoomLevel = defaultZoomLevel; |
@@ -27,6 +27,7 @@ export default class TbTencentMap { | @@ -27,6 +27,7 @@ export default class TbTencentMap { | ||
27 | this.minZoomLevel = minZoomLevel; | 27 | this.minZoomLevel = minZoomLevel; |
28 | this.tooltips = []; | 28 | this.tooltips = []; |
29 | this.defaultMapType = tmDefaultMapType; | 29 | this.defaultMapType = tmDefaultMapType; |
30 | + this.defaultCenterPosition =defaultCenterPosition; | ||
30 | 31 | ||
31 | function clearGlobalId() { | 32 | function clearGlobalId() { |
32 | if (tmGlobals.loadingTmId && tmGlobals.loadingTmId === tbMap.mapId) { | 33 | if (tmGlobals.loadingTmId && tmGlobals.loadingTmId === tbMap.mapId) { |
@@ -44,7 +45,8 @@ export default class TbTencentMap { | @@ -44,7 +45,8 @@ export default class TbTencentMap { | ||
44 | tbMap.map = new qq.maps.Map($containerElement[0], { // eslint-disable-line no-undef | 45 | tbMap.map = new qq.maps.Map($containerElement[0], { // eslint-disable-line no-undef |
45 | scrollwheel: !disableScrollZooming, | 46 | scrollwheel: !disableScrollZooming, |
46 | mapTypeId: getTencentMapTypeId(tbMap.defaultMapType), | 47 | mapTypeId: getTencentMapTypeId(tbMap.defaultMapType), |
47 | - zoom: tbMap.defaultZoomLevel || 8 | 48 | + zoom: tbMap.defaultZoomLevel || 8, |
49 | + center: new qq.maps.LatLng(tbMap.defaultCenterPosition[0],tbMap.defaultCenterPosition[1]) // eslint-disable-line no-undef | ||
48 | }); | 50 | }); |
49 | 51 | ||
50 | if (initCallback) { | 52 | if (initCallback) { |