diff --git a/MPBadgePosition.ts b/MPBadgePosition.ts new file mode 100644 index 0000000..99be9b1 --- /dev/null +++ b/MPBadgePosition.ts @@ -0,0 +1,12 @@ +/** + * The possible position of the badge on an icon. + * + * @export + * @enum {number} + */ +export enum MPBadgePosition { + bottomLeft, + bottomRight, + topLeft, + topRight, +} \ No newline at end of file diff --git a/MPDirectionsService.ts b/MPDirectionsService.ts index 4750582..e2a5b5e 100644 --- a/MPDirectionsService.ts +++ b/MPDirectionsService.ts @@ -57,6 +57,31 @@ export default class MPDirectionsService { return DirectionsService.clearWayType(this.id); } + /** + * Add an excludeWayType, these are based on [OSM highways](https://wiki.openstreetmap.org/wiki/Key:highway). + * + * Supported types are defined in {@link MPHighway}. + * + * @public + * @async + * @param {string} wayType + * @returns {Promise} + */ + public async addExcludeWayType(wayType: string): Promise { + return DirectionsService.addExcludeWayType(wayType, this.id); + } + + /** + * Clears all added excludeWayType. + * + * @public + * @async + * @returns {Promise} + */ + public async clearExcludeWayType(): Promise { + return DirectionsService.clearExcludeWayType(this.id); + } + /** * Sets whether routes should use departure time or arrival time when using the transit travel mode. * diff --git a/MPDisplayRule.ts b/MPDisplayRule.ts index 0fcec92..d91d885 100644 --- a/MPDisplayRule.ts +++ b/MPDisplayRule.ts @@ -1,5 +1,8 @@ import { NativeModules } from 'react-native'; import { MPError, MPIconSize } from "../../index"; +import { MPIconPlacement } from './MPIconPlacement'; +import { MPLabelType } from './MPLabelType'; +import { MPBadgePosition } from './MPBadgePosition'; const { DisplayRule } = NativeModules; @@ -58,7 +61,7 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setVisible(visible: boolean): Promise { - return DisplayRule.setVisible(this.id, visible).catch((err: Error) => { + return DisplayRule.setVisible(this.id, JSON.stringify(visible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } @@ -85,7 +88,7 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setIconVisible(iconVisible: boolean): Promise { - return DisplayRule.setIconVisible(this.id, iconVisible).catch((err: Error) => { + return DisplayRule.setIconVisible(this.id, JSON.stringify(iconVisible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } @@ -112,7 +115,7 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setPolygonVisible(polygonVisible: boolean): Promise { - return DisplayRule.setPolygonVisible(this.id, polygonVisible).catch((err: Error) => { + return DisplayRule.setPolygonVisible(this.id, JSON.stringify(polygonVisible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } @@ -139,7 +142,7 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setLabelVisible(labelVisible: boolean): Promise { - return DisplayRule.setLabelVisible(this.id, labelVisible).catch((err: Error) => { + return DisplayRule.setLabelVisible(this.id, JSON.stringify(labelVisible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } @@ -166,7 +169,7 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setModel2DVisible(model2DVisible: boolean): Promise { - return DisplayRule.setModel2DVisible(this.id, model2DVisible).catch((err: Error) => { + return DisplayRule.setModel2DVisible(this.id, JSON.stringify(model2DVisible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } @@ -193,7 +196,7 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setWallVisible(wallVisible: boolean): Promise { - return DisplayRule.setWallVisible(this.id, wallVisible).catch((err: Error) => { + return DisplayRule.setWallVisible(this.id, JSON.stringify(wallVisible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } @@ -220,7 +223,7 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setExtrusionVisible(extrusionVisible: boolean): Promise { - return DisplayRule.setExtrusionVisible(this.id, extrusionVisible).catch((err: Error) => { + return DisplayRule.setExtrusionVisible(this.id, JSON.stringify(extrusionVisible)).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } @@ -247,6 +250,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setZoomFrom(zoomFrom: number): Promise { + if (zoomFrom == null) { + zoomFrom = -1; + } return DisplayRule.setZoomFrom(this.id, zoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -274,6 +280,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setZoomTo(zoomTo: number): Promise { + if (zoomTo == null) { + zoomTo = -1; + } return DisplayRule.setZoomTo(this.id, zoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -386,6 +395,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setLabelZoomFrom(zoomFrom: number): Promise { + if (zoomFrom == null) { + zoomFrom = -1; + } return DisplayRule.setLabelZoomFrom(this.id, zoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -413,6 +425,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setLabelZoomTo(zoomTo: number): Promise { + if (zoomTo == null) { + zoomTo = -1; + } return DisplayRule.setLabelZoomTo(this.id, zoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -440,6 +455,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setLabelMaxWidth(labelMaxWidth: number): Promise { + if (labelMaxWidth == null) { + labelMaxWidth = -1; + } return DisplayRule.setLabelMaxWidth(this.id, labelMaxWidth).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -467,6 +485,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setPolygonZoomFrom(polygonZoomFrom: number): Promise { + if (polygonZoomFrom == null) { + polygonZoomFrom = -1; + } return DisplayRule.setPolygonZoomFrom(this.id, polygonZoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -494,6 +515,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setPolygonZoomTo(polygonZoomTo: number): Promise { + if (polygonZoomTo == null) { + polygonZoomTo = -1; + } return DisplayRule.setPolygonZoomFrom(this.id, polygonZoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -521,6 +545,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setPolygonStrokeWidth(strokeWidth: number): Promise { + if (strokeWidth == null) { + strokeWidth = -1; + } return DisplayRule.setPolygonStrokeWidth(this.id, strokeWidth).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -575,6 +602,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setPolygonStrokeOpacity(strokeOpacity: number): Promise { + if (strokeOpacity == null) { + strokeOpacity = -1; + } return DisplayRule.setPolygonStrokeOpacity(this.id, strokeOpacity).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -602,6 +632,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setPolygonFillOpacity(fillOpacity: number): Promise { + if (fillOpacity == null) { + fillOpacity = -1; + } return DisplayRule.setPolygonFillOpacity(this.id, fillOpacity).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -683,6 +716,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setWallHeight(wallHeight: number): Promise { + if (wallHeight == null) { + wallHeight = -1; + } return DisplayRule.setWallHeight(this.id, wallHeight).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -710,6 +746,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setWallZoomFrom(wallZoomFrom: number): Promise { + if (wallZoomFrom == null) { + wallZoomFrom = -1; + } return DisplayRule.setWallZoomFrom(this.id, wallZoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -737,6 +776,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setWallZoomTo(wallZoomTo: number): Promise { + if (wallZoomTo == null) { + wallZoomTo = -1; + } return DisplayRule.setWallZoomTo(this.id, wallZoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -791,6 +833,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setExtrusionHeight(extrusionHeight: number): Promise { + if (extrusionHeight == null) { + extrusionHeight = -1; + } return DisplayRule.setExtrusionHeight(this.id, extrusionHeight).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -818,6 +863,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setExtrusionZoomFrom(extrusionZoomFrom: number): Promise { + if (extrusionZoomFrom == null) { + extrusionZoomFrom = -1; + } return DisplayRule.setExtrusionZoomFrom(this.id, extrusionZoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -845,6 +893,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setExtrusionZoomTo(extrusionZoomTo: number): Promise { + if (extrusionZoomTo == null) { + extrusionZoomTo = -1; + } return DisplayRule.setExtrusionZoomTo(this.id, extrusionZoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -872,6 +923,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setModel2DZoomFrom(zoomFrom: number): Promise { + if (zoomFrom == null) { + zoomFrom = -1; + } return DisplayRule.setModel2DZoomFrom(this.id, zoomFrom).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -899,6 +953,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setModel2DZoomTo(zoomTo: number): Promise { + if (zoomTo == null) { + zoomTo = -1; + } return DisplayRule.setModel2DZoomTo(this.id, zoomTo).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -953,6 +1010,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setModel2DWidthMeters(width: number): Promise { + if (width == null) { + width = -1; + } return DisplayRule.setModel2DWidthMeters(this.id, width).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -980,6 +1040,9 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setModel2DHeightMeters(height: number): Promise { + if (height == null) { + height = -1; + } return DisplayRule.setModel2DHeightMeters(this.id, height).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); @@ -1007,11 +1070,515 @@ export default class MPDisplayRule { * @returns {Promise} */ public async setModel2DBearing(bearing: number): Promise { + if (bearing == null) { + bearing = -1; + } return DisplayRule.setModel2DBearing(this.id, bearing).catch((err: Error) => { return Promise.reject(MPError.create(JSON.parse(err.message))); }); } + /** + * + * @returns + */ + public async getIconScale(): Promise { + return DisplayRule.getIconScale(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setIconScale(iconScale: number): Promise { + if (iconScale == null) { + iconScale = -1; + } + return DisplayRule.setIconScale(this.id, iconScale).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getIconPlacement(): Promise { + return DisplayRule.getIconPlacement(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setIconPlacement(iconPlacement: MPIconPlacement): Promise { + if (iconPlacement == null) { + return DisplayRule.setIconPlacement(this.id, -1).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + }else { + return DisplayRule.setIconPlacement(this.id, iconPlacement.valueOf()).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + } + + /** + * + * @returns + */ + public async getLabelType(): Promise { + return DisplayRule.getLabelType(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setLabelType(labelType: MPLabelType): Promise { + if (labelType == null) { + return DisplayRule.setLabelType(this.id, -1).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + }else { + return DisplayRule.setLabelType(this.id, labelType.valueOf()).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + + } + } + + /** + * + * @returns + */ + public async getLabelStyleTextSize(): Promise { + return DisplayRule.getLabelStyleTextSize(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setLabelStyleTextSize(textSize: number): Promise { + if (textSize == null) { + textSize = -1; + } + return DisplayRule.setLabelStyleTextSize(this.id, textSize).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getLabelStyleTextColor(): Promise { + return DisplayRule.getLabelStyleTextColor(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setLabelStyleTextColor(textColor: String): Promise { + return DisplayRule.setLabelStyleTextColor(this.id, textColor).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getLabelStyleTextOpacity(): Promise { + return DisplayRule.getLabelStyleTextOpacity(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setLabelStyleTextOpacity(textOpacity: number): Promise { + if (textOpacity == null) { + textOpacity = -1; + } + return DisplayRule.setLabelStyleTextOpacity(this.id, textOpacity).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getLabelStyleHaloColor(): Promise { + return DisplayRule.getLabelStyleHaloColor(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setLabelStyleHaloColor(color: string): Promise { + return DisplayRule.setLabelStyleHaloColor(this.id, color).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getLabelStyleHaloWidth(): Promise { + return DisplayRule.getLabelStyleHaloWidth(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setLabelStyleHaloWidth(haloWidth: number): Promise { + if (haloWidth == null) { + haloWidth = -1; + } + return DisplayRule.setLabelStyleHaloWidth(this.id, haloWidth).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getLabelStyleHaloBlur(): Promise { + return DisplayRule.getLabelStyleHaloBlur(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setLabelStyleHaloBlur(haloBlur: number): Promise { + if (haloBlur == null) { + haloBlur = -1; + } + return DisplayRule.setLabelStyleHaloBlur(this.id, haloBlur).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getLabelStyleBearing(): Promise { + return DisplayRule.getLabelStyleBearing(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setLabelStyleBearing(bearing: number): Promise { + if (bearing == null) { + bearing = -1; + } + return DisplayRule.setLabelStyleBearing(this.id, bearing).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getPolygonLightnessFactor(): Promise { + return DisplayRule.getPolygonLightnessFactor(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setPolygonLightnessFactor(lightnessFactor: number): Promise { + if (lightnessFactor == null) { + lightnessFactor = -2; + } + return DisplayRule.setPolygonLightnessFactor(this.id, lightnessFactor).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getWallLightnessFactor(): Promise { + return DisplayRule.getWallLightnessFactor(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setWallLightnessFactor(lightnessFactor: number): Promise { + if (lightnessFactor == null) { + lightnessFactor = -2; + } + return DisplayRule.setWallLightnessFactor(this.id, lightnessFactor).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getExtrusionLightnessFactor(): Promise { + return DisplayRule.getExtrusionLightnessFactor(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setExtrusionLightnessFactor(lightnessFactor: number): Promise { + if (lightnessFactor == null) { + lightnessFactor = -2; + } + return DisplayRule.setExtrusionLightnessFactor(this.id, lightnessFactor).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async isBadgeVisible(): Promise { + return DisplayRule.isBadgeVisible(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setBadgeVisible(visible: boolean): Promise { + return DisplayRule.setBadgeVisible(this.id, JSON.stringify(visible)).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getBadgeZoomFrom(): Promise { + return DisplayRule.getBadgeZoomFrom(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setBadgeZoomFrom(zoomFrom: number): Promise { + if (zoomFrom == null) { + zoomFrom = -1; + } + return DisplayRule.setBadgeZoomFrom(this.id, zoomFrom).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getBadgeZoomTo(): Promise { + return DisplayRule.getBadgeZoomTo(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setBadgeZoomTo(zoomTo: number): Promise { + if (zoomTo == null) { + zoomTo = -1; + } + return DisplayRule.setBadgeZoomTo(this.id, zoomTo).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getBadgeRadius(): Promise { + return DisplayRule.getBadgeRadius(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setBadgeRadius(radius: number): Promise { + if (radius == null) { + radius = -1; + } + return DisplayRule.setBadgeRadius(this.id, radius).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getBadgeStrokeWidth(): Promise { + return DisplayRule.getBadgeStrokeWidth(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setBadgeStrokeWidth(strokeWidth: number): Promise { + if (strokeWidth == null) { + strokeWidth = -1; + } + return DisplayRule.setBadgeStrokeWidth(this.id, strokeWidth).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getBadgeStrokeColor(): Promise { + return DisplayRule.getBadgeStrokeColor(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setBadgeStrokeColor(strokeColor: string): Promise { + return DisplayRule.setBadgeStrokeColor(this.id, strokeColor).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getBadgeFillColor(): Promise { + return DisplayRule.getBadgeFillColor(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setBadgeFillColor(fillColor: string): Promise { + return DisplayRule.setBadgeFillColor(this.id, fillColor).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getBadgeScale(): Promise { + return DisplayRule.getBadgeScale(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setBadgeScale(badgeScale: number): Promise { + if (badgeScale == null) { + badgeScale = -1; + } + return DisplayRule.setBadgeScale(this.id, badgeScale).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async getBadgePosition(): Promise { + return DisplayRule.getBadgePosition(this.id).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + + /** + * + * @returns + */ + public async setBadgePosition(badgePosition: MPBadgePosition): Promise { + if (badgePosition == null) { + return DisplayRule.setBadgePosition(this.id, -1).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + }else { + return DisplayRule.setBadgePosition(this.id, badgePosition.valueOf()).catch((err: Error) => { + return Promise.reject(MPError.create(JSON.parse(err.message))); + }); + } + } + /** * Resets the display rule to its default state. * diff --git a/MPHighlightBehavior.ts b/MPHighlightBehavior.ts new file mode 100644 index 0000000..ac62019 --- /dev/null +++ b/MPHighlightBehavior.ts @@ -0,0 +1,95 @@ +import MapControl from "../../index"; + +/** + * Sets a behavior for the map when calling {@link MapControl#setHighlight}. + * + * Has a default behavior: + * * MoveCamera = false + * * ShowInfoWindow = false + * * AnimationDuration = 0 + * * AllowFloorChange = false + * * ZoomToFit = true + * + * @export + * @class MPFilterBehavior + * @typedef {MPHighlightBehavior} + */ +export default class MPHighlightBehavior { + + /** + * Creates an instance of MPHighlightBehavior. + * + * @constructor + * @private + * @param {boolean} allowFloorChange Whether the highlighting is allowed to change the floor if no results are visible on the current floor. + * @param {boolean} moveCamera Whether the highlighting should move the camera to encompass the results. + * @param {number} animationDuration How long the camera movement should be animated for, set to 0 disables animation. + * @param {boolean} showInfoWindow Whether to open the info window if a single result is returned. + * @param {boolean} zoomToFit Whether the highlighting is allowed to zoom in/out the camera. + */ + private constructor( + public allowFloorChange: boolean, + public moveCamera: boolean, + public animationDuration: number, + public showInfoWindow: boolean, + public zoomToFit: boolean, + ) { } + + /** + * Creator for MPHighlightBehavior, invoke with 0 parameters to use default behavior. + * + * @public + * @static + * @param {MPFilterBehaviorParams} object + * @returns {MPFilterBehavior} + */ + public static create(object?: MPHighlightBehaviorParams): MPHighlightBehavior { + return new MPHighlightBehavior( + object?.allowFloorChange ? object.allowFloorChange : false, + object?.moveCamera ? object.moveCamera : false, + object?.animationDuration ? object.animationDuration : 0, + object?.showInfoWindow ? object.showInfoWindow : false, + object?.zoomToFit ? object?.zoomToFit : true + ); + }; +} + +/** + * Parameter interface for {@link MPHighlightBehavior}. + * + * @export + * @interface MPHighlightBehaviorParams + * @typedef {MPHighlightBehaviorParams} + */ +export interface MPHighlightBehaviorParams { + /** + * Whether the highlight is allowed to change the floor if no results are visible on the current floor. + * + * @type {?boolean} + */ + allowFloorChange?: boolean, + /** + * Whether the Highlight should move the camera to encompass the results. + * + * @type {?boolean} + */ + moveCamera?: boolean, + /** + * How long the camera movement should be animated for, set to 0 disables animation. + * + * @type {?number} + */ + animationDuration?: number, + /** + * Whether to open the info window if a single result is returned. + * + * @type {?boolean} + */ + showInfoWindow?: boolean, + /** + * Whether the Highlight is allowed to zoom in/out the camera. + * + * @type {?boolean} + */ + zoomToFit?: boolean, +} \ No newline at end of file diff --git a/MPIconPlacement.ts b/MPIconPlacement.ts new file mode 100644 index 0000000..763677c --- /dev/null +++ b/MPIconPlacement.ts @@ -0,0 +1,13 @@ +/** + * The possible position of Icons based on the location Anchor. + * + * @export + * @enum {number} + */ +export enum MPIconPlacement { + center, + above, + below, + left, + right +} \ No newline at end of file diff --git a/MPLabelType.ts b/MPLabelType.ts new file mode 100644 index 0000000..1426c8f --- /dev/null +++ b/MPLabelType.ts @@ -0,0 +1,10 @@ +/** + * The type of label + * + * @export + * @enum {number} + */ +export enum MPLabelType { + flat, + floating, +} \ No newline at end of file diff --git a/MPSolutionConfig.ts b/MPSolutionConfig.ts index ded64de..38c72e5 100644 --- a/MPSolutionConfig.ts +++ b/MPSolutionConfig.ts @@ -29,6 +29,7 @@ export default class MPSolutionConfig { public readonly settings3D: MPSettings3D, private _enableClustering?: boolean, private _mpCollisionHandling?: MPCollisionHandling, + private _isNewSelection?: boolean, ) { } @@ -46,6 +47,7 @@ export default class MPSolutionConfig { MPSettings3D.create(object?.settings3D), object?.enableClustering, object?.collisionHandling, + object?.isNewSelection, ); } @@ -90,6 +92,15 @@ export default class MPSolutionConfig { public get enableClustering(): boolean { return this._enableClustering ? this._enableClustering : true; } + + public set isNewSelection(enable: boolean) { + this._isNewSelection = enable; + MPUtils.setNewSelection(enable); + } + + public get isNewSelection(): boolean { + return this._isNewSelection ? this._isNewSelection : true; + } } /** @@ -124,4 +135,10 @@ export interface MPSolutionConfigParams { * @type {?MPCollisionHandling} */ collisionHandling?: MPCollisionHandling, + /** + * New selection setting + * + * @type {?boolean} + */ + isNewSelection?: boolean, } \ No newline at end of file diff --git a/MPSolutionDisplayRule.ts b/MPSolutionDisplayRule.ts index 90e53ec..a30a91e 100644 --- a/MPSolutionDisplayRule.ts +++ b/MPSolutionDisplayRule.ts @@ -10,4 +10,6 @@ export enum MPSolutionDisplayRule { buildingOutline = "buildingOutline", selectionHighlight = "selectionHighlight", positionIndicator = "positionIndicator", + selection = "selection", + highlight = "highlight" } diff --git a/MPUtils.ts b/MPUtils.ts index f13dcf0..a3e03ba 100644 --- a/MPUtils.ts +++ b/MPUtils.ts @@ -131,6 +131,18 @@ export default class MPUtils { return UtilsModule.enableClustering(enableClustering); } + /** + * Internal - Documentation will follow. + * + * @static + * @async + * @param {boolean} enableClustering + * @returns {Promise} + */ + static async setNewSelection(isNewSelection: boolean): Promise { + return Promise.resolve(UtilsModule.setNewSelection(isNewSelection)); + } + /** * Internal - Documentation will follow. * diff --git a/MapControl.ts b/MapControl.ts index 2692ac2..55002d2 100644 --- a/MapControl.ts +++ b/MapControl.ts @@ -9,6 +9,7 @@ import { OnLiveLocationUpdateListener, MPCameraEvent, MPMapStyle, MPCameraUpdate, MPCameraPosition, MPEntity, } from "../../index" import { EventNames } from './EventNames'; +import MPHighlightBehavior from './MPHighlightBehavior'; const { MapControlModule } = NativeModules; @@ -260,8 +261,9 @@ export default class MapControl { * @returns {Promise} True if any locations are available. */ public async setFilter(filter: MPFilter, filterBehavior: MPFilterBehavior): Promise; + /** - * Use this method to display temporary locations, not points of interests location. Use [clearFilter()] to exit this state. + * Use this method to display temporary locations. Use [clearFilter()] to exit this state. * * @public * @async @@ -281,6 +283,26 @@ export default class MapControl { } } + /** + * + * Use this method to highlight a list of locations. Use [clearHighlight()] to exit this state. + * + * @param locations the locations to highlight + * @param highlightBehavior How the map should show the applied highlight + * @returns + */ + public async setHighlight(locations: MPLocation[], highlightBehavior: MPHighlightBehavior): Promise { + const locationIds: string[] = new Array(); + locations.forEach((location => { + locationIds.push(location.id); + })); + return Promise.resolve(MapControlModule.setHighlight(JSON.stringify(locationIds), JSON.stringify(highlightBehavior))); + } + + public async clearHighlight(): Promise { + return MapControlModule.clearHighlight(); + } + /** * Focus the map on the given {@link MPEntity}. *