Skip to content

Commit

Permalink
adress suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Zedwag committed Sep 15, 2024
1 parent 726a10f commit c742ccf
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 41 deletions.
7 changes: 3 additions & 4 deletions packages/devextreme/js/__internal/ui/map/m_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const Map = Widget.inherit({
google: '',
googleStatic: '',
},
googleMapConfig: {
providerConfig: {
mapId: '',
useAdvancedMarkers: true,
},
Expand Down Expand Up @@ -89,7 +89,7 @@ const Map = Widget.inherit({
_setDeprecatedOptions() {
this.callBase();
extend(this._deprecatedOptions, {
'googleMapConfig.useAdvancedMarkers': { since: '24.2', message: 'Google deprecated the original map markers. Transition to advanced markers for future compatibility.' },
'providerConfig.useAdvancedMarkers': { since: '24.2', message: 'Google deprecated the original map markers. Transition to advanced markers for future compatibility.' },
});
},

Expand Down Expand Up @@ -250,10 +250,9 @@ const Map = Widget.inherit({
case 'markerIconSrc':
this._queueAsyncAction('updateMarkers', this._rendered.markers, this._rendered.markers);
break;
case 'googleMapConfig':
case 'providerConfig':
this._suppressAsyncAction = true;
this._invalidate();

break;
case 'onReady':
case 'onUpdated':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ const GoogleProvider = DynamicProvider.inherit({
return new Promise((resolve) => {
this._resolveLocation(this._option('center')).then((center) => {
const disableDefaultUI = !this._option('controls');
const { mapId } = this._option('googleMapConfig');
const providerConfig = this._option('providerConfig');
const mapId = providerConfig?.mapId ?? '';
this._map = new google.maps.Map(this._$container[0], {
center,
disableDefaultUI,
Expand Down Expand Up @@ -305,18 +306,21 @@ const GoogleProvider = DynamicProvider.inherit({
}, options.htmlOffset),
});
} else {
const { useAdvancedMarkers } = this._option('googleMapConfig');
const providerConfig = this._option('providerConfig');
const useAdvancedMarkers = providerConfig?.useAdvancedMarkers ?? true;
const icon = options.iconSrc ?? this._option('markerIconSrc');
if (useAdvancedMarkers) {
const content = icon ? this._createIconTemplate(icon) : undefined;
marker = new google.maps.marker.AdvancedMarkerElement({
position: location,
map: this._map,
content: this._createIconTemplate(this._option('markerIconSrc')),
content,
});
} else {
marker = new google.maps.Marker({
position: location,
map: this._map,
icon: options.iconSrc || this._option('markerIconSrc'),
icon,
});
}
}
Expand Down Expand Up @@ -347,13 +351,11 @@ const GoogleProvider = DynamicProvider.inherit({
},

_createIconTemplate(iconSrc: string) {
const imgNode = document.createElement('img');
const $img = $(`<img src='${iconSrc}' alt='Marker icon' >`);

imgNode.src = iconSrc;
imgNode.alt = 'Marker icon';
imgNode.classList.add(MAP_MARKER_CLASS);
$img.addClass(MAP_MARKER_CLASS);

return imgNode;
return $img[0];
},

_renderTooltip(marker, options) {
Expand Down
4 changes: 2 additions & 2 deletions packages/devextreme/testing/helpers/forMap/googleMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
google.markerOptions = {};
google.markerOptions.mapSpecified = options.map instanceof google.maps.Map;
google.markerOptions.position = options.position;
google.markerOptions.icon = options.content.src;
google.markerOptions.icon = options.content?.src;
}

this.getAnimation = function() {};
Expand All @@ -298,7 +298,7 @@
this.setDraggable = function() {};
this.setFlat = function() {};
this.getIcon = function() {
return options.content.src;
return options.content?.src;
};
this.setIcon = function() {};
this.setMap = function(map) {
Expand Down
Loading

0 comments on commit c742ccf

Please sign in to comment.