forked from DevExpress/DevExtreme
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch, Resizable, Map: ignore errors after move to TS
- Loading branch information
1 parent
223d2ef
commit 8c99f89
Showing
23 changed files
with
2,828 additions
and
2,832 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
1,214 changes: 602 additions & 612 deletions
1,214
packages/devextreme/js/__internal/ui/m_resizable.ts
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
843 changes: 425 additions & 418 deletions
843
packages/devextreme/js/__internal/ui/map/m_provider.dynamic.bing.ts
Large diffs are not rendered by default.
Oops, something went wrong.
818 changes: 410 additions & 408 deletions
818
packages/devextreme/js/__internal/ui/map/m_provider.dynamic.google.ts
Large diffs are not rendered by default.
Oops, something went wrong.
384 changes: 187 additions & 197 deletions
384
packages/devextreme/js/__internal/ui/map/m_provider.dynamic.ts
Large diffs are not rendered by default.
Oops, something went wrong.
331 changes: 168 additions & 163 deletions
331
packages/devextreme/js/__internal/ui/map/m_provider.google_static.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,192 +1,197 @@ | ||
import { getWidth, getHeight } from '../../core/utils/size'; | ||
import { each } from '../../core/utils/iterator'; | ||
import eventsEngine from '../../events/core/events_engine'; | ||
import Provider from './provider'; | ||
import Color from '../../color'; | ||
import { name as clickEventName } from '../../events/click'; | ||
import Color from '@js/color'; | ||
import { each } from '@js/core/utils/iterator'; | ||
import { getHeight, getWidth } from '@js/core/utils/size'; | ||
import { name as clickEventName } from '@js/events/click'; | ||
import eventsEngine from '@js/events/core/events_engine'; | ||
|
||
import Provider from './m_provider'; | ||
|
||
let GOOGLE_STATIC_URL = 'https://maps.google.com/maps/api/staticmap?'; | ||
|
||
const GoogleStaticProvider = Provider.inherit({ | ||
|
||
_locationToString: function(location) { | ||
const latLng = this._getLatLng(location); | ||
return latLng ? (latLng.lat + ',' + latLng.lng) : location.toString().replace(/ /g, '+'); | ||
}, | ||
|
||
_renderImpl: function() { | ||
return this._updateMap(); | ||
}, | ||
|
||
updateDimensions: function() { | ||
return this._updateMap(); | ||
}, | ||
|
||
updateMapType: function() { | ||
return this._updateMap(); | ||
}, | ||
|
||
updateBounds: function() { | ||
return Promise.resolve(); | ||
}, | ||
|
||
updateCenter: function() { | ||
return this._updateMap(); | ||
}, | ||
|
||
updateZoom: function() { | ||
return this._updateMap(); | ||
}, | ||
|
||
updateControls: function() { | ||
return Promise.resolve(); | ||
}, | ||
|
||
addMarkers: function(options) { | ||
const that = this; | ||
|
||
return this._updateMap().then(function(result) { | ||
each(options, function(_, options) { | ||
that._fireMarkerAddedAction({ | ||
options: options | ||
}); | ||
}); | ||
return result; | ||
}); | ||
}, | ||
|
||
removeMarkers: function(options) { | ||
const that = this; | ||
|
||
return this._updateMap().then(function(result) { | ||
each(options, function(_, options) { | ||
that._fireMarkerRemovedAction({ | ||
options: options | ||
}); | ||
}); | ||
return result; | ||
}); | ||
}, | ||
|
||
adjustViewport: function() { | ||
return Promise.resolve(); | ||
}, | ||
|
||
addRoutes: function(options) { | ||
const that = this; | ||
|
||
return this._updateMap().then(function(result) { | ||
each(options, function(_, options) { | ||
that._fireRouteAddedAction({ | ||
options: options | ||
}); | ||
}); | ||
return result; | ||
}); | ||
}, | ||
|
||
removeRoutes: function(options) { | ||
const that = this; | ||
|
||
return this._updateMap().then(function(result) { | ||
each(options, function(_, options) { | ||
that._fireRouteRemovedAction({ | ||
options: options | ||
}); | ||
}); | ||
return result; | ||
}); | ||
}, | ||
|
||
clean: function() { | ||
this._$container.css('backgroundImage', 'none'); | ||
eventsEngine.off(this._$container, this._addEventNamespace(clickEventName)); | ||
|
||
return Promise.resolve(); | ||
}, | ||
|
||
mapRendered: function() { | ||
return true; | ||
}, | ||
_locationToString(location) { | ||
const latLng = this._getLatLng(location); | ||
return latLng ? `${latLng.lat},${latLng.lng}` : location.toString().replace(/ /g, '+'); | ||
}, | ||
|
||
_updateMap: function() { | ||
const key = this._keyOption('googleStatic'); | ||
const $container = this._$container; | ||
_renderImpl() { | ||
return this._updateMap(); | ||
}, | ||
|
||
const requestOptions = [ | ||
'sensor=false', | ||
'size=' + Math.round(getWidth($container)) + 'x' + Math.round(getHeight($container)), | ||
'maptype=' + this._option('type'), | ||
'center=' + this._locationToString(this._option('center')), | ||
'zoom=' + this._option('zoom'), | ||
this._markersSubstring() | ||
]; | ||
requestOptions.push.apply(requestOptions, this._routeSubstrings()); | ||
if(key) { | ||
requestOptions.push('key=' + key); | ||
} | ||
updateDimensions() { | ||
return this._updateMap(); | ||
}, | ||
|
||
const request = GOOGLE_STATIC_URL + requestOptions.join('&'); | ||
updateMapType() { | ||
return this._updateMap(); | ||
}, | ||
|
||
this._$container.css('background', 'url("' + request + '") no-repeat 0 0'); | ||
updateBounds() { | ||
return Promise.resolve(); | ||
}, | ||
|
||
this._attachClickEvent(); | ||
updateCenter() { | ||
return this._updateMap(); | ||
}, | ||
|
||
return Promise.resolve(true); | ||
}, | ||
updateZoom() { | ||
return this._updateMap(); | ||
}, | ||
|
||
_markersSubstring: function() { | ||
const that = this; | ||
const markers = []; | ||
const markerIcon = this._option('markerIconSrc'); | ||
updateControls() { | ||
return Promise.resolve(); | ||
}, | ||
|
||
if(markerIcon) { | ||
markers.push('icon:' + markerIcon); | ||
} | ||
addMarkers(options) { | ||
const that = this; | ||
|
||
each(this._option('markers'), function(_, marker) { | ||
markers.push(that._locationToString(marker.location)); | ||
return this._updateMap().then((result) => { | ||
each(options, (_, options) => { | ||
that._fireMarkerAddedAction({ | ||
options, | ||
}); | ||
}); | ||
return result; | ||
}); | ||
}, | ||
|
||
removeMarkers(options) { | ||
const that = this; | ||
|
||
return this._updateMap().then((result) => { | ||
each(options, (_, options) => { | ||
that._fireMarkerRemovedAction({ | ||
options, | ||
}); | ||
}); | ||
return result; | ||
}); | ||
}, | ||
|
||
adjustViewport() { | ||
return Promise.resolve(); | ||
}, | ||
|
||
addRoutes(options) { | ||
const that = this; | ||
|
||
return this._updateMap().then((result) => { | ||
each(options, (_, options) => { | ||
that._fireRouteAddedAction({ | ||
options, | ||
}); | ||
}); | ||
return result; | ||
}); | ||
}, | ||
|
||
removeRoutes(options) { | ||
const that = this; | ||
|
||
return this._updateMap().then((result) => { | ||
each(options, (_, options) => { | ||
that._fireRouteRemovedAction({ | ||
options, | ||
}); | ||
}); | ||
return result; | ||
}); | ||
}, | ||
|
||
clean() { | ||
this._$container.css('backgroundImage', 'none'); | ||
eventsEngine.off(this._$container, this._addEventNamespace(clickEventName)); | ||
|
||
return Promise.resolve(); | ||
}, | ||
|
||
mapRendered() { | ||
return true; | ||
}, | ||
|
||
_updateMap() { | ||
const key = this._keyOption('googleStatic'); | ||
const $container = this._$container; | ||
|
||
const requestOptions = [ | ||
'sensor=false', | ||
`size=${Math.round(getWidth($container))}x${Math.round(getHeight($container))}`, | ||
`maptype=${this._option('type')}`, | ||
`center=${this._locationToString(this._option('center'))}`, | ||
`zoom=${this._option('zoom')}`, | ||
this._markersSubstring(), | ||
]; | ||
requestOptions.push.apply(requestOptions, this._routeSubstrings()); | ||
if (key) { | ||
requestOptions.push(`key=${key}`); | ||
} | ||
|
||
return 'markers=' + markers.join('|'); | ||
}, | ||
|
||
_routeSubstrings: function() { | ||
const that = this; | ||
const routes = []; | ||
const request = GOOGLE_STATIC_URL + requestOptions.join('&'); | ||
|
||
each(this._option('routes'), function(_, route) { | ||
const color = new Color(route.color || that._defaultRouteColor()).toHex().replace('#', '0x'); | ||
const opacity = Math.round((route.opacity || that._defaultRouteOpacity()) * 255).toString(16); | ||
const width = route.weight || that._defaultRouteWeight(); | ||
const locations = []; | ||
each(route.locations, function(_, routePoint) { | ||
locations.push(that._locationToString(routePoint)); | ||
}); | ||
this._$container.css('background', `url("${request}") no-repeat 0 0`); | ||
|
||
routes.push('path=color:' + color + opacity + '|weight:' + width + '|' + locations.join('|')); | ||
}); | ||
this._attachClickEvent(); | ||
|
||
return routes; | ||
}, | ||
return Promise.resolve(true); | ||
}, | ||
|
||
_attachClickEvent: function() { | ||
const that = this; | ||
const eventName = this._addEventNamespace(clickEventName); | ||
_markersSubstring() { | ||
const that = this; | ||
const markers = []; | ||
const markerIcon = this._option('markerIconSrc'); | ||
|
||
eventsEngine.off(this._$container, eventName); | ||
eventsEngine.on(this._$container, eventName, function(e) { | ||
that._fireClickAction({ event: e }); | ||
}); | ||
if (markerIcon) { | ||
// @ts-expect-error | ||
markers.push(`icon:${markerIcon}`); | ||
} | ||
|
||
each(this._option('markers'), (_, marker) => { | ||
// @ts-expect-error | ||
markers.push(that._locationToString(marker.location)); | ||
}); | ||
|
||
return `markers=${markers.join('|')}`; | ||
}, | ||
|
||
_routeSubstrings() { | ||
const that = this; | ||
const routes = []; | ||
|
||
each(this._option('routes'), (_, route) => { | ||
const color = new Color(route.color || that._defaultRouteColor()).toHex().replace('#', '0x'); | ||
const opacity = Math.round((route.opacity || that._defaultRouteOpacity()) * 255).toString(16); | ||
const width = route.weight || that._defaultRouteWeight(); | ||
const locations = []; | ||
each(route.locations, (_, routePoint) => { | ||
// @ts-expect-error | ||
locations.push(that._locationToString(routePoint)); | ||
}); | ||
// @ts-expect-error | ||
routes.push(`path=color:${color}${opacity}|weight:${width}|${locations.join('|')}`); | ||
}); | ||
|
||
return routes; | ||
}, | ||
|
||
_attachClickEvent() { | ||
const that = this; | ||
const eventName = this._addEventNamespace(clickEventName); | ||
|
||
eventsEngine.off(this._$container, eventName); | ||
eventsEngine.on(this._$container, eventName, (e) => { | ||
that._fireClickAction({ event: e }); | ||
}); | ||
}, | ||
|
||
}); | ||
|
||
///#DEBUG | ||
GoogleStaticProvider.remapConstant = function(newValue) { | ||
GOOGLE_STATIC_URL = newValue; | ||
/// #DEBUG | ||
// @ts-expect-error | ||
GoogleStaticProvider.remapConstant = function (newValue) { | ||
GOOGLE_STATIC_URL = newValue; | ||
}; | ||
|
||
///#ENDDEBUG | ||
/// #ENDDEBUG | ||
|
||
export default GoogleStaticProvider; |
Oops, something went wrong.