Skip to content

Commit 25f8660

Browse files
authored
Merge pull request #16 from OpenICGC/devel
0.0.96 geocoder with options
2 parents 7542319 + ac2191d commit 25f8660

File tree

10 files changed

+5319
-5284
lines changed

10 files changed

+5319
-5284
lines changed
Lines changed: 5009 additions & 4992 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { p as Ui } from "./index-DMlHD4NY.mjs";
1+
import { p as Ui } from "./index-NFWyDjBL.mjs";
22
var Zt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
33
function No(i) {
44
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;

dist/mapicgc-gl.js

Lines changed: 132 additions & 132 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/mapicgc-gl.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { C as p, a as s, M as r } from "./index-DMlHD4NY.mjs";
1+
import { C as p, a as s, M as r } from "./index-NFWyDjBL.mjs";
22
export {
33
p as CompareMaps,
44
s as Config,

dist/mapicgc-gl.umd.js

Lines changed: 132 additions & 132 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docu_Map.md

550 Bytes
addGeocoderICGC([options], [position]) ⇒ Object

Add geocoder.

Add geocoder with customizable options.

getConfigStyles() ⇒ Array

Retrieves the available base styles from default options.

getConfigWMSLayers() ⇒ Array

Retrieves the available WMS image layers from default options.

getConfigOrtoLayers() ⇒ Array

Retrieves the available orto image layers from default options.

getConfigVectorLayers() ⇒ Array

Retrieves the available vector layers from default options.

getConfigVectorAdminLayers() ⇒ Array

Retrieves the available vector layers from default options.

getConfigFGBAdminLayers() ⇒ Array

Retrieves the available fgb layers from default options.

fetchData(url, idLayer, options)

Fetches GeoJSON data from a URL and adds a corresponding layer to the map based on the specified geometry type.

fetchDataAndMenu(url, idLayer, filterField, options)

Fetches GeoJSON data from a URL and adds a corresponding layer to the map based on the specified geometry type and adds to the Menu as a checkbox item.

on(type, func)

Adds an event listener to the map.

setStyle(style, [options])

Sets the style of the map.

addControl(control, [position])

Adds a control to the map with the specified position.

setSky(options)

Sets the sky properties of the map.

addMouseCoordControl([position])

Adds a mouse coordinate control to the map.

addGeolocateControl(options, [position])

Adds a geolocate control to the map.

addFullscreenControl(options, [position])

Adds a fullscreen control to the map.

addLayer(layer, layerIdOrder)

Adds a layer to the map.

addImage(id, image, options) ⇒ this

Adds an image to the map.

addSource(id, source) ⇒ this

Adds a source to the map.

addSprite(id, url, options) ⇒ this

Adds a sprite to the map.

areTilesLoaded() ⇒ boolean

Checks if all tiles in the viewport are loaded.

cameraForBounds(bounds, options) ⇒ CenterZoomBearing | undefined

Calculates the camera position for given bounds.

easeTo(options, eventData) ⇒ this

Eases the camera to a new position.

fitBounds(bounds, options, eventData) ⇒ this

Fits the map to the given geographical bounds.

fitScreenCoordinates(p0, p1, bearing, options, eventData) ⇒ this

Fits the map to the given screen coordinates.

flyTo(options, eventData) ⇒ this

Flies the camera to a new position.

getBearing() ⇒ number

Gets the current bearing of the map.

getBounds() ⇒ LngLatBounds

Gets the current geographical bounds of the map.

getCameraTargetElevation() ⇒ number

Gets the elevation for the point where the camera is looking.

getCanvas() ⇒ HTMLCanvasElement

Gets the map's element.

getCanvasContainer() ⇒ HTMLElement

Gets the HTML element containing the map's element.

getCenter() ⇒ LngLat

Returns the map's geographical centerpoint.

getContainer() ⇒ HTMLElement

Returns the map's containing HTML element.

getFeatureState(feature) ⇒ any

Gets the state of a feature.

getFilter(layerId) ⇒ void | FilterSpecification

Returns the filter applied to the specified style layer.

getGlyphs() ⇒ string

Returns the value of the style's glyphs URL.

getImage(id) ⇒ StyleImage

Returns an image currently available in the map.

getLayer(id) ⇒ StyleLayer

Returns the layer with the specified ID in the map's style.

getLayersOrder() ⇒ Array.<string>

Return the ids of all layers currently in the style, including custom layers, in order.

getLayoutProperty(layerId, name) ⇒ any

Returns the value of a layout property in the specified style layer.

getLight() ⇒ LightSpecification

Returns the value of the light object.

getMaxBounds() ⇒ LngLatBounds

Returns the maximum geographical bounds the map is constrained to.

getMaxPitch() ⇒ number

Returns the map's maximum allowable pitch.

getMaxZoom() ⇒ number

Returns the map's maximum allowable zoom level.

getMinPitch() ⇒ number

Returns the map's minimum allowable pitch.

getMinZoom() ⇒ number

Returns the map's minimum allowable zoom level.

getPadding() ⇒ PaddingOptions

Returns the current padding applied around the map viewport.

getPaintProperty(layerId, name) ⇒ unknown

Returns the value of a paint property in the specified style layer.

getPitch() ⇒ number

Returns the map's current pitch (tilt).

getPixelRatio() ⇒ number

Returns the map's pixel ratio.

getRenderWorldCopies() ⇒ boolean

Returns the state of renderWorldCopies.

getSource(id) ⇒ Source

Returns the source with the specified ID in the map's style.

getSprite() ⇒ Array.<object>

Returns the as-is value of the style's sprite.

getStyle() ⇒ StyleSpecification

Returns the map's MapLibre style object.

getTerrain() ⇒ TerrainSpecification

Get the terrain-options if terrain is loaded.

getZoom() ⇒ number

Returns the map's current zoom level.

hasControl(control) ⇒ boolean

Checks if a control exists on the map.

hasImage(id) ⇒ boolean

Check whether or not an image with a specific ID exists in the style.

isMoving() ⇒ boolean

Returns true if the map is panning, zooming, rotating, or pitching due to a camera animation or user gesture.

isRotating() ⇒ boolean

Returns true if the map is rotating due to a camera animation or user gesture.

isSourceLoaded(id) ⇒ boolean

Returns a Boolean indicating whether the source is loaded.

isStyleLoaded() ⇒ boolean | void

Returns a Boolean indicating whether the map's style is fully loaded.

isZooming() ⇒ boolean

Returns true if the map is zooming due to a camera animation or user gesture.

jumpTo(options, [eventData]) ⇒ this

Changes any combination of center, zoom, bearing, and pitch, without an animated transition.

listImages() ⇒ Array.<string>

Returns an Array of strings containing the IDs of all images currently available in the map.

listens(type) ⇒ boolean

Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.

loadImage(url) ⇒ Promise.<GetResourceResponse.<(ImageBitmap|HTMLImageElement)>>

Load an image from an external URL to be used with Map#addImage.

loaded() ⇒ boolean

Returns a Boolean indicating whether the map is fully loaded.

addProtocol(customProtocol, loadFn) ⇒ void

Adds a custom load resource function that will be called when using a URL that starts with a custom URL schema.

moveLayer(id, [beforeId]) ⇒ this

Moves a layer to a different z-position.

panBy(offset, [options], [eventData]) ⇒ this

Pans the map by the specified offset.

panTo(lnglat, [options], [eventData]) ⇒ this

Pans the map to the specified location with an animated transition.

project(lnglat) ⇒ Point

Returns a Point representing pixel coordinates, relative to the map's container, that correspond to the specified geographical location.

queryRenderedFeatures([geometryOrOptions], [options]) ⇒ Array

Queries rendered features within a specified geometry or bounding box.

querySourceFeatures(sourceId, parameters) ⇒ Array

Queries source features within a specified source.

queryTerrainElevation(lngLatLike) ⇒ number

Queries the terrain elevation at a specified geographical location.

redraw() ⇒ this

Redraws the map.

remove() ⇒ this

Removes the map from the DOM.

removeControl(control) ⇒ this

Removes a control from the map.

removeFeatureState(target, [key]) ⇒ this

Removes the state of a feature.

removeImage(id) ⇒ this

Removes an image from the style's sprite.

removeLayer(idLayer)

Removes a layer from the map.

removeSource(idLayer)

Removes a source from the map.

removeSprite(id) ⇒ this

Removes a sprite from the style.

resetNorth([options], [eventData]) ⇒ this

Resets the map orientation so that north is up.

resetNorthPitch([options], [eventData]) ⇒ this

Resets the map orientation so that north is up and pitch is set to 0┬░.

resize([eventData]) ⇒ this

Resizes the map to fit its container.

rotateTo(bearing, [options], [eventData]) ⇒ this

Rotates the map to the specified bearing with an animated transition.

setBearing(bearing, [eventData]) ⇒ this

Sets the map's bearing with an optional animated transition.

setCenter(center, [eventData]) ⇒ this

Sets the map's center coordinates with an optional animated transition.

setEventedParent([parent], [data]) ⇒ this

Sets the parent of the map's event emitter.

setFeatureState(feature, state) ⇒ this

Sets the state of a feature.

setFilter(layerId, [filter], [options]) ⇒ this

Sets the filter for a specified layer.

setGlyphs(glyphsUrl, [options]) ⇒ this

Sets the glyphs for the map's style.

setLayerZoomRange(layerId, minzoom, maxzoom) ⇒ this

Sets the zoom range for a specified layer.

setLayoutProperty(layerId, name, value, [options]) ⇒ this

Sets a layout property for a specified layer.

setLight(light, [options]) ⇒ this

Sets the light for the map's style.

setMaxBounds(bounds) ⇒ this

Sets the maximum bounds for the map.

setMaxPitch(maxPitch) ⇒ this

Sets the maximum pitch for the map.

setMaxZoom(maxZoom) ⇒ this

Sets the maximum zoom level for the map.

setMinPitch(minPitch) ⇒ this

Sets the minimum pitch for the map.

setMinZoom(minZoom) ⇒ this

Sets the minimum zoom level for the map.

setPadding(padding, [eventData]) ⇒ this

Sets padding for the map's container.

setPaintProperty(layerId, name, value, [options]) ⇒ this

Sets a paint property for a specified layer.

setPitch(pitch, [eventData]) ⇒ this

Sets the map's pitch angle with an optional animated transition.

setPixelRatio(pixelRatio) ⇒ this

Sets the pixel ratio for the map.

setRenderWorldCopies(renderWorldCopies) ⇒ this

Sets whether the map should render world copies when the center longitude is greater than or less than ┬▒180 degrees.

setSprite(spriteUrl, [options]) ⇒ this

Sets the sprite for the map's style.

setTerrain(options) ⇒ this

Loads a 3D terrain mesh based on a "raster-dem" source.

setTransformRequest(transformRequest) ⇒ this

Updates the requestManager's transform request with a new function.

setZoom(zoom, [eventData]) ⇒ this

Sets the map's zoom level.

snapToNorth([options], [eventData]) ⇒ this

Snaps the map so that north is up (0┬░ bearing), if the current bearing is close enough to it.

stop() ⇒ this

Stops any animated transition underway.

triggerRepaint() ⇒ void

Triggers the rendering of a single frame.

unproject(point) ⇒ LngLat

Returns geographical coordinates corresponding to the specified pixel coordinates.

updateImage(id, image) ⇒ this

Updates an existing image in the style's sprite.

zoomIn([options], [eventData]) ⇒ this

Increases the map's zoom level by 1.

zoomOut([options], [eventData]) ⇒ this

Decreases the map's zoom level by 1.

zoomTo(zoom, [options], [eventData]) ⇒ this

Zooms the map to the specified zoom level with an animated transition.

addLayerGeoJSON(layer, layerPosition)

Adds a GeoJSON layer to the map.

addLayerWMS(tiles, idLayer, options)

Adds a WMS layer to the map.

addLogo(options)

Adds a logo to the map.

addBasemapsICGC(basesArray)

Adds base layers to the map.

addBasemaps(baseLayers)

Adds base layers to the map.

addFeatureQuery(idLayer, queryFields, popupStyle)

Adds feature query function to a layer.

addScaleControl(options, position)

Adds a scale control to the map.

  • @function addScaleControl
addExportControl(options, [position])

Adds an export control to the map with the provided options and position.

addMarker(options) ⇒ Object

Adds a marker to the map.

addPopup(options, coord, text, popupStyle) ⇒ Object

Adds a popup to the map.

addFullScreen([position])

Adds a fullscreen control to the map.

addMenuItem(name)

Adds a menu item with a checkbox for controlling the visibility of a layer on the map.

addLayerTree(options)

Adds a layer tree to the map.

createNavigationControl(options, [position]) ⇒ Object

Creates a navigation control with the provided options.

addNavigationControl(options, [position])

Adds a navigation control to the map with the provided options.

addAttributionControl(options, [position])

Adds an attribution control to the map with the provided options.

addImageLayerICGC(url, idLayer, options)

Adds an ICGC image layer to the map based on the specified name and year.

addVectorLayerICGC(url, idLayer, options)

Adds an ICGC vector layer to the map based on the specified name and year.

addFGBLayerICGC(url, idLayer, options)

Adds an ICGC FGB layer to the map based on the specified name and year.

addTerrainICGC(url, controlPosition)

Adds 3D terrain to the map using hillshade.

addLegend(url, idLayer)

Add image legend.

_findImageType(url, var1, var2, var3, var4) ⇒ string | null

Finds the type of image based on the provided URL and specified vectors.

_getKeyByUrlFGB(url) ⇒ string | null

Gets the key by URL from the FGBAdmin layers.

_getLegendByName(name) ⇒ string | null

Gets the legend by name from the default vector layers.

_getKeyByUrlVector(url) ⇒ string | null

Gets the key by URL from the Vector layers.

_raiseText3DStyle() ⇒ Promise.<void>

Raises text 3D style on the map.

_dealStyleMaps(name) ⇒ Object | string | null

Deals with map styles based on the name.

_dealOrto3dStyle(name) ⇒ void | null

Deals with the 3D ortho style based on the name.

_dealOrderLayer(order) ⇒ string

Deals with the order of the layer.

_firstSymbolLayer() ⇒ string | undefined

Retrieves the id of the first symbol layer.

_firstLineLayer() ⇒ string | undefined

Retrieves the id of the first line layer.

_createCitiesMapboxLayer() ⇒ MapboxLayer | null

Creates a Mapbox layer for displaying cities in 3D.

addGeocoderICGC([options], [position]) ⇒ Object

Add geocoder.

Add geocoder with customizable options.

Kind: global function
Returns: Object - - The current position of the search resultmerged configuration options for the geocoder, including the position.

Param Type Default Description
[position] string "'top-right'" Position to add the control on the map.
Param Type Default Description
[options] Object {} Optional configuration options for the geocoder. Defaults to an empty object.
[position] string "'top-right'" Position to add the geocoder control on the map. Defaults to 'top-right'.

package-lock.json

Lines changed: 24 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mapicgc-gl-js",
33
"homepage": "https://openicgc.github.io/mapicgc-doc/",
4-
"version": "0.0.95",
4+
"version": "0.0.96",
55
"description": "mapicgc-gl-js library",
66
"author": "Institut Cartogràfic i Geològic de Catalunya",
77
"license": "BSD-3-Clause",
@@ -44,6 +44,7 @@
4444
"@babel/core": "^7.23.9",
4545
"@babel/preset-env": "^7.23.9",
4646
"@rollup/plugin-babel": "^6.0.4",
47+
"axios": "^1.7.9",
4748
"dotenv": "^16.3.1",
4849
"jest": "29.7.0",
4950
"jsdoc": "^4.0.2",
@@ -53,7 +54,8 @@
5354
"rollup-plugin-polyfill": "^4.2.0",
5455
"ssh2-sftp-client": "^9.0.4",
5556
"vite": "^5.2.10",
56-
"vite-plugin-node-polyfills": "^0.21.0"
57+
"vite-plugin-node-polyfills": "^0.21.0",
58+
"xml2js": "^0.6.2"
5759
},
5860
"dependencies": {
5961
"@deck.gl/core": "~8.9.35",
@@ -63,10 +65,9 @@
6365
"@maplibre/maplibre-gl-compare": "^0.5.0",
6466
"@maplibre/maplibre-gl-geocoder": "^1.5.0",
6567
"@watergis/maplibre-gl-export": "^3.7.0",
66-
"axios": "^1.6.7",
6768
"flatgeobuf": "^3.31.1",
6869
"maplibre-gl": "^4.7.1",
69-
"utm-latlng": "^1.0.8",
70-
"xml2js": "^0.6.2"
70+
"utm-latlng": "^1.0.8"
71+
7172
}
7273
}

