@maptiler/geocoding-control 2.1.7 → 3.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CODE_OF_CONDUCT.md +46 -0
- package/CONTRIBUTING.md +72 -0
- package/README.md +115 -43
- package/SECURITY.md +16 -0
- package/dist/index.js +860 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +263 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/leaflet.public.js +1251 -0
- package/dist/leaflet.public.js.map +1 -0
- package/dist/leaflet.public.umd.js +276 -0
- package/dist/leaflet.public.umd.js.map +1 -0
- package/dist/maplibregl.js +1275 -0
- package/dist/maplibregl.js.map +1 -0
- package/dist/maplibregl.umd.js +276 -0
- package/dist/maplibregl.umd.js.map +1 -0
- package/dist/maptilersdk.js +1283 -0
- package/dist/maptilersdk.js.map +1 -0
- package/dist/maptilersdk.umd.js +276 -0
- package/dist/maptilersdk.umd.js.map +1 -0
- package/dist/src/components/clear-icon.d.ts +10 -0
- package/dist/src/components/fail-icon.d.ts +10 -0
- package/dist/src/components/loading-icon.d.ts +10 -0
- package/dist/src/components/marker.d.ts +10 -0
- package/dist/src/components/reverse-geocoding-icon.d.ts +10 -0
- package/dist/src/components/search-icon.d.ts +10 -0
- package/dist/src/controls/base-control.d.ts +44 -0
- package/dist/src/controls/leaflet-control.d.ts +27 -0
- package/dist/src/controls/leaflet-events.d.ts +42 -0
- package/dist/src/controls/leaflet-options.d.ts +84 -0
- package/dist/src/controls/maplibregl-control.d.ts +34 -0
- package/dist/src/controls/maplibregl-events.d.ts +44 -0
- package/dist/src/controls/maplibregl-options.d.ts +104 -0
- package/dist/src/controls/maptilersdk-control.d.ts +7 -0
- package/dist/src/controls/maptilersdk-events.d.ts +2 -0
- package/dist/src/controls/maptilersdk-options.d.ts +10 -0
- package/dist/src/controls/openlayers-control.d.ts +35 -0
- package/dist/src/controls/openlayers-events.d.ts +43 -0
- package/dist/src/controls/openlayers-options.d.ts +83 -0
- package/dist/src/geocoder/geocoder-events.d.ts +46 -0
- package/dist/src/geocoder/geocoder-feature-item.d.ts +22 -0
- package/{svelte/types.d.ts → dist/src/geocoder/geocoder-options.d.ts} +23 -143
- package/dist/src/geocoder/geocoder.d.ts +113 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/leaflet.public.d.ts +7 -0
- package/dist/src/maplibregl.d.ts +7 -0
- package/dist/src/maptilersdk.d.ts +7 -0
- package/dist/src/openlayers.public.d.ts +7 -0
- package/dist/src/types.d.ts +46 -0
- package/dist/src/utils/geo-utils.d.ts +6 -0
- package/dist/src/utils/mask.d.ts +2 -0
- package/dist/src/utils/proximity.d.ts +2 -0
- package/package.json +84 -112
- package/MapLibreBasedGeocodingControl.d.ts +0 -3072
- package/geo-coordinates-parser.t.d.ts +0 -8
- package/geoUtils.d.ts +0 -3
- package/leaflet-controller.d.ts +0 -12
- package/leaflet-controller.js +0 -2475
- package/leaflet-controller.js.map +0 -1
- package/leaflet-controller.umd.js +0 -2
- package/leaflet-controller.umd.js.map +0 -1
- package/leaflet.d.ts +0 -131
- package/leaflet.js +0 -5082
- package/leaflet.js.map +0 -1
- package/leaflet.umd.js +0 -14
- package/leaflet.umd.js.map +0 -1
- package/maplibregl-controller.d.ts +0 -19
- package/maplibregl-controller.js +0 -2418
- package/maplibregl-controller.js.map +0 -1
- package/maplibregl-controller.umd.js +0 -2
- package/maplibregl-controller.umd.js.map +0 -1
- package/maplibregl.d.ts +0 -2509
- package/maplibregl.js +0 -5142
- package/maplibregl.js.map +0 -1
- package/maplibregl.umd.js +0 -14
- package/maplibregl.umd.js.map +0 -1
- package/maptilersdk.d.ts +0 -2504
- package/maptilersdk.js +0 -5152
- package/maptilersdk.js.map +0 -1
- package/maptilersdk.umd.js +0 -14
- package/maptilersdk.umd.js.map +0 -1
- package/mask.d.ts +0 -2
- package/openlayers-controller.d.ts +0 -15
- package/openlayers-controller.js +0 -2174
- package/openlayers-controller.js.map +0 -1
- package/openlayers-controller.umd.js +0 -2
- package/openlayers-controller.umd.js.map +0 -1
- package/openlayers.d.ts +0 -109
- package/openlayers.js +0 -5045
- package/openlayers.js.map +0 -1
- package/openlayers.umd.js +0 -14
- package/openlayers.umd.js.map +0 -1
- package/proximity.d.ts +0 -2
- package/react.d.ts +0 -45
- package/react.js +0 -2795
- package/react.js.map +0 -1
- package/react.umd.js +0 -14
- package/react.umd.js.map +0 -1
- package/style.css +0 -1
- package/svelte/ClearIcon.svelte +0 -12
- package/svelte/ClearIcon.svelte.d.ts +0 -25
- package/svelte/FailIcon.svelte +0 -12
- package/svelte/FailIcon.svelte.d.ts +0 -25
- package/svelte/FeatureItem.svelte +0 -246
- package/svelte/FeatureItem.svelte.d.ts +0 -26
- package/svelte/GeocodingControl.svelte +0 -921
- package/svelte/GeocodingControl.svelte.d.ts +0 -105
- package/svelte/LoadingIcon.svelte +0 -40
- package/svelte/LoadingIcon.svelte.d.ts +0 -25
- package/svelte/MapLibreBasedGeocodingControl.d.ts +0 -3072
- package/svelte/MapLibreBasedGeocodingControl.js +0 -210
- package/svelte/MarkerIcon.svelte +0 -71
- package/svelte/MarkerIcon.svelte.d.ts +0 -18
- package/svelte/ReverseGeocodingIcon.svelte +0 -12
- package/svelte/ReverseGeocodingIcon.svelte.d.ts +0 -25
- package/svelte/SearchIcon.svelte +0 -26
- package/svelte/SearchIcon.svelte.d.ts +0 -25
- package/svelte/geo-coordinates-parser.t.d.ts +0 -8
- package/svelte/geo-coordinates-parser.t.js +0 -1
- package/svelte/geoUtils.d.ts +0 -3
- package/svelte/geoUtils.js +0 -18
- package/svelte/info.json +0 -1
- package/svelte/leaflet-controller.d.ts +0 -12
- package/svelte/leaflet-controller.js +0 -274
- package/svelte/leaflet.d.ts +0 -131
- package/svelte/leaflet.js +0 -116
- package/svelte/maplibregl-controller.d.ts +0 -19
- package/svelte/maplibregl-controller.js +0 -279
- package/svelte/maplibregl.d.ts +0 -2509
- package/svelte/maplibregl.js +0 -17
- package/svelte/maptilersdk.d.ts +0 -2504
- package/svelte/maptilersdk.js +0 -32
- package/svelte/mask.d.ts +0 -2
- package/svelte/mask.js +0 -54
- package/svelte/openlayers-controller.d.ts +0 -15
- package/svelte/openlayers-controller.js +0 -283
- package/svelte/openlayers.d.ts +0 -109
- package/svelte/openlayers.js +0 -178
- package/svelte/proximity.d.ts +0 -2
- package/svelte/proximity.js +0 -60
- package/svelte/react.d.ts +0 -45
- package/svelte/react.js +0 -106
- package/svelte/types.js +0 -1
- package/svelte/vanilla.d.ts +0 -61
- package/svelte/vanilla.js +0 -101
- package/svelte/vite-env.d.ts +0 -2
- package/types.d.ts +0 -391
- package/vanilla.d.ts +0 -61
- package/vanilla.js +0 -2799
- package/vanilla.js.map +0 -1
- package/vanilla.umd.js +0 -14
- package/vanilla.umd.js.map +0 -1
- /package/{icons → dist/icons}/10pin.svg +0 -0
- /package/{icons → dist/icons}/9pin.svg +0 -0
- /package/{icons → dist/icons}/advertising_column.svg +0 -0
- /package/{icons → dist/icons}/aerodrome.svg +0 -0
- /package/{icons → dist/icons}/alcohol.svg +0 -0
- /package/{icons → dist/icons}/alpine_hut.svg +0 -0
- /package/{icons → dist/icons}/amusement_arcade.svg +0 -0
- /package/{icons → dist/icons}/amusement_park.svg +0 -0
- /package/{icons → dist/icons}/apartment.svg +0 -0
- /package/{icons → dist/icons}/archaeological_site.svg +0 -0
- /package/{icons → dist/icons}/area.svg +0 -0
- /package/{icons → dist/icons}/art.svg +0 -0
- /package/{icons → dist/icons}/arts_centre.svg +0 -0
- /package/{icons → dist/icons}/artwork.svg +0 -0
- /package/{icons → dist/icons}/audioguide.svg +0 -0
- /package/{icons → dist/icons}/bag.svg +0 -0
- /package/{icons → dist/icons}/beauty.svg +0 -0
- /package/{icons → dist/icons}/bed.svg +0 -0
- /package/{icons → dist/icons}/bell_tower.svg +0 -0
- /package/{icons → dist/icons}/beverages.svg +0 -0
- /package/{icons → dist/icons}/bicycle_repair_station.svg +0 -0
- /package/{icons → dist/icons}/biergarten.svg +0 -0
- /package/{icons → dist/icons}/bird_hide.svg +0 -0
- /package/{icons → dist/icons}/boat_rental.svg +0 -0
- /package/{icons → dist/icons}/bookmaker.svg +0 -0
- /package/{icons → dist/icons}/books.svg +0 -0
- /package/{icons → dist/icons}/bowl.svg +0 -0
- /package/{icons → dist/icons}/bowling_alley.svg +0 -0
- /package/{icons → dist/icons}/bunker.svg +0 -0
- /package/{icons → dist/icons}/bureau_de_change.svg +0 -0
- /package/{icons → dist/icons}/bus_station.svg +0 -0
- /package/{icons → dist/icons}/bust.svg +0 -0
- /package/{icons → dist/icons}/camping.svg +0 -0
- /package/{icons → dist/icons}/car_parts.svg +0 -0
- /package/{icons → dist/icons}/car_wash.svg +0 -0
- /package/{icons → dist/icons}/caravan_park.svg +0 -0
- /package/{icons → dist/icons}/carpet.svg +0 -0
- /package/{icons → dist/icons}/cattle_grid.svg +0 -0
- /package/{icons → dist/icons}/cave_entrance.svg +0 -0
- /package/{icons → dist/icons}/chalet.svg +0 -0
- /package/{icons → dist/icons}/charity.svg +0 -0
- /package/{icons → dist/icons}/chemist.svg +0 -0
- /package/{icons → dist/icons}/chimney.svg +0 -0
- /package/{icons → dist/icons}/church.svg +0 -0
- /package/{icons → dist/icons}/city_gate.svg +0 -0
- /package/{icons → dist/icons}/clinic.svg +0 -0
- /package/{icons → dist/icons}/clothes.svg +0 -0
- /package/{icons → dist/icons}/coffee.svg +0 -0
- /package/{icons → dist/icons}/community_centre.svg +0 -0
- /package/{icons → dist/icons}/computer.svg +0 -0
- /package/{icons → dist/icons}/consulate.svg +0 -0
- /package/{icons → dist/icons}/copyshop.svg +0 -0
- /package/{icons → dist/icons}/cosmetics.svg +0 -0
- /package/{icons → dist/icons}/courthouse.svg +0 -0
- /package/{icons → dist/icons}/crane.svg +0 -0
- /package/{icons → dist/icons}/dairy.svg +0 -0
- /package/{icons → dist/icons}/deli.svg +0 -0
- /package/{icons → dist/icons}/department_store.svg +0 -0
- /package/{icons → dist/icons}/diy.svg +0 -0
- /package/{icons → dist/icons}/electronics.svg +0 -0
- /package/{icons → dist/icons}/embankment.svg +0 -0
- /package/{icons → dist/icons}/embassy.svg +0 -0
- /package/{icons → dist/icons}/excrement_bags.svg +0 -0
- /package/{icons → dist/icons}/fabric.svg +0 -0
- /package/{icons → dist/icons}/farmyard.svg +0 -0
- /package/{icons → dist/icons}/ferry.svg +0 -0
- /package/{icons → dist/icons}/firepit.svg +0 -0
- /package/{icons → dist/icons}/firestation.svg +0 -0
- /package/{icons → dist/icons}/fishing.svg +0 -0
- /package/{icons → dist/icons}/fitness.svg +0 -0
- /package/{icons → dist/icons}/ford.svg +0 -0
- /package/{icons → dist/icons}/fort.svg +0 -0
- /package/{icons → dist/icons}/fortress.svg +0 -0
- /package/{icons → dist/icons}/full-height_turnstile.svg +0 -0
- /package/{icons → dist/icons}/generator_wind.svg +0 -0
- /package/{icons → dist/icons}/golf_pin.svg +0 -0
- /package/{icons → dist/icons}/greengrocer.svg +0 -0
- /package/{icons → dist/icons}/guest_house.svg +0 -0
- /package/{icons → dist/icons}/helipad.svg +0 -0
- /package/{icons → dist/icons}/hifi.svg +0 -0
- /package/{icons → dist/icons}/hostel.svg +0 -0
- /package/{icons → dist/icons}/hotel.svg +0 -0
- /package/{icons → dist/icons}/housenumber.svg +0 -0
- /package/{icons → dist/icons}/houseware.svg +0 -0
- /package/{icons → dist/icons}/hunting_stand.svg +0 -0
- /package/{icons → dist/icons}/interior_decoration.svg +0 -0
- /package/{icons → dist/icons}/internet_cafe.svg +0 -0
- /package/{icons → dist/icons}/kindergarten.svg +0 -0
- /package/{icons → dist/icons}/kissing_gate.svg +0 -0
- /package/{icons → dist/icons}/manor.svg +0 -0
- /package/{icons → dist/icons}/map.svg +0 -0
- /package/{icons → dist/icons}/marker_reverse.svg +0 -0
- /package/{icons → dist/icons}/marker_selected.svg +0 -0
- /package/{icons → dist/icons}/marker_unselected.svg +0 -0
- /package/{icons → dist/icons}/marketplace.svg +0 -0
- /package/{icons → dist/icons}/massage.svg +0 -0
- /package/{icons → dist/icons}/mast.svg +0 -0
- /package/{icons → dist/icons}/mast_communications.svg +0 -0
- /package/{icons → dist/icons}/mast_lighting.svg +0 -0
- /package/{icons → dist/icons}/medical_supply.svg +0 -0
- /package/{icons → dist/icons}/memorial.svg +0 -0
- /package/{icons → dist/icons}/miniature_golf.svg +0 -0
- /package/{icons → dist/icons}/motel.svg +0 -0
- /package/{icons → dist/icons}/mountain_range.svg +0 -0
- /package/{icons → dist/icons}/multifaith.svg +0 -0
- /package/{icons → dist/icons}/musical_instrument.svg +0 -0
- /package/{icons → dist/icons}/newsagent.svg +0 -0
- /package/{icons → dist/icons}/nightclub.svg +0 -0
- /package/{icons → dist/icons}/ocean.svg +0 -0
- /package/{icons → dist/icons}/office.svg +0 -0
- /package/{icons → dist/icons}/outdoor_seating.svg +0 -0
- /package/{icons → dist/icons}/palace.svg +0 -0
- /package/{icons → dist/icons}/parcel_locker.svg +0 -0
- /package/{icons → dist/icons}/parking_space.svg +0 -0
- /package/{icons → dist/icons}/parking_tickets.svg +0 -0
- /package/{icons → dist/icons}/pet.svg +0 -0
- /package/{icons → dist/icons}/photo.svg +0 -0
- /package/{icons → dist/icons}/picnic.svg +0 -0
- /package/{icons → dist/icons}/plaque.svg +0 -0
- /package/{icons → dist/icons}/poi.svg +0 -0
- /package/{icons → dist/icons}/post_box.svg +0 -0
- /package/{icons → dist/icons}/post_office.svg +0 -0
- /package/{icons → dist/icons}/postal_code.svg +0 -0
- /package/{icons → dist/icons}/pub.svg +0 -0
- /package/{icons → dist/icons}/public_bath.svg +0 -0
- /package/{icons → dist/icons}/public_bookcase.svg +0 -0
- /package/{icons → dist/icons}/public_building.svg +0 -0
- /package/{icons → dist/icons}/public_transport_tickets.svg +0 -0
- /package/{icons → dist/icons}/reverse.svg +0 -0
- /package/{icons → dist/icons}/river.svg +0 -0
- /package/{icons → dist/icons}/road.svg +0 -0
- /package/{icons → dist/icons}/saddle.svg +0 -0
- /package/{icons → dist/icons}/sauna.svg +0 -0
- /package/{icons → dist/icons}/sea.svg +0 -0
- /package/{icons → dist/icons}/second_hand.svg +0 -0
- /package/{icons → dist/icons}/shintoist.svg +0 -0
- /package/{icons → dist/icons}/shoe.svg +0 -0
- /package/{icons → dist/icons}/shower.svg +0 -0
- /package/{icons → dist/icons}/shrine.svg +0 -0
- /package/{icons → dist/icons}/sikhist.svg +0 -0
- /package/{icons → dist/icons}/slipway.svg +0 -0
- /package/{icons → dist/icons}/snowmobile.svg +0 -0
- /package/{icons → dist/icons}/social_facility.svg +0 -0
- /package/{icons → dist/icons}/sports.svg +0 -0
- /package/{icons → dist/icons}/sprite.json +0 -0
- /package/{icons → dist/icons}/sprite.png +0 -0
- /package/{icons → dist/icons}/sprite@2x.json +0 -0
- /package/{icons → dist/icons}/sprite@2x.png +0 -0
- /package/{icons → dist/icons}/stationery.svg +0 -0
- /package/{icons → dist/icons}/stile.svg +0 -0
- /package/{icons → dist/icons}/stone.svg +0 -0
- /package/{icons → dist/icons}/storage_tank.svg +0 -0
- /package/{icons → dist/icons}/stream.svg +0 -0
- /package/{icons → dist/icons}/street.svg +0 -0
- /package/{icons → dist/icons}/supermarket.svg +0 -0
- /package/{icons → dist/icons}/tea.svg +0 -0
- /package/{icons → dist/icons}/telescope_dish.svg +0 -0
- /package/{icons → dist/icons}/telescope_dome.svg +0 -0
- /package/{icons → dist/icons}/ticket.svg +0 -0
- /package/{icons → dist/icons}/tobacco.svg +0 -0
- /package/{icons → dist/icons}/tower_cantilever_communication.svg +0 -0
- /package/{icons → dist/icons}/tower_cooling.svg +0 -0
- /package/{icons → dist/icons}/tower_dish.svg +0 -0
- /package/{icons → dist/icons}/tower_dome.svg +0 -0
- /package/{icons → dist/icons}/tower_generic.svg +0 -0
- /package/{icons → dist/icons}/tower_lattice.svg +0 -0
- /package/{icons → dist/icons}/tower_lattice_communication.svg +0 -0
- /package/{icons → dist/icons}/tower_lattice_lighting.svg +0 -0
- /package/{icons → dist/icons}/tower_lighting.svg +0 -0
- /package/{icons → dist/icons}/townhall.svg +0 -0
- /package/{icons → dist/icons}/toys.svg +0 -0
- /package/{icons → dist/icons}/trade.svg +0 -0
- /package/{icons → dist/icons}/traffic_light.svg +0 -0
- /package/{icons → dist/icons}/train_station.svg +0 -0
- /package/{icons → dist/icons}/travel_agency.svg +0 -0
- /package/{icons → dist/icons}/tyres.svg +0 -0
- /package/{icons → dist/icons}/university.svg +0 -0
- /package/{icons → dist/icons}/variety_store.svg +0 -0
- /package/{icons → dist/icons}/vehicle_inspection.svg +0 -0
- /package/{icons → dist/icons}/vending_machine.svg +0 -0
- /package/{icons → dist/icons}/video.svg +0 -0
- /package/{icons → dist/icons}/video_games.svg +0 -0
- /package/{icons → dist/icons}/waste_disposal.svg +0 -0
- /package/{icons → dist/icons}/water_well.svg +0 -0
- /package/{icons → dist/icons}/waterfall.svg +0 -0
- /package/{icons → dist/icons}/wilderness_hut.svg +0 -0
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import { feature, featureCollection } from "@turf/helpers";
|
|
2
|
-
import union from "@turf/union";
|
|
3
|
-
import MarkerIcon from "./MarkerIcon.svelte";
|
|
4
|
-
import { setMask } from "./mask";
|
|
5
|
-
const defaultGeometryStyle = {
|
|
6
|
-
fill: {
|
|
7
|
-
paint: {
|
|
8
|
-
"fill-color": "#000",
|
|
9
|
-
"fill-opacity": 0.1,
|
|
10
|
-
},
|
|
11
|
-
filter: ["all", ["==", ["geometry-type"], "Polygon"], ["has", "isMask"]],
|
|
12
|
-
},
|
|
13
|
-
line: {
|
|
14
|
-
layout: {
|
|
15
|
-
"line-cap": "square",
|
|
16
|
-
},
|
|
17
|
-
paint: {
|
|
18
|
-
"line-width": ["case", ["==", ["geometry-type"], "Polygon"], 2, 3],
|
|
19
|
-
"line-dasharray": [1, 1],
|
|
20
|
-
"line-color": "#3170fe",
|
|
21
|
-
},
|
|
22
|
-
filter: ["!", ["has", "isMask"]],
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
const RESULT_SOURCE = "mtlr-gc-full-geom";
|
|
26
|
-
const RESULT_LAYER_FILL = "mtlr-gc-full-geom-fill";
|
|
27
|
-
const RESULT_LAYER_LINE = "mtlr-gc-full-geom-line";
|
|
28
|
-
export function createMapLibreGlMapController(map, maplibregl, marker = true, showResultMarkers = true, flyToOptions = {}, fitBoundsOptions = {}, fullGeometryStyle = defaultGeometryStyle) {
|
|
29
|
-
let eventHandler;
|
|
30
|
-
const markers = [];
|
|
31
|
-
let selectedMarker;
|
|
32
|
-
let reverseMarker;
|
|
33
|
-
let savedData; // used to restore features on style switch
|
|
34
|
-
function syncFullGeometryLayer() {
|
|
35
|
-
if (!map.loaded) {
|
|
36
|
-
map.once("load", syncFullGeometryLayer);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const effFullGeometryStyle = !fullGeometryStyle
|
|
40
|
-
? undefined
|
|
41
|
-
: fullGeometryStyle === true
|
|
42
|
-
? defaultGeometryStyle
|
|
43
|
-
: fullGeometryStyle;
|
|
44
|
-
if (!effFullGeometryStyle?.fill && !effFullGeometryStyle?.line) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const source = map.getSource(RESULT_SOURCE);
|
|
48
|
-
if (source) {
|
|
49
|
-
source.setData(savedData ?? featureCollection([]));
|
|
50
|
-
}
|
|
51
|
-
else if (savedData) {
|
|
52
|
-
map.addSource(RESULT_SOURCE, {
|
|
53
|
-
type: "geojson",
|
|
54
|
-
data: savedData,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (!map.getLayer(RESULT_LAYER_FILL) && effFullGeometryStyle?.fill) {
|
|
61
|
-
map.addLayer({
|
|
62
|
-
...effFullGeometryStyle?.fill,
|
|
63
|
-
id: RESULT_LAYER_FILL,
|
|
64
|
-
type: "fill",
|
|
65
|
-
source: RESULT_SOURCE,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
if (!map.getLayer(RESULT_LAYER_LINE) && effFullGeometryStyle?.line) {
|
|
69
|
-
map.addLayer({
|
|
70
|
-
...effFullGeometryStyle?.line,
|
|
71
|
-
id: RESULT_LAYER_LINE,
|
|
72
|
-
type: "line",
|
|
73
|
-
source: RESULT_SOURCE,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function setAndSaveData(data) {
|
|
78
|
-
savedData = data;
|
|
79
|
-
syncFullGeometryLayer();
|
|
80
|
-
}
|
|
81
|
-
map.on("styledata", () => {
|
|
82
|
-
// timeout prevents collision with svelte-maplibre library
|
|
83
|
-
setTimeout(() => {
|
|
84
|
-
if (savedData) {
|
|
85
|
-
syncFullGeometryLayer();
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
const handleMapClick = (e) => {
|
|
90
|
-
eventHandler?.({
|
|
91
|
-
type: "mapClick",
|
|
92
|
-
coordinates: [e.lngLat.lng, e.lngLat.lat],
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
function createMarker(interactive = false) {
|
|
96
|
-
if (!maplibregl) {
|
|
97
|
-
throw new Error();
|
|
98
|
-
}
|
|
99
|
-
const element = document.createElement("div");
|
|
100
|
-
if (interactive) {
|
|
101
|
-
element.classList.add("marker-interactive");
|
|
102
|
-
}
|
|
103
|
-
new MarkerIcon({
|
|
104
|
-
props: { displayIn: "maplibre" },
|
|
105
|
-
target: element,
|
|
106
|
-
});
|
|
107
|
-
return new maplibregl.Marker({ element, offset: [1, -13] });
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
setEventHandler(handler) {
|
|
111
|
-
if (handler) {
|
|
112
|
-
eventHandler = handler;
|
|
113
|
-
map.on("click", handleMapClick);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
eventHandler = undefined;
|
|
117
|
-
map.off("click", handleMapClick);
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
flyTo(center, zoom) {
|
|
121
|
-
map.flyTo({ center, ...(zoom ? { zoom } : {}), ...flyToOptions });
|
|
122
|
-
},
|
|
123
|
-
fitBounds(bbox, padding, maxZoom) {
|
|
124
|
-
map.fitBounds([
|
|
125
|
-
[bbox[0], bbox[1]],
|
|
126
|
-
[bbox[2], bbox[3]],
|
|
127
|
-
], { padding, ...(maxZoom ? { maxZoom } : {}), ...fitBoundsOptions });
|
|
128
|
-
},
|
|
129
|
-
indicateReverse(reverse) {
|
|
130
|
-
map.getCanvasContainer().style.cursor = reverse ? "crosshair" : "";
|
|
131
|
-
},
|
|
132
|
-
setReverseMarker(coordinates) {
|
|
133
|
-
if (!maplibregl || !marker) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (reverseMarker) {
|
|
137
|
-
if (!coordinates) {
|
|
138
|
-
reverseMarker.remove();
|
|
139
|
-
reverseMarker = undefined;
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
reverseMarker.setLngLat(coordinates);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else if (coordinates) {
|
|
146
|
-
if (marker instanceof Function) {
|
|
147
|
-
reverseMarker = marker(map) ?? undefined;
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
reverseMarker = (typeof marker === "object"
|
|
151
|
-
? new maplibregl.Marker(marker)
|
|
152
|
-
: createMarker())
|
|
153
|
-
.setLngLat(coordinates)
|
|
154
|
-
.addTo(map);
|
|
155
|
-
reverseMarker.getElement().classList.add("marker-reverse");
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
setFeatures(markedFeatures, picked, showPolygonMarker) {
|
|
160
|
-
for (const marker of markers) {
|
|
161
|
-
marker.remove();
|
|
162
|
-
}
|
|
163
|
-
markers.length = 0;
|
|
164
|
-
setAndSaveData(undefined);
|
|
165
|
-
if (!maplibregl) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
block: if (picked) {
|
|
169
|
-
let handled = false;
|
|
170
|
-
if (picked.geometry.type === "GeometryCollection") {
|
|
171
|
-
const geoms = picked.geometry.geometries.filter((geometry) => geometry.type === "Polygon" || geometry.type === "MultiPolygon");
|
|
172
|
-
ok: if (geoms.length > 0) {
|
|
173
|
-
const unioned = union(featureCollection(geoms.map((geom) => feature(geom))));
|
|
174
|
-
if (!unioned) {
|
|
175
|
-
break ok;
|
|
176
|
-
}
|
|
177
|
-
setMask({
|
|
178
|
-
...picked,
|
|
179
|
-
geometry: unioned.geometry,
|
|
180
|
-
}, setAndSaveData);
|
|
181
|
-
handled = true;
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
const geometries = picked.geometry.geometries.filter((geometry) => geometry.type === "LineString" ||
|
|
185
|
-
geometry.type === "MultiLineString");
|
|
186
|
-
if (geometries.length > 0) {
|
|
187
|
-
setAndSaveData({
|
|
188
|
-
...picked,
|
|
189
|
-
geometry: { type: "GeometryCollection", geometries },
|
|
190
|
-
});
|
|
191
|
-
handled = true;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (handled) {
|
|
196
|
-
// nothing
|
|
197
|
-
}
|
|
198
|
-
else if (picked.geometry.type === "Polygon" ||
|
|
199
|
-
picked.geometry.type === "MultiPolygon") {
|
|
200
|
-
setMask(picked, setAndSaveData);
|
|
201
|
-
}
|
|
202
|
-
else if (picked.geometry.type === "LineString" ||
|
|
203
|
-
picked.geometry.type === "MultiLineString") {
|
|
204
|
-
setAndSaveData(picked);
|
|
205
|
-
break block; // no pin for (multi)linestrings
|
|
206
|
-
}
|
|
207
|
-
if (!showPolygonMarker && !picked.geometry.type.endsWith("Point")) {
|
|
208
|
-
break block;
|
|
209
|
-
}
|
|
210
|
-
if (marker instanceof Function) {
|
|
211
|
-
const m = marker(map, picked);
|
|
212
|
-
if (m) {
|
|
213
|
-
markers.push(m);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
else if (marker) {
|
|
217
|
-
markers.push(typeof marker === "object"
|
|
218
|
-
? new maplibregl.Marker(marker)
|
|
219
|
-
: createMarker().setLngLat(picked.center).addTo(map));
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
if (showResultMarkers) {
|
|
223
|
-
for (const feature of markedFeatures ?? []) {
|
|
224
|
-
if (feature === picked) {
|
|
225
|
-
continue;
|
|
226
|
-
}
|
|
227
|
-
let marker;
|
|
228
|
-
if (showResultMarkers instanceof Function) {
|
|
229
|
-
marker = showResultMarkers(map, feature);
|
|
230
|
-
if (!marker) {
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
marker = (typeof showResultMarkers === "object"
|
|
236
|
-
? new maplibregl.Marker(showResultMarkers)
|
|
237
|
-
: createMarker(true))
|
|
238
|
-
.setLngLat(feature.center)
|
|
239
|
-
.setPopup(new maplibregl.Popup({
|
|
240
|
-
offset: [1, -27],
|
|
241
|
-
closeButton: false,
|
|
242
|
-
closeOnMove: true,
|
|
243
|
-
className: "maptiler-gc-popup",
|
|
244
|
-
}).setText(feature.place_type[0] === "reverse"
|
|
245
|
-
? feature.place_name
|
|
246
|
-
: feature.place_name.replace(/,.*/, "")))
|
|
247
|
-
.addTo(map);
|
|
248
|
-
}
|
|
249
|
-
const element = marker.getElement();
|
|
250
|
-
element.addEventListener("click", (e) => {
|
|
251
|
-
e.stopPropagation();
|
|
252
|
-
eventHandler?.({ type: "markerClick", id: feature.id });
|
|
253
|
-
});
|
|
254
|
-
element.addEventListener("mouseenter", () => {
|
|
255
|
-
eventHandler?.({ type: "markerMouseEnter", id: feature.id });
|
|
256
|
-
marker.togglePopup();
|
|
257
|
-
});
|
|
258
|
-
element.addEventListener("mouseleave", () => {
|
|
259
|
-
eventHandler?.({ type: "markerMouseLeave", id: feature.id });
|
|
260
|
-
marker.togglePopup();
|
|
261
|
-
});
|
|
262
|
-
// element.classList.toggle("marker-fuzzy", !!feature.matching_text);
|
|
263
|
-
markers.push(marker);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
setSelectedMarker(index) {
|
|
268
|
-
if (selectedMarker) {
|
|
269
|
-
selectedMarker.getElement().classList.toggle("marker-selected", false);
|
|
270
|
-
}
|
|
271
|
-
selectedMarker = index > -1 ? markers[index] : undefined;
|
|
272
|
-
selectedMarker?.getElement().classList.toggle("marker-selected", true);
|
|
273
|
-
},
|
|
274
|
-
getCenterAndZoom() {
|
|
275
|
-
const c = map.getCenter();
|
|
276
|
-
return [map.getZoom(), c.lng, c.lat];
|
|
277
|
-
},
|
|
278
|
-
};
|
|
279
|
-
}
|