yio-map 0.15.2 → 0.16.0
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/README.md +2 -2
- package/dist/YioMap.d.ts.map +1 -1
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/controls/UserPinInteraction.d.ts +5 -1
- package/dist/controls/UserPinInteraction.d.ts.map +1 -1
- package/dist/yio-map.iife.js +6 -10
- package/dist/yio-map.js +41 -11
- package/dist/yio-map.umd.cjs +6 -10
- package/package.json +1 -1
package/dist/yio-map.js
CHANGED
|
@@ -859,11 +859,29 @@ var defaultStyles = [new Style({
|
|
|
859
859
|
fill,
|
|
860
860
|
stroke
|
|
861
861
|
})];
|
|
862
|
-
var
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
862
|
+
var PIN_PATH = "M11.906 1.994a8.002 8.002 0 0 1 8.09 8.421 7.996 7.996 0 0 1-1.297 3.957.996.996 0 0 1-.133.204l-.108.129c-.178.243-.37.477-.573.699l-5.112 6.224a1 1 0 0 1-1.545 0L5.982 15.26l-.002-.002a18.146 18.146 0 0 1-.309-.38l-.133-.163a.999.999 0 0 1-.13-.202 7.995 7.995 0 0 1 6.498-12.518ZM15 9.997a3 3 0 1 1-5.999 0 3 3 0 0 1 5.999 0Z";
|
|
863
|
+
/** Fill of the pin on a plain point (empty map, or content features that aren't selectable) */
|
|
864
|
+
var PIN_COLOR = "#dc4b6f";
|
|
865
|
+
/** Fill of the pin on a selectable feature: the blue of the lot highlight outline, so it reads as "selected" */
|
|
866
|
+
var PIN_COLOR_SELECTABLE = "#1D4ED8";
|
|
867
|
+
/**
|
|
868
|
+
* A map pin icon with a thin white outline, so it stays visible on dark maps (orthophoto) and on symbols of a
|
|
869
|
+
* similar color.
|
|
870
|
+
* @param {string} color
|
|
871
|
+
* @returns {Style}
|
|
872
|
+
*/
|
|
873
|
+
function createPinStyle(color) {
|
|
874
|
+
const svg = `<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill-rule="evenodd" clip-rule="evenodd" fill="${color}" stroke="#ffffff" stroke-width="1.25" stroke-linejoin="round" paint-order="stroke" d="${PIN_PATH}"/></svg>`;
|
|
875
|
+
return new Style({ image: new Icon({
|
|
876
|
+
opacity: 1,
|
|
877
|
+
src: "data:image/svg+xml;utf8," + encodeURIComponent(svg),
|
|
878
|
+
anchor: [.5, 1]
|
|
879
|
+
}) });
|
|
880
|
+
}
|
|
881
|
+
/** The pin on a plain point */
|
|
882
|
+
var pinStyle = createPinStyle(PIN_COLOR);
|
|
883
|
+
/** The pin on a selectable feature (with `enableSelect`) */
|
|
884
|
+
var pinSelectableStyle = createPinStyle(PIN_COLOR_SELECTABLE);
|
|
867
885
|
// src/controls/UserEditInteraction.js
|
|
868
886
|
/**
|
|
869
887
|
* @typedef {Object} Options
|
|
@@ -1166,31 +1184,42 @@ var UserPinInteraction = class extends Interaction {
|
|
|
1166
1184
|
}
|
|
1167
1185
|
/**
|
|
1168
1186
|
* @param {Array<number>} coordinate - coordinate in EPSG:3857
|
|
1187
|
+
* @param {boolean} [selectable] - whether the pin marks a selectable feature
|
|
1169
1188
|
*/
|
|
1170
|
-
#placePin(coordinate) {
|
|
1189
|
+
#placePin(coordinate, selectable = false) {
|
|
1171
1190
|
const source = this.#layer.getSource();
|
|
1172
1191
|
source.clear();
|
|
1173
1192
|
const feature = new Feature(new Point(coordinate));
|
|
1174
|
-
feature.setStyle(pinStyle);
|
|
1193
|
+
feature.setStyle(selectable ? pinSelectableStyle : pinStyle);
|
|
1175
1194
|
source.addFeature(feature);
|
|
1176
1195
|
this.#yioMap.dispatchEvent(new CustomEvent("pin", {
|
|
1177
1196
|
composed: true,
|
|
1178
1197
|
bubbles: true,
|
|
1179
|
-
detail: {
|
|
1198
|
+
detail: {
|
|
1199
|
+
coordinate: toLonLat(coordinate),
|
|
1200
|
+
selectable
|
|
1201
|
+
}
|
|
1180
1202
|
}));
|
|
1181
1203
|
}
|
|
1182
1204
|
/**
|
|
1183
1205
|
* @param {import('ol').MapBrowserEvent} event
|
|
1184
1206
|
*/
|
|
1185
1207
|
#handleClick(event) {
|
|
1186
|
-
this.#
|
|
1208
|
+
const selectable = !!this.#yioMap.enableSelect && getSelectableFeaturesAtPixel(this.getMap(), this.#yioMap._getContentLayer(), event.pixel).length > 0;
|
|
1209
|
+
this.#placePin(event.coordinate, selectable);
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Show the pin as a plain point, e.g. when the selection is switched off. The pin stays where it is.
|
|
1213
|
+
*/
|
|
1214
|
+
resetSelectable() {
|
|
1215
|
+
for (const feature of this.#layer.getSource().getFeatures()) feature.setStyle(pinStyle);
|
|
1187
1216
|
}
|
|
1188
1217
|
setActive(active) {
|
|
1189
1218
|
if (!active) this.#layer.getSource().clear();
|
|
1190
1219
|
super.setActive(active);
|
|
1191
1220
|
}
|
|
1192
1221
|
/**
|
|
1193
|
-
* Set the pin to a specific location.
|
|
1222
|
+
* Set the pin to a specific location, as a plain point.
|
|
1194
1223
|
* @param {Array<number>} coordinate - coordinate in EPSG:3857
|
|
1195
1224
|
*/
|
|
1196
1225
|
setPin(coordinate) {
|
|
@@ -1216,7 +1245,7 @@ var package_default = {
|
|
|
1216
1245
|
"type": "git",
|
|
1217
1246
|
"url": "https://github.com/yiogmbh/yio-map"
|
|
1218
1247
|
},
|
|
1219
|
-
version: "0.
|
|
1248
|
+
version: "0.16.0",
|
|
1220
1249
|
type: "module",
|
|
1221
1250
|
files: ["dist"],
|
|
1222
1251
|
exports: { ".": {
|
|
@@ -1835,6 +1864,7 @@ var YioMap = class extends i {
|
|
|
1835
1864
|
set enableSelect(value) {
|
|
1836
1865
|
this.#enableUserSelect = value;
|
|
1837
1866
|
this.#userSelectInteraction.setActive(!!this.#enableUserSelect);
|
|
1867
|
+
if (!this.#enableUserSelect) this.#userPinInteraction.resetSelectable();
|
|
1838
1868
|
}
|
|
1839
1869
|
get enablePinning() {
|
|
1840
1870
|
return this.#enablePinning;
|