Skip to content

Commit

Permalink
Updatefor new release (Siedlerchr#170)
Browse files Browse the repository at this point in the history
* update deps

* fix types for ol 10

* add missing types

* add missing methods and new classes

* bump version
  • Loading branch information
Siedlerchr authored Nov 22, 2024
1 parent c64416b commit dbdf42a
Show file tree
Hide file tree
Showing 20 changed files with 1,048 additions and 907 deletions.
13 changes: 13 additions & 0 deletions @types/ol-ext/control/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,17 @@ export default class Button extends ol_control_Control {
* @returns {Element}
*/
getButtonElement(): Element

/**
* Test if the control is disabled.
* @return {bool}
* @api stable
*/
getDisable(): boolean

/** Disable the control button.
* @param {bool} b disable (or enable) the control, default false (enable)
* @api stable
*/
setDisable(b: boolean): void
}
54 changes: 54 additions & 0 deletions @types/ol-ext/control/SearchCoordinates.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { ProjectionLike } from 'ol/proj'
import type { Options as SearchOptions } from './Search'
import Search from './Search'

export interface Options extends SearchOptions {
projection?: ProjectionLike;
className?: string;
target?: Element | string;
label?: string;
labelGps?: string;
labelCenter?: string;
typing?: number;
minLength?: number;
maxItems?: number;
digit?: number;
}

/**
* Search on GPS coordinate.
*
* @constructor
* @extends {ol_control_Search}
* @fires select
* @param {Object=} Control options.
* @param {ol/proj/ProjectionLike} [options.projection="EPSG:3857"] control projection
* @param {string} [options.className] control class name
* @param {Element | string } [options.target] Specify a target if you want the control to be rendered outside of the map's viewport.
* @param {string} [options.label="search"] Text label to use for the search button, default "search"
* @param {string} [options.labelGPS="Locate with GPS"] placeholder
* @param {string} [options.labelCenter="Map center"] placeholder
* @param {number} [options.typing=300] a delay on each typing to start searching (ms), default 300.
* @param {integer} [options.minLength=1] minimum length to start searching, default 1
* @param {integer} [options.maxItems=10] maximum number of items to display in the autocomplete list, default 10
* @param {integer} [options.digit=3] number of digit in coords
*/
export default class SearchCoordinates extends Search {
constructor(options?: Options);

/** Set the input value in the form (for initialisation purpose)
* @param {Array<number>} [coord] if none get the map center
* @api
*/
setInput(coord: number[]): void;

/** Get the control projection
* @returns {ProjectionLike}
*/
getProjection(): ProjectionLike

/** Set the projection
* @param {ProjectionLike} proj
*/
setProjection(proj: ProjectionLike): void
}
6 changes: 6 additions & 0 deletions @types/ol-ext/control/SearchGPS.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,10 @@ export default class SearchGPS extends Search {
* @return {boolean}
*/
equalFeatures(f1: any, f2: any): boolean;

/** Set the input value in the form (for initialisation purpose
* @param {Array<number>} [coord] if none get the map center
* @api
*/
setInput(coord: number[]): void;
}
4 changes: 3 additions & 1 deletion @types/ol-ext/interaction/Splitter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface Options {
features?: Collection<Feature>;
filter?: (f: Feature) => boolean;
tolerance?: number;
alignTolerance: number;
}

/** Interaction splitter: acts as a split feature agent while editing vector features (LineString).
Expand All @@ -37,7 +38,8 @@ export class Splitter extends Interaction {
* - triggerFeatures {ol_Collection.<ol.Feature>} Any newly created or modified features from this collection will be used to split features on the target source (replace triggerSource).
* - filter {function|undefined} a filter that takes a feature and return true if the feature is eligible for splitting, default always split.
* - tolerance {function|undefined} Distance between the calculated intersection and a vertex on the source geometry below which the existing vertex will be used for the split. Default is 1e-10.
*/
* - alignTolerance Tolerance to check allignment. Default is 1e-3.
constructor(options: Options);
/** Calculate intersection on 2 segs
Expand Down
3 changes: 2 additions & 1 deletion @types/ol-ext/overlay/FixedPopup.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Map as _ol_Map_ } from 'ol'
import { Overlay } from 'ol'

import type { Pixel } from 'ol/pixel'
import type { Style } from 'ol/style'
Expand All @@ -17,6 +16,7 @@ export interface Options extends OverlayOptions {
onshow?: () => void;
offsetBox?: number | number[];
positioning?: typeof Positioning | any | undefined; // workaround with any for 'auto'
hook?: 'map' | 'viewport'
}

/**
Expand All @@ -42,6 +42,7 @@ export default class FixedPopup extends Popup {
* @param {Number|Array<number>} options.offsetBox an offset box
* @param {ol.OverlayPositioning | string | undefined} options.positioning
* the 'auto' positioning var the popup choose its positioning to stay on the map.
* @param {string} options.hook popup is hooked on the 'map' (and move with it) or on the 'viewport', default viewport.
*/
constructor(options?: Options);

Expand Down
18 changes: 10 additions & 8 deletions @types/ol-ext/source/IDW.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@ export default class IDW extends ImageCanvas {
*/
getSource(): VectorSource;

/** Apply the value to the map RGB. Overwrite this function to set your own colors.
* @param {number} v value
* @param {Uint8ClampedArray} data RGBA array
* @param {number} i index in the RGBA array
* @api
*/
setData(v: number, data: Uint8ClampedArray, i: number): void;

/** Get image value at coord (RGBA)
* @param {l.coordinate} coord
* @return {Uint8ClampedArray}
*/
getValue(coord: Coordinate): Uint8ClampedArray;

/** Set IDW scale
* @param {number} scale
*/
setScale(scale: number): void

/** Set IDW max distance
* @param {number} [dist] max distance in proj units
*/
setMaxD(dist: number): void

/** Get color for a value. Return an array of RGBA values.
* @param {number} v value
* @returns {Array<number>}
Expand Down
18 changes: 10 additions & 8 deletions @types/ol-ext/source/TileWFS.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export enum TileWFSEventType {
}

export interface Options {
version?: WFSVersion;
typeName?: string;
version?: WFSVersion;
outputFormat?: string | 'application/json'
tileZoom?: number;
featureLimit?: number;
pagination?: boolean;
Expand All @@ -48,13 +49,14 @@ export interface Options {
export default class TileWFS extends VectorSource {
/**
* @param {Object} options
* @param {string} [options.version=1.1.0] WFS version to use. Can be either 1.0.0, 1.1.0 or 2.0.0.
* @param {string} options.typeName WFS type name parameter
* @param {number} options.tileZoom zoom to load the tiles
* @param {number} options.maxFeatures maximum features returned in the WFS
* @param {number} options.featureLimit maximum features in the source before refresh, default Infinity
* @param {boolean} [options.pagination] experimental enable pagination, default no pagination
*/
* @param {string} options.typeName WFS type name parameter
* @param {string} [options.version=1.1.0] WFS version to use. Can be either 1.0.0, 1.1.0 or 2.0.0.
* @param {string} [options.outputFormat=application/json] WFS outputFormat parameter
* @param {number} [options.tileZoom=14] zoom to load the tiles
* @param {number} [options.maxFeatures] maximum features returned in the WFS
* @param {number} [options.featureLimit=Infinity] maximum features in the source before refresh, default Infinity
* @param {boolean} [options.pagination] experimental enable pagination, default no pagination
*/
constructor(options?: Options);

on: TileWFSOnSignature<EventsKey>
Expand Down
2 changes: 2 additions & 0 deletions @types/ol-ext/style/FontSymbol.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface Options {
rotation?: number;
rotateWithView?: boolean;
declutterMode?: 'obstacle' | 'none' | undefined
scale?: number;
opacity?: number;
fontSize?: number;
fontStyle?: string;
Expand Down Expand Up @@ -87,6 +88,7 @@ export default class FontSymbol extends RegularShape {
* @param {number} options.rotation
* @param {boolean} options.rotateWithView
* @param {string} [options.declutterMode] Declutter mode "declutter" | "obstacle" | "none" | undefined
* @param {number} [options.scale=1]
* @param {number} [options.opacity=1]
* @param {number} [options.fontSize=1] size of the font compare to the radius, fontSize greater than 1 will exceed the symbol extent
* @param {string} [options.fontStyle] the font style (bold, italic, bold italic, etc), default none
Expand Down
11 changes: 9 additions & 2 deletions @types/ol-ext/util/element.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare module 'ol-ext/util/element' {
import type { Map as _ol_Map_ } from 'ol'

/** Options for creating an HTML element
* @property {string} [className] - CSS class name(s) for the element
Expand Down Expand Up @@ -228,7 +229,13 @@ declare module 'ol-ext/util/element' {
* @param {Element} element - The element to dispatch the event on
*/
function dispatchEvent(eventName: string, element: Element): void;
}

export default ol_ext_element;
/** Set cursor
* @param {Element|ol/Map} elt
* @param {string} cursor
*/
function setCursor(elt: Element | _ol_Map_, cursor: string): void

export default ol_ext_element
}
}
30 changes: 15 additions & 15 deletions examples/bar/map.control.bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ const vector = new Vector({ source: new VectorSource() })

// The map
const map = new Map
({
target: 'map',
view: new View
({
zoom: 14,
center: [270701, 6247637],
}),
layers:
[new Tile({ source: new OSM() }),
vector,
],
})
target: 'map',
view: new View
({
zoom: 14,
center: [270701, 6247637],
}),
layers:
[new Tile({ source: new OSM() }),
vector,
],
})

