Skip to content

Commit

Permalink
Update types with new options (#143)
Browse files Browse the repository at this point in the history
* Update types with new options

* WIP try to use stadia maps

* replace examples

* Switch to ol9 dev since there are issues with VectorSource
Update examples and types
add new parameter to geoportail

fix geojson adjustment

* fix example

* Update to Openlayers 9
Use latest ol-ext

Fix Geoportail
Fix photo style
Fix examples
  • Loading branch information
Siedlerchr authored Mar 9, 2024
1 parent 5242105 commit 410205f
Show file tree
Hide file tree
Showing 35 changed files with 1,257 additions and 1,433 deletions.
2 changes: 1 addition & 1 deletion @types/ol-ext/control/EditBar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface Options {
target?: string;
edition?: boolean;
interactions?: Interactions; // TODO dig deeper into the type system
source?: VectorSource;
source?: VectorSource | null;
}

/** Control bar for editing in a layer
Expand Down
13 changes: 9 additions & 4 deletions @types/ol-ext/control/SearchGeoportail.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Options as SearchJsonOptions } from './SearchJSON'
import SearchJSON from './SearchJSON'

export type AddressType = 'StreetAddress' | 'PositionOfInterest' | 'CadastralParcel' | 'Commune';
export type AddressType = 'StreetAddress' | 'PositionOfInterest' | 'CadastralParcel' | 'Commune'

export interface Options extends SearchJsonOptions {
className?: string;
Expand All @@ -15,6 +15,7 @@ export interface Options extends SearchJsonOptions {
minLength?: number;
maxItems?: number;
type?: AddressType;
terr?: 'METROPOLE' | 'DOMTOM' | string;
}

/**
Expand All @@ -30,7 +31,7 @@ export default class SearchGeoportail extends SearchJSON {
/**
* @param {any} options extend ol.control.SearchJSON options
* @param {string} options.className control class name
* @param {string | undefined} options.apiKey the service api key.
* @param {string | undefined} options.apiKey {string} options.gppKey Geoportail API key or 'gpf' for new Geoplatform services, default use layer registered key
* @param {string | undefined} [options.version] API version '2' to use geocodage-beta-2, default v1.
* @param {string | undefined} options.authentication: basic authentication for the service API as btoa("login:pwd")
* @param {Element | string | undefined} options.target Specify a target if you want the control to be rendered outside of the map's viewport.
Expand All @@ -40,9 +41,13 @@ export default class SearchGeoportail extends SearchJSON {
* @param {number | undefined} options.typing a delay on each typing to start searching (ms), default 500.
* @param {integer | undefined} options.minLength minimum length to start searching, default 3
* @param {integer | undefined} options.maxItems maximum number of items to display in the autocomplete list, default 10
* @param {StreetAddress|PositionOfInterest|CadastralParcel|Commune} [options.type] type of search. Using Commune will return the INSEE code, default StreetAddress,PositionOfInterest
* @param {string} [options.terr] territory METROPOLE|DOMTOM|dep code
* @param {boolean} [options.position] Search, with priority to geo position (map center), default false
* @param {ol.extent} [options.bbox] if set search inside the bbox (in map projection)
* @param {boolean} [options.useExtent] returns candidates inside the current map extent, default false
*
* @param {StreetAddress|PositionOfInterest|CadastralParcel|Commune} options.type type of search. Using Commune will return the INSEE code, default StreetAddress,PositionOfInterest
*/
*/
constructor(options?: Options);

/** Send an ajax request (GET)
Expand Down
36 changes: 24 additions & 12 deletions @types/ol-ext/control/SearchGeoportailParcelle.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ import SearchJSON from './SearchJSON'
export interface Options extends SearchJsonOptions {
className?: string;
apiKey?: string;
target?: HTMLElement | string
authentication?: string;
label?: string;
placeholder?: string;
prefixPlaceholder?: string,
sectionPlaceholder?: string,
numberPlaceholder?: string,
arrondPlaceholder?: string,
typing?: number;
minLength?: number;
maxItems?: number;
Expand All @@ -24,18 +29,20 @@ export interface Options extends SearchJsonOptions {
* @see {@link https://geoservices.ign.fr/documentation/geoservices/geocodage.html} */
export default class SearchGeoportailParcelle extends SearchJSON {
/**
* @param {any} options extend ol.control.SearchJSON options
* @param {string} options.className control class name
* @param {boolean | undefined} options.apiKey the service api key.
* @param {string | undefined} options.authentication: basic authentication for the service API as btoa("login:pwd")
* @param {Element | string | undefined} options.target Specify a target if you want the control to be rendered outside of the map's viewport.
* @param {string | undefined} options.label Text label to use for the search button, default "search"
* @param {string | undefined} options.placeholder placeholder, default "Search..."
* @param {number | undefined} options.typing a delay on each typing to start searching (ms), default 500.
* @param {integer | undefined} options.minLength minimum length to start searching, default 3
* @param {integer | undefined} options.maxItems maximum number of items to display in the autocomplete list, default 10
*
* @param {Number} options.pageSize item per page for parcelle list paging, use -1 for no paging, default 5
* @param {string} options.className control class name
* @param {boolean | undefined} [options.apiKey] the service api key.
* @param {string | undefined} options.authentication: basic authentication for the service API as btoa("login:pwd")
* @param {Element | string | undefined} options.target Specify a target if you want the control to be rendered outside of the map's viewport.
* @param {string | undefined} options.label Text label to use for the search button, default "search"
* @param {string | undefined} options.placeholder placeholder for city input, default "Choisissez une commune..."
* @param {string | undefined} options.prefixPlaceholder placeholder for prefix input, default "Préfixe"
* @param {string | undefined} options.sectionPlaceholder placeholder for section input, default "Section"
* @param {string | undefined} options.numberPlaceholder placeholder for number input, default "Numéro"
* @param {string | undefined} options.arrondPlaceholder placeholder for arrondissement, default "Arrond."
* @param {number | undefined} options.typing a delay on each typing to start searching (ms), default 500.
* @param {integer | undefined} options.minLength minimum length to start searching, default 3
* @param {integer | undefined} options.maxItems maximum number of items to display in the autocomplete list, default 10
* @param {Number} options.pageSize item per page for parcelle list paging, use -1 for no paging, default 5
*/
constructor(options: Options);

Expand Down Expand Up @@ -140,6 +147,11 @@ export default class SearchGeoportailParcelle extends SearchJSON {
*/
clearHistory(): void;

/**
* Clear the parcel list
*/
clearParcelList(): void

/**
* Get history table
*/
Expand Down
3 changes: 1 addition & 2 deletions @types/ol-ext/control/SearchJSON.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { Feature } from 'ol'
import type { Coordinate } from 'ol/coordinate'
import type { EventsKey } from 'ol/events'
import BaseEvent from 'ol/events/Event'
import type { Geometry } from 'ol/geom'
import type { Options as SearchOptions, SearchOnSignature } from './Search'
import Search, { SearchEvent } from './Search'
import Search from './Search'

export interface Options extends SearchOptions {
handleResponse?: ((response: any) => any[]);
Expand Down
4 changes: 0 additions & 4 deletions @types/ol-ext/geom/GPAltiCode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { Coordinate } from 'ol/coordinate'

export interface Options {
projection?: ProjectionLike;
apiKey?: string;
sampling?: number;
samplingDist?: number;
success?: (result: Geometry) => void;
Expand All @@ -16,7 +15,6 @@ export interface Options {
* @param {Geometry} geom
* @param {Object} options
* @param {ol/proj~ProjectionLike} [options.projection='EPSG:3857'] geometry projection, default 'EPSG:3857'
* @param {string} [options.apiKey='choisirgeoportail'] Geoportail API key
* @param {number} [options.sampling=0] number of resulting point, max 5000, if none keep input points or use samplingDist
* @param {number} [options.samplingDist=0] distance for sampling the line or use sampling if lesser
* @param {string} options.success a function that takes the resulting XYZ geometry
Expand All @@ -28,13 +26,11 @@ export function ol_geom_GPAltiCode(geom: Geometry, options: Options): void;
* @param {ol.coordinate|Array<ol.coordinate>} coord coordinate or an array of coordinates
* @param {Object} options
* @param {ol/proj~ProjectionLike} [options.projection='EPSG:3857'] geometry projection, default 'EPSG:3857'
* @param {string} [options.apiKey='choisirgeoportail'] Geoportail API key
* @param {string} options.success a function that takes the resulting XYZ coordinates
* @param {string} options.error
*/
export function ol_coordinate_GPAltiCode(coord: Coordinate | Coordinate[], options: {
projection?: ProjectionLike,
apiKey?: string,
success?: (g: Coordinate) => void,
error?: (e: any) => void
}): void;
2 changes: 1 addition & 1 deletion @types/ol-ext/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// index.d.ts
// index.d.ts
Loading

0 comments on commit 410205f

Please sign in to comment.