Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #9

Merged
merged 19 commits into from
Feb 4, 2025
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
✅ Tested for map.apps 4.18.3 / Linie 4
✅ Tested for map.apps 4.19.0 / Linie 4

#### Release Notes
- autogenerated SNAPSHOT-Release
28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "mapapps-what3words",
"name": "mapapps-4-developers",
"description": "test build",
"version": "0.0.1",
"license": "CC0-1.0",
Expand All @@ -9,28 +9,30 @@
"watch-types": "tsc -w --noEmit"
},
"devDependencies": {
"@conterra/ct-mapapps-typings": "~4.18.3",
"@conterra/ct-mapapps-typings": "~4.19.0",
"@conterra/mapapps-mocha-runner": "1.1.1",
"@conterra/reactivity-core": "^0.4.0",
"@conterra/reactivity-core": "^0.4.4",
"@types/chai": "4.3.10",
"@types/license-checker": "^25.0.6",
"@types/mocha": "10.0.4",
"arcgis-js-api": "4.29.10",
"chai": "4.3.10",
"ct-mapapps-browser-sync": "0.0.41",
"ct-mapapps-gulp-js": "0.10.3",
"@types/mocha": "10.0.10",
"@types/sinon": "^17.0.3",
"arcgis-js-api": "4.31.6",
"chai": "4.5.0",
"ct-mapapps-browser-sync": "0.0.42",
"ct-mapapps-gulp-js": "0.10.8",
"eslint-config-ct-prodeng": "1.4.0",
"license-checker": "25.0.1",
"mocha": "10.2.0",
"puppeteer": "21.5.2",
"mocha": "11.0.1",
"puppeteer": "23.11.1",
"sinon": "19.0.2",
"stylelint": "15.11.0",
"stylelint-config-ct-prodeng": "2.0.0",
"stylelint-config-recommended": "13.0.0",
"stylelint-config-recommended-less": "2.0.0",
"ts-node": "^10.9.1",
"tsx": "^4.6.0",
"tsx": "^4.19.2",
"typescript": "5.4.5",
"vue": "2.7.15",
"vue-template-compiler": "2.7.15"
"vue": "2.7.16",
"vue-template-compiler": "2.7.16"
}
}
9 changes: 4 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<plugin>
<groupId>de.conterra.maven</groupId>
<artifactId>setproperties-maven-plugin</artifactId>
<version>1.0.2</version>
<version>1.0.5</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down Expand Up @@ -476,8 +476,7 @@
</build>
<scm>
<connection>scm:git:https://github.com/conterra/mapapps-mapapps-what3words.git</connection>
<developerConnection>scm:git:https://github.com/conterra/mapapps-what3words.git
</developerConnection>
<developerConnection>scm:git:https://github.com/conterra/mapapps-what3words.git</developerConnection>
<url>https://github.com/conterra/mapapps-what3words</url>
<tag>HEAD</tag>
</scm>
Expand All @@ -496,12 +495,12 @@
<root.build.outputPath>${project.build.directory}/webapp</root.build.outputPath>
<js.build.outputPath>${root.build.outputPath}/js</js.build.outputPath>

<mapapps.version>4.18.3</mapapps.version>
<mapapps.version>4.19.0</mapapps.version>
<!-- JS lib versions -->
<apprt.version>${mapapps.version}</apprt.version>

<!-- java lib versions -->
<ct.jsregistry.version>2.1.3</ct.jsregistry.version>
<ct.jsregistry.version>2.1.4</ct.jsregistry.version>

