diff --git a/mapsjs/mapsjs.d.ts b/mapsjs/mapsjs.d.ts index 46367fc50..a71cb1ad5 100644 --- a/mapsjs/mapsjs.d.ts +++ b/mapsjs/mapsjs.d.ts @@ -428,7 +428,7 @@ declare module 'mapsjs' { * @param {number} [idx] Index of the line for which to compute the distance. * @returns {number} Distance in meters of the line. */ - getActualDistance(idx: number): number; + getActualDistance(idx?: number): number; /** * Determines whether this polyline intersects a given geometry. @@ -509,7 +509,7 @@ declare module 'mapsjs' { * @param {number} [idx] Index of the ring for which to compute the area. * @returns {number} Area in square meters of the ring. */ - getActualArea(idx: number): number; + getActualArea(idx?: number): number; /** * Calculates perimeter of a ring in a polygon by index according @@ -518,7 +518,7 @@ declare module 'mapsjs' { * @param {number} [idx] Index of the ring for which to compute the perimeter. * @returns {number} Length in meters of the perimeter of the ring. */ - getActualPerimeter(idx: number): number; + getActualPerimeter(idx?: number): number; /** * Determines whether this polygon intersects a given geometry. @@ -548,7 +548,7 @@ declare module 'mapsjs' { * @class geometryStyle */ export class geometryStyle { - constructor(); + constructor(options?: styleObj); /** * Gets path outline thickness in pixels. @@ -899,8 +899,14 @@ declare module 'mapsjs' { * @class styledGeometry */ export class styledGeometry { - constructor(geom: geometry, gStyle: geometryStyle); + constructor(geom: geometry, gStyle?: geometryStyle); + /** + * Set this styledGeometry's geometry. + * @param {geometry} g A new Geometry. + */ + setGeometry(g: geometry): void; + /** * Set this styledGeometry's geometryStyle. * @param {geometryStyle} gs A new styledGeometry. @@ -912,6 +918,12 @@ declare module 'mapsjs' { * @returns {geometry} The underlying geometry. */ getGeometry(): geometry; + + /** + * Gets the styledGeometry's underlying geometryStyle object. + * @returns {geometryStyle} The underlying geometry style. + */ + getGeometryStyle(): geometryStyle; /** * Gets path outline thickness in pixels. @@ -933,7 +945,7 @@ declare module 'mapsjs' { /** * Gets path outline opacity in decimal format. - * @returns {number} Outline opacity. + * @param {number} Outline opacity. */ setOutlineColor(c: string): void; @@ -1322,6 +1334,11 @@ declare module 'mapsjs' { ulX: number; ulY: number; }; + + /** + * Unbind all associations with this tile layer to facilitate garbage collection + */ + dispose(): void; } /** @@ -2221,8 +2238,53 @@ declare module 'mapsjs' { * @returns {number} maxY coord as integer */ maxY: number; - } - + } + + interface extentChangeStatsObj { + + centerX: number; + centerY: number; + centerLat: number; + centerLon: number; + zoomLevel: number; + mapScale: number; + mapScaleProjected: number; + mapUnitsPerPixel: number; + extents: envelope; + } + + interface repositionStatsObj { + + centerX: number; + centerY: number; + zoomLevel: number; + mapUnitsPerPixel: number; + } + + interface beginDigitizeOptions { + key?: string; + shapeType: string; + geometryStyle?: geometryStyle; + styledGeometry?: styledGeometry; + nodeTapAndHoldAction?: (setIdx: number, idx: number) => boolean; + nodeMoveAction?: (x: number, y: number, actionType: string) => any; + shapeChangeAction?: () => void; + envelopeEndAction?: (env: envelope) => void; + circleEndAction?: (circle: geometry.polygon) => void; + suppressNodeAdd?: boolean; + leavePath?: boolean; + } + + + interface styleObj { + fillColor?: string; + fillOpacity?: number; + outlineColor?: string; + outlineOpacity?: number; + outlineThicknessPix?: number + dashArray?: string; + } + interface mapsjsWidget { /** @@ -2512,12 +2574,18 @@ declare module 'mapsjs' { * content area DOM. If an attempt to add a geometry is made with the same * key, the geometry is swapped out. You must remove using removePathGeometry * for resource cleanup. - * @param {styleGeometry} styledGeom THe styledGeometry to render. - * @param {string} key String used to tie a geometry to its SVG + * @param {styleGeometry} styledGeom The styledGeometry to render. + * @param {string} key String used to tie a geometry to its SVG + * @param {function} addAction optional function that is called when mapsjs adds an svg element to the DOM representing this styledGeometry. + * @param {function} removeAction optional function that is called when mapsjs adds an svg element to the DOM representing this styledGeometry. * rendering in the DOM. * @returns {element} The SVG element which was added to the DOM. */ - addPathGeometry(styledGeom: styledGeometry, key: string): void; + addPathGeometry( + styledGeom: styledGeometry, + key: string, + addAction?: (svg: SVGElement) => void, + removeAction?: (svg: SVGElement) => void): SVGElement; /** * Updates an existing path geometry to reflect a style change. @@ -2529,41 +2597,34 @@ declare module 'mapsjs' { /** * Removes a styledGeometry from display. * @param {string} key The key of the geometry to remove. + * @returns {element} The SVG element which was removed from the DOM. */ - removePathGeometry(key: string): void; + removePathGeometry(key?: string): SVGElement; /** * Initiates digitization on the map control. This creates a new * geometry and adds verticies to the geometry accord to mouse * click locations. * @param {object} options JavaScript object of the form { key, - * shapeType, geometryStyle, nodeTapAndHoldAction, nodeMoveAction, - * shapeChangeAction, envelopeEndAction, supressNodeAdd, leavePath } + * shapeType, geometryStyle, styledGeometry, nodeTapAndHoldAction, nodeMoveAction, + * shapeChangeAction, envelopeEndAction, circleEndAction, supressNodeAdd, leavePath } * where key is a a string associated with this geometry, shapeType - * is the type of shape this geometry is, one of 'point', 'path', or - * 'polygon', geometryStyle is a geometryStyle which should be applied - * to the digitized geometry, nodeTapAndHoldAction is a callback invoked + * is the type of shape this geometry is, one of 'polygon', 'polyline', 'multipoint', 'envelope' or 'circle', + * geometryStyle is a geometryStyle which should be applied + * to the digitized geometry, styledGeometry is an optional styledGeometry for existing paths to edit, set this to enter edit mode, + * nodeTapAndHoldAction is a callback invoked * when any point in the geometry is clicked and held and has the * signature nodeTapAndHoldAction(setIdx, idx), nodeMoveAction is a * callback invoked after any node is dragged to a new location and * has signature nodeMoveAction(x, y, actionType), shapeChangeAction * is a callback that is invoked after the geometry shape changes and, - * has signature shapeChangeAction(), envelopeEndAction is a callback + * has signature shapeChangeAction(shape), envelopeEndAction is a callback * invoked after an envelope is created and has signature envelopeEndAction(envelope), + * circleEndAction is similar to envelopeEndAction but takes a geometry.polygon representing the circle, * and leavePath is a flag that indicates whether the digitized shape * should be left on the map after digitization is complete. */ - beginDigitize(options: { - key?: string; - shapeType: string; - geometryStyle?: geometryStyle; - nodeTapAndHoldAction?: (setIdx: number, idx: number) => boolean; - nodeMoveAction?: (x: number, y: number, actionType: string) => any; - shapeChangeAction?: () => void; - envelopeEndAction?: (env: envelope) => void; - suppressNodeAdd?: boolean; - leavePath?: boolean; - }): void; + beginDigitize(options: beginDigitizeOptions): void; endDigitize(): void; /** @@ -2606,7 +2667,7 @@ declare module 'mapsjs' { * the form { centerX, centerY, centerLat, centerLon, zoomLevel, mapScale, * mapScaleProjected, mapUnitsPerPixel, extents }. */ - setExtentChangeCompleteAction(action: (vals: {}) => void): void; + setExtentChangeCompleteAction(action: (vals: extentChangeStatsObj) => void): void; /** * Set the function called when map content (map tiles and fixed elements) are @@ -2616,7 +2677,7 @@ declare module 'mapsjs' { * completes repositioning with signature action(object) where object * is of the form { centerX, centerY, zoomLevel, mapUnitsPerPixel }. */ - setContentRepositionAction(action: (vals: {}) => void): void; + setContentRepositionAction(action: (vals: repositionStatsObj) => void): void; /** * Sets function called when map is clicked or tapped.