src/map/Map.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,25 +132,29 @@ export default class Map {
132132

133133
}
134134
/**
135-
* Add geocoder.
135+
* Add geocoder with customizable options.
136136
* @function addGeocoderICGC
137-
* @param {string} [position='top-right'] - Position to add the control on the map.
138-
* @returns {Object} - The current position of the search result.
137+
* @param {Object} [options={}] - Optional configuration options for the geocoder. Defaults to an empty object.
138+
* @param {string} [position='top-right'] - Position to add the geocoder control on the map. Defaults to 'top-right'.
139+
* @returns {Object} - The merged configuration options for the geocoder, including the position.
140+
*
139141
*/
140-
addGeocoderICGC(position) {
142+
addGeocoderICGC(options = {}, position = "top-right") {
141143
try {
142-
if (position === undefined) {
143-
position = "top-right";
144-
}
145-
let options = {
144+
145+
const defOptions = {
146146
collapsed: true,
147147
marker: true,
148+
zoom: 16,
148149
popup: true,
149150
showResultMarkers: true,
150151
maplibregl: maplibregl,
151152
showResultsWhileTyping: true,
152153
minLength: 2,
153154
};
155+
options = { ...defOptions, ...options };
156+
157+
154158
const geocoderApi = {
155159
forwardGeocode: async (config) => {
156160
const features = [];

test/exemples/addGeocoderICGC.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
pitch: 0,
3535
});
3636
map.on("load", () => {
37-
map.addGeocoderICGC();
37+
let options = { zoom: 10 };
38+
map.addGeocoderICGC(options);
3839
});
3940
}
4041
initMap();

0 commit comments

Comments
 (0)