// Main control bar
const mainbar = new Bar()
Expand Down Expand Up @@ -56,10 +56,10 @@ const pedit = new Toggle(
className: 'edit',
title: 'Point',
interaction: new Draw
({
type: 'Point',
source: (vector.getSource() == null) ? undefined : vector.getSource() as VectorSource,
}),
({
type: 'Point',
source: (vector.getSource() == null) ? undefined : vector.getSource() as VectorSource,
}),
onToggle(active) {
document.querySelector<HTMLTextAreaElement>('#info')!.textContent = `Edition is ${active ? 'activated' : 'deactivated'}`
},
Expand Down
20 changes: 10 additions & 10 deletions examples/bar/map.control.button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import Button from 'ol-ext/control/Button'

// The map
const map = new Map
({
target: 'map',
view: new View
({
zoom: 14,
center: [270701, 6247637],
}),
layers:
[new Tile({ source: new OSM() }),
],
})
target: 'map',
view: new View
({
zoom: 14,
center: [270701, 6247637],
}),
layers:
[new Tile({ source: new OSM() }),
],
})

console.log('ok')
// Add a custom push button with onToggle function
Expand Down
3 changes: 1 addition & 2 deletions examples/bar/map.control.editbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ edit.getInteraction('DrawPoint').on('change:active', e => {
edit.on('info', e => {
console.log(e)
note.show(
`<i class="fa fa-info-circle"></i> ${
e.features.getLength()
`<i class="fa fa-info-circle"></i> ${e.features.getLength()
} feature(s) selected`,
)
})
28 changes: 14 additions & 14 deletions examples/control/map.control.geobookmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ declare global {

// The map
const map = new Map
({
target: 'map',
view: new View({ zoom: 13, center: [649083, 5408224] }),
layers: [new Geoportail('GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2')],
})
({
target: 'map',
view: new View({ zoom: 13, center: [649083, 5408224] }),
layers: [new Geoportail('GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2')],
})

const bm = new GeoBookmark({
marks:
{
Paris: { pos: transform([2.351828, 48.856578], 'EPSG:4326', 'EPSG:3857'), zoom: 11, permanent: true },
London: { pos: transform([-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'), zoom: 11, permanent: true },
Geneve: { pos: transform([6.149985, 46.200013], 'EPSG:4326', 'EPSG:3857'), zoom: 13, permanent: true },
Bruxelles: { pos: transform([4.35, 50.83], 'EPSG:4326', 'EPSG:3857'), zoom: 12, permanent: true },
Berlin: { pos: transform([13.383333, 52.516667], 'EPSG:4326', 'EPSG:3857'), zoom: 12, permanent: true },
Madrid: { pos: transform([-3.683333, 40.433333], 'EPSG:4326', 'EPSG:3857'), zoom: 12 },
Roma: { pos: transform([12.48657, 41.888732], 'EPSG:4326', 'EPSG:3857'), zoom: 12 },
},
{
Paris: { pos: transform([2.351828, 48.856578], 'EPSG:4326', 'EPSG:3857'), zoom: 11, permanent: true },
London: { pos: transform([-0.1275, 51.507222], 'EPSG:4326', 'EPSG:3857'), zoom: 11, permanent: true },
Geneve: { pos: transform([6.149985, 46.200013], 'EPSG:4326', 'EPSG:3857'), zoom: 13, permanent: true },
Bruxelles: { pos: transform([4.35, 50.83], 'EPSG:4326', 'EPSG:3857'), zoom: 12, permanent: true },
Berlin: { pos: transform([13.383333, 52.516667], 'EPSG:4326', 'EPSG:3857'), zoom: 12, permanent: true },
Madrid: { pos: transform([-3.683333, 40.433333], 'EPSG:4326', 'EPSG:3857'), zoom: 12 },
Roma: { pos: transform([12.48657, 41.888732], 'EPSG:4326', 'EPSG:3857'), zoom: 12 },
},
})
map.addControl(bm)

Expand Down
2 changes: 1 addition & 1 deletion examples/control/map.switcher.popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const vectorSource = new VectorSource(
featureProjection: 'EPSG:3857',
}),
attributions: ['&copy; <a href=\'https://data.culture.gouv.fr/explore/dataset/fonds-de-la-guerre-14-18-extrait-de-la-base-memoire\'>'
+ '<img src=\'https://data.culture.gouv.fr/assets/logo\' height=\'12px\'>data.culture.gouv.fr</a>'],
+ '<img src=\'https://data.culture.gouv.fr/assets/logo\' height=\'12px\'>data.culture.gouv.fr</a>'],
},
)

Expand Down
2 changes: 1 addition & 1 deletion examples/geom/map.geom.cspline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ declare global {
interface Window {
$(selector: any, context?: any): any;

vector: VectorLayer<Feature, VectorSource>
vector: VectorLayer<VectorSource<Feature<Geometry>>>
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/routing/map.source.dijkstra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let speed: { [char: string]: number } = {
declare global {
interface Window {
map: _ol_Map;
nodes: VectorLayer<Feature, VectorSource>
nodes: VectorLayer<VectorSource<Feature<Geometry>>>
}
}
const { $ } = window
Expand Down
18 changes: 9 additions & 9 deletions examples/search/map.control.searchnominatim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ const layers = [new Tile({ source: new OSM() })]

// The map
const map = new Map
({
target: 'map',
view: new View
({
zoom: 5,
center: [166326, 5992663],
}),
interactions: interaction_defaults({ altShiftDragRotate: false, pinchRotate: false }),
layers,
})
target: 'map',
view: new View
({
zoom: 5,
center: [166326, 5992663],
}),
interactions: interaction_defaults({ altShiftDragRotate: false, pinchRotate: false }),
layers,
})

// Current selection
const sLayer = new Vector({
Expand Down
Loading

0 comments on commit dbdf42a

Please sign in to comment.