<!-- the default app, replaced in the *.html files to switch app names-->
<default.app.name>sample</default.app.name>
Expand Down
32 changes: 21 additions & 11 deletions src/main/js/apps/sample/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,32 @@
"bundles"
],
"allowedBundles": [
"system@^4.6.2",
"splashscreen@^4.6.2",
"templatelayout@^4.6.2",
"template-seasons@^4.6.2",
"theme-autumn@^4.6.2",
"toolset@^4.6.2",
"map-init@^4.6.2",
"omnisearch@^4.6.2",
"banner@^4.6.2",
"system",
"splashscreen",
"templatelayout",
"template-seasons",
"theme-autumn",
"toolset",
"map-init",
"search-ui",
"banner",
"basemapswitcher",
"locator-store",
"dn_welcome",
"dn_what3words"
]
},
"bundles": {
"search-ui": {
"Config": {
"actions": [
"what3words-open-popup",
"zoomto",
"openpopup"
],
"zoomto-point-scale": 1000
}
},
"banner": {
"BannerWidget": {
"label": "Developer Network",
Expand Down Expand Up @@ -110,9 +120,9 @@
"ToolsetManager": {
"toolsets": [
{
"id": "popup",
"id": "what3wordstoolset",
"tools": [
"popupToggleTool"
"what3wordstool"
],
"container": "map",
"windowType": "fixed",
Expand Down
125 changes: 0 additions & 125 deletions src/main/js/bundles/dn_what3words/MapClickPopupHandler.js

This file was deleted.

104 changes: 104 additions & 0 deletions src/main/js/bundles/dn_what3words/MapClickPopupHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
///
/// Copyright (C) 2023 con terra GmbH ([email protected])
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///

import apprt_request from "apprt-request";
import Locale from "apprt-core/Locale";
import Graphic from "esri/Graphic";

import type { InjectedReference } from "apprt-core/InjectedReference";
import type { Messages } from "./nls/bundle";
import type { I18N } from "apprt/api";

export class MapClickPopupHandler {
private _i18n: InjectedReference<I18N<Messages>>;
private _clickHandle?: IHandle;
private _mapWidgetModel: InjectedReference<any>;
private _what3WordsModel: InjectedReference<any>;

public activateTool(): void {
const i18n = this._i18n!.get().ui;
this.getView().then((view) => {
this.addClickHandler(view, i18n);
});
}

public deactivateTool(): void {
if (this._clickHandle) {
this._clickHandle.remove();
this._clickHandle = undefined;
}

this.getView().then((view) => {
view.popup.close();
});
}

private addClickHandler(view: __esri.View, i18n: Messages["ui"]) {
const w3wModel = this._what3WordsModel;
const key = w3wModel.apiKey;
const coordsUrl = w3wModel.what3wordsUrl;

this._clickHandle = view.on("click", (event: { mapPoint: __esri.Point }) => {
if (key === "") {
console.warn(i18n.missingApiKeyWarning);
return;
}

const currentLang = Locale.getCurrent().getLocaleString();
const latitude = event.mapPoint.latitude;
const longitude = event.mapPoint.longitude;
const queryParams = { key, coordinates: `${latitude},${longitude}`, language: currentLang };

apprt_request(coordsUrl, { query: queryParams }).then(
(response) => {
view.popup.open({
features: [
new Graphic({
geometry: event.mapPoint,
attributes: {
words: response.words,
roundedLatitude: Math.round(latitude * 1000) / 1000,
roundedLongitude: Math.round(longitude * 1000) / 1000
},
popupTemplate: {
title: "///{words}",
customActions: ["popup-action-copy-what3words"],
content: `${i18n.popup.coordinatePrefix}: [{roundedLatitude}, {roundedLongitude}]`
} as __esri.PopupTemplate & { customActions: string[] }
})
]
});
}
).catch((e) => {
console.warn(`${i18n.popup.geocodingErrorPrefix}: ${e?.response?.data?.error?.message}`);
});
});
}

private getView(): Promise<__esri.MapView | __esri.SceneView> {
const mapWidgetModel = this._mapWidgetModel;
return new Promise((resolve) => {
if (mapWidgetModel.view) {
resolve(mapWidgetModel.view);
} else {
const watcher = mapWidgetModel.watch("view", ({ value: view }: { value: __esri.MapView | __esri.SceneView }) => {
watcher.remove();
resolve(view);
});
}
});
}
}
Loading
Loading