Skip to content

Commit

Permalink
Add maptiler-geocoding-control v2.0.0 (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
zdila authored Oct 18, 2024
1 parent 266eb3b commit e429da5
Show file tree
Hide file tree
Showing 520 changed files with 33,875 additions and 1 deletion.
2 changes: 1 addition & 1 deletion maptiler-geocoding-control/latest
29 changes: 29 additions & 0 deletions maptiler-geocoding-control/v2.0.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2023, MapTiler
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import type { Evented, FitBoundsOptions, FlyToOptions, Map, Marker, MarkerOptions } from "maplibre-gl";
import type { SvelteComponent } from "svelte";
import GeocodingControlComponent from "./GeocodingControl.svelte";
import { type FullGeometryStyle, type MapLibreGL } from "./maplibregl-controller";
import type { ControlOptions, Feature } from "./types";
export { createMapLibreGlMapController, type MapLibreGL, } from "./maplibregl-controller";
export type MapLibreBaseControlOptions = Omit<ControlOptions, "apiKey"> & {
/**
* Marker to be added to the map at the location of the user-selected result using a default set of Marker options.
*
* - If `true` or `undefined` then a default marker will be used.
* - If the value is a [MarkerOptions](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MarkerOptions/) then the marker will be constructed using these options.
* - If the value is a function then it can return instance of the [Marker](https://maplibre.org/maplibre-gl-js/docs/API/classes/Marker/).
* Function can accept `Feature` as a parameter which is `undefined` for the reverse location marker.
* - If `false` or `null` then no marker will be added to the map.
*
* Requires that `options.maplibregl` also be set.
*
* Default value is `true`.
*/
marker?: null | boolean | MarkerOptions | ((map: Map, feature?: Feature) => undefined | null | Marker);
/**
* Marker be added to the map at the location the geocoding results.
*
* - If `true` or `undefined` then a default marker will be used.
* - If the value is a [MarkerOptions](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MarkerOptions/) then the marker will be constructed using these options.
* - If the value is a function then it can return instance of the [Marker](https://maplibre.org/maplibre-gl-js/docs/API/classes/Marker/).
* In this case the default pop-up won't be added to the marker.
* Function can accept `Feature` as a parameter.
* - If `false` or `null` then no marker will be added to the map.
*
* Requires that `options.maplibregl` also be set.
*
* Default value is `true`.
*/
showResultMarkers?: null | boolean | MarkerOptions | ((map: Map, feature: Feature) => undefined | null | Marker);
/**
* Animation to selected feature on the map.
*
* - If `false` or `null` then animating the map to a selected result is disabled.
* - If `true` or `undefined` then animating the map will use the default animation parameters.
* - If an [FlyToOptions](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/FlyToOptions/)
* ` & `[FitBoundsOptions](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/FitBoundsOptions/)
* then it will be passed as options to the map [flyTo](https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/#flyto)
* or [fitBounds](https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/#fitbounds) method providing control over the animation of the transition.
*
* Default value is `true`.
*/
flyTo?: null | boolean | (FlyToOptions & FitBoundsOptions);
/**
* Style for full feature geometry GeoJSON.
*
* - If `false` or `null` then no full geometry is drawn.
* - If `true` or `undefined` then default-styled full geometry is drawn.
* - If an object then it must represent the style and will be used to style the full geometry.
*
* Default is the default style.
*/
fullGeometryStyle?: null | boolean | FullGeometryStyle;
};
export type Props<T> = T extends SvelteComponent<infer P> ? P : never;
type EventedConstructor = new (...args: ConstructorParameters<typeof Evented>) => Evented;
export declare function crateBaseClass(Evented: EventedConstructor, maplibreGl: MapLibreGL, getExtraProps?: (map: Map, div: HTMLElement) => Partial<Props<GeocodingControlComponent>>): {
new <T extends MapLibreBaseControlOptions>(options?: T): {
"__#1@#gc"?: GeocodingControlComponent;
"__#1@#options": T;
onAddInt(map: Map): HTMLElement;
setOptions(options: T): void;
setQuery(value: string, submit?: boolean): void;
clearMap(): void;
clearList(): void;
setReverseMode(value: boolean): void;
focus(): void;
blur(): void;
onRemove(): void;
_listeners: import("maplibre-gl").Listeners;
_oneTimeListeners: import("maplibre-gl").Listeners;
_eventedParent: Evented;
_eventedParentData: any | (() => any);
on(type: string, listener: import("maplibre-gl").Listener): any;
off(type: string, listener: import("maplibre-gl").Listener): any;
once(type: string, listener?: import("maplibre-gl").Listener): Promise<any> | any;
fire(event: {
readonly type: string;
} | string, properties?: any): any;
listens(type: string): boolean;
setEventedParent(parent?: Evented | null, data?: any | (() => any)): any;
};
};
100 changes: 100 additions & 0 deletions maptiler-geocoding-control/v2.0.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<p align="center">
<a href="https://www.maptiler.com/cloud/geocoding/">official page →</a><br>
<img src="images/maptiler-logo.svg" width="350px">
</p>

<p align="center" style="color: #AAA">
The Javascript & TypeScript Map Control component for <a href="https://www.maptiler.com/cloud/geocoding">MapTiler Geocoding</a> service! Easy to be integrated into any JavaScript mapping application.
</p>

<p align="center">
<img src="images/JS-logo.svg" width="20px">
<img src="images/TS-logo.svg" width="20px">
<img src="images/react-logo.svg" width="20px">
<img src="images/svelte-logo.svg" width="20px">
<img src="https://img.shields.io/npm/v/@maptiler/geocoding-control"></img>
<img src="https://img.shields.io/twitter/follow/maptiler?style=social"></img>
</p>

# MapTiler Geocoding control for MapTiler SDK, MapLibre GL JS, Leaflet and OpenLayers

## About

A _Geocoding control_ for [MapTiler SDK](https://github.com/maptiler/maptiler-sdk-js),
[MapLibre GL JS](https://github.com/maplibre/maplibre-gl-js),
[Leaflet](https://leafletjs.com) and [OpenLayers](https://openlayers.org) utilizes [MapTiler Cloud Geocoding
API](https://www.maptiler.com/cloud/geocoding/). With this control, users of
mapping application can find any place on Earth (States, Cities, Streets, Addresses, POIs, ...) down
to the address level, restrict the search area to a specific country, highlight
searched results on the map, autocomplete words while typing, and much more.

The component can be used as an ES module or UMD module with or without bundler.

Geocoding control is also provided as [React component](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/react/) and [Svelte component](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/svelte/) and [other libraries](#installation-and-more-usage-examples).

## Quick start

Install the Geocoding control unsing `npm`:

```shell
npm install --save @maptiler/geocoding-control @maptiler/sdk
```

Use the component in your mapping application:

```js
import * as maptilersdk from "@maptiler/sdk";
import { GeocodingControl } from "@maptiler/geocoding-control/maptilersdk";
import "@maptiler/sdk/dist/maptiler-sdk.css";
import "@maptiler/geocoding-control/style.css";

maptilersdk.config.apiKey = "YOUR_MAPTILER_API_KEY_HERE";

const map = new maptilersdk.Map({
container: "map", // id of HTML container element
});

const gc = new GeocodingControl();

map.addControl(gc);
```

NOTE: Get your personal [MapTiler API key](https://docs.maptiler.com/cloud/api/authentication-key/) in the [MapTiler Cloud](https://cloud.maptiler.com).

## Installation and more usage examples

- [With MapTiler SDK](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/sdk-js/)
- [With MapLibre GL](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/maplibre-gl-js/)
- [With Leaflet](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/leaflet/)
- [With OpenLayers](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/openlayers/)
- [As a React component](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/react/)
- [As Svelte component](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/svelte/)
- [As vanilla JavaScript module](https://docs.maptiler.com/sdk-js/modules/geocoding/api/usage/vanilla-js/)

## API Documentation

In addition to the details and examples provided in this `README.md` and our documentation, check out

- [The complete Geocoding service API documentation](https://docs.maptiler.com/cloud/api/geocoding/)
- [The complete Geocoding control reference](https://docs.maptiler.com/sdk-js/modules/geocoding/api/api-reference/)
- [UMD global variables](https://docs.maptiler.com/sdk-js/modules/geocoding/#umd-global-variables)

## Development

### Building

```bash
npm install && npm run build
```

You will find compilation result in the `dist` directory.

### Running in dev mode

```bash
npm install && VITE_API_KEY=YOUR_MAPTILER_API_KEY_HERE npm run dev
```

### POI icons and bundlers

POI icons are served from CDN per default. If there is an requirement to serve them from a different location and the control is used in the application which is built with Web Application bundler (like Webpack or Vite) then it is necessary to do some extra configuration. Icons are bundled in the library and you can find them in `node_modules/@maptiler/geocoding-control/icons`. Configure your bundler and/or provide `iconsBaseUrl` option for the icons to be properly resolved. You can also copy icons from that directory to your `public` directory.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare module "geo-coordinates-parser" {
function convert(input: string, decimalPlaces: number): {
decimalLatitude: number;
decimalLongitude: number;
verbatimLatitude: string;
verbatimLongitude: string;
};
}
3 changes: 3 additions & 0 deletions maptiler-geocoding-control/v2.0.0/geoUtils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { BBox } from "./types";
export declare function wrapNum(x: number, range: [number, number], includeMax: boolean): number;
export declare function unwrapBbox(bbox0: BBox): BBox;
1 change: 1 addition & 0 deletions maptiler-geocoding-control/v2.0.0/icons/10pin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions maptiler-geocoding-control/v2.0.0/icons/9pin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions maptiler-geocoding-control/v2.0.0/icons/aerialway.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions maptiler-geocoding-control/v2.0.0/icons/aerodrome.12.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions maptiler-geocoding-control/v2.0.0/icons/aerodrome.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions maptiler-geocoding-control/v2.0.0/icons/airfield.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions maptiler-geocoding-control/v2.0.0/icons/airport.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions maptiler-geocoding-control/v2.0.0/icons/alcohol.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions maptiler-geocoding-control/v2.0.0/icons/alcohol_shop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions maptiler-geocoding-control/v2.0.0/icons/alpine_hut.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions maptiler-geocoding-control/v2.0.0/icons/amusement_park.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions maptiler-geocoding-control/v2.0.0/icons/animal_shelter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions maptiler-geocoding-control/v2.0.0/icons/apartment.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions maptiler-geocoding-control/v2.0.0/icons/aquarium.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e429da5

Please sign in to comment.