mahal_map 1.0.3 → 1.0.4
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/dist/index.d.mts +101 -0
- package/dist/index.d.ts +100 -13
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/mahal_map.sdk.js +1 -0
- package/package.json +20 -10
- package/.vscode/settings.json +0 -3
- package/dist/app/config/constants.d.ts +0 -9
- package/dist/app/config/constants.d.ts.map +0 -1
- package/dist/app/config/geojson-polyline.d.ts +0 -3
- package/dist/app/config/geojson-polyline.d.ts.map +0 -1
- package/dist/app/config/geometry-polyline.d.ts +0 -3
- package/dist/app/config/geometry-polyline.d.ts.map +0 -1
- package/dist/app/config/index.d.ts +0 -4
- package/dist/app/config/index.d.ts.map +0 -1
- package/dist/app/lib/axios/api/axios.d.ts +0 -2
- package/dist/app/lib/axios/api/axios.d.ts.map +0 -1
- package/dist/app/lib/axios/api/index.d.ts +0 -2
- package/dist/app/lib/axios/api/index.d.ts.map +0 -1
- package/dist/app/lib/axios/index.d.ts +0 -2
- package/dist/app/lib/axios/index.d.ts.map +0 -1
- package/dist/app/lib/checking-coordinates/index.d.ts +0 -2
- package/dist/app/lib/checking-coordinates/index.d.ts.map +0 -1
- package/dist/app/lib/checking-coordinates/utils.d.ts +0 -5
- package/dist/app/lib/checking-coordinates/utils.d.ts.map +0 -1
- package/dist/app/lib/index.d.ts +0 -4
- package/dist/app/lib/index.d.ts.map +0 -1
- package/dist/app/lib/saveKey/index.d.ts +0 -2
- package/dist/app/lib/saveKey/index.d.ts.map +0 -1
- package/dist/app/lib/saveKey/utils.d.ts +0 -5
- package/dist/app/lib/saveKey/utils.d.ts.map +0 -1
- package/dist/app/types/additional-param/index.d.ts +0 -6
- package/dist/app/types/additional-param/index.d.ts.map +0 -1
- package/dist/app/types/index.d.ts +0 -5
- package/dist/app/types/index.d.ts.map +0 -1
- package/dist/app/types/map/index.d.ts +0 -10
- package/dist/app/types/map/index.d.ts.map +0 -1
- package/dist/app/types/router-param/index.d.ts +0 -33
- package/dist/app/types/router-param/index.d.ts.map +0 -1
- package/dist/app/types/search-param/index.d.ts +0 -13
- package/dist/app/types/search-param/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/map/utils.d.ts +0 -5
- package/dist/lib/map/utils.d.ts.map +0 -1
- package/dist/lib/routing/api.d.ts +0 -3
- package/dist/lib/routing/api.d.ts.map +0 -1
- package/dist/lib/routing/utils.d.ts +0 -4
- package/dist/lib/routing/utils.d.ts.map +0 -1
- package/dist/lib/search/api.d.ts +0 -3
- package/dist/lib/search/api.d.ts.map +0 -1
- package/dist/lib/search/utils.d.ts +0 -4
- package/dist/lib/search/utils.d.ts.map +0 -1
- package/dist/mahal_map.esm.js +0 -2
- package/dist/mahal_map.esm.js.map +0 -1
- package/dist/mahal_map.umd.js +0 -2
- package/dist/mahal_map.umd.js.map +0 -1
- package/index.html +0 -465
- package/rollup.config.js +0 -38
- package/src/app/config/constants.ts +0 -15
- package/src/app/config/geojson-polyline.ts +0 -47
- package/src/app/config/geometry-polyline.ts +0 -58
- package/src/app/config/index.ts +0 -3
- package/src/app/lib/axios/api/axios.ts +0 -17
- package/src/app/lib/axios/api/index.ts +0 -1
- package/src/app/lib/axios/index.ts +0 -1
- package/src/app/lib/checking-coordinates/index.ts +0 -1
- package/src/app/lib/checking-coordinates/utils.ts +0 -20
- package/src/app/lib/index.ts +0 -3
- package/src/app/lib/saveKey/index.ts +0 -1
- package/src/app/lib/saveKey/utils.ts +0 -18
- package/src/app/types/additional-param/index.ts +0 -6
- package/src/app/types/index.ts +0 -4
- package/src/app/types/map/index.ts +0 -10
- package/src/app/types/router-param/index.ts +0 -33
- package/src/app/types/search-param/index.ts +0 -13
- package/src/index.d.ts +0 -21
- package/src/index.ts +0 -26
- package/src/lib/map/utils.ts +0 -35
- package/src/lib/routing/api.ts +0 -17
- package/src/lib/routing/utils.ts +0 -37
- package/src/lib/search/api.ts +0 -13
- package/src/lib/search/utils.ts +0 -40
- package/tsconfig.json +0 -23
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { api } from "@app/lib";
|
|
2
|
-
|
|
3
|
-
let apiKey: string = "";
|
|
4
|
-
|
|
5
|
-
function saveKey(param: string) {
|
|
6
|
-
if (param === "") return;
|
|
7
|
-
apiKey = param;
|
|
8
|
-
api.defaults.headers.common["Authorization"] = `Bearer ${param}`;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function clearKey() {
|
|
12
|
-
apiKey = "";
|
|
13
|
-
api.defaults.headers.common["Authorization"] = "";
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const getApiKey = () => apiKey;
|
|
17
|
-
|
|
18
|
-
export { saveKey, clearKey, getApiKey };
|
package/src/app/types/index.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
interface IRoute {
|
|
2
|
-
id: number;
|
|
3
|
-
type: string;
|
|
4
|
-
name: string;
|
|
5
|
-
icon: string;
|
|
6
|
-
success: boolean;
|
|
7
|
-
coords: string;
|
|
8
|
-
route?: {
|
|
9
|
-
code: string;
|
|
10
|
-
routes: {
|
|
11
|
-
geometry: string | number[][];
|
|
12
|
-
legs: {
|
|
13
|
-
steps: [];
|
|
14
|
-
summary: string;
|
|
15
|
-
weight: number;
|
|
16
|
-
duration: number;
|
|
17
|
-
distance: number;
|
|
18
|
-
}[];
|
|
19
|
-
weight_name: string;
|
|
20
|
-
distance: number;
|
|
21
|
-
duration: number;
|
|
22
|
-
weight: number;
|
|
23
|
-
}[];
|
|
24
|
-
waypoints: {
|
|
25
|
-
hint: string;
|
|
26
|
-
distance: any;
|
|
27
|
-
name: string;
|
|
28
|
-
location: number[];
|
|
29
|
-
}[];
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type { IRoute };
|
package/src/index.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export * from "./app/types/map";
|
|
2
|
-
export * from "./app/types/search-param";
|
|
3
|
-
export * from "./app/types/additional-param";
|
|
4
|
-
export * from "./app/types/router-param";
|
|
5
|
-
|
|
6
|
-
import * as Map from "../src/lib/map/utils";
|
|
7
|
-
import * as keyUtils from "./app/lib/saveKey";
|
|
8
|
-
import * as searchUtils from "./lib/search/utils";
|
|
9
|
-
import * as routerUtils from "./lib/routing/utils";
|
|
10
|
-
|
|
11
|
-
export { Map, keyUtils, searchUtils, routerUtils };
|
|
12
|
-
|
|
13
|
-
declare const MahalMap: {
|
|
14
|
-
Map: typeof Map;
|
|
15
|
-
keyUtils: typeof keyUtils;
|
|
16
|
-
searchUtils: typeof searchUtils;
|
|
17
|
-
routerUtils: typeof routerUtils;
|
|
18
|
-
loadKeyFromScriptUrl: () => string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default MahalMap;
|
package/src/index.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as Map from "@lib/map/utils";
|
|
2
|
-
import * as keyUtils from "@app/lib/saveKey";
|
|
3
|
-
import * as searchUtils from "@lib/search/utils";
|
|
4
|
-
import * as routerUtils from "@lib/routing/utils";
|
|
5
|
-
|
|
6
|
-
export { Map, keyUtils, searchUtils, routerUtils };
|
|
7
|
-
|
|
8
|
-
const MahalMap = {
|
|
9
|
-
Map,
|
|
10
|
-
keyUtils,
|
|
11
|
-
searchUtils,
|
|
12
|
-
routerUtils,
|
|
13
|
-
loadKeyFromScriptUrl: () => {
|
|
14
|
-
const scripts = document.getElementsByTagName("script");
|
|
15
|
-
for (const script of scripts) {
|
|
16
|
-
if (script.src.includes("mahal_map.umd.js")) {
|
|
17
|
-
const url = new URL(script.src);
|
|
18
|
-
const apikey = url.searchParams.get("apikey");
|
|
19
|
-
if (apikey) return apikey;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return "";
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default MahalMap;
|
package/src/lib/map/utils.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Map as MapType } from "maplibre-gl";
|
|
2
|
-
import type { IMahalMapOptions } from "@app/types";
|
|
3
|
-
import { DARK, LIGHT, VECTOR } from "@app/config";
|
|
4
|
-
import maplibregl from "maplibre-gl";
|
|
5
|
-
|
|
6
|
-
const defaultStyles = { dark: DARK, light: LIGHT };
|
|
7
|
-
|
|
8
|
-
function createMap(options: IMahalMapOptions): MapType {
|
|
9
|
-
let finalStyle;
|
|
10
|
-
|
|
11
|
-
if (options.autoAddVectorSource) {
|
|
12
|
-
finalStyle = VECTOR;
|
|
13
|
-
} else {
|
|
14
|
-
finalStyle = options.style
|
|
15
|
-
? options.style
|
|
16
|
-
: options.theme === "dark"
|
|
17
|
-
? defaultStyles.dark
|
|
18
|
-
: defaultStyles.light;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const map: MapType = new maplibregl.Map({
|
|
22
|
-
container: options.container || "map",
|
|
23
|
-
style: finalStyle as string,
|
|
24
|
-
center: options.center || [69.624024, 40.279687],
|
|
25
|
-
zoom: options.zoom || 5,
|
|
26
|
-
});
|
|
27
|
-
const compactEl = document.getElementsByClassName(
|
|
28
|
-
"maplibregl-compact-show"
|
|
29
|
-
)[0] as HTMLElement;
|
|
30
|
-
if (compactEl) compactEl.style.display = "none";
|
|
31
|
-
|
|
32
|
-
return map;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { createMap };
|
package/src/lib/routing/api.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { api } from "@app/lib";
|
|
2
|
-
|
|
3
|
-
const routingApi = async (param: number[][]) => {
|
|
4
|
-
try {
|
|
5
|
-
const points: { lng: number; lat: number }[] = [];
|
|
6
|
-
param.forEach((e) => {
|
|
7
|
-
points.push({ lng: e[0], lat: e[1] });
|
|
8
|
-
});
|
|
9
|
-
const response = await api.post("services/getRoutes", { points });
|
|
10
|
-
return response.data;
|
|
11
|
-
} catch (err) {
|
|
12
|
-
console.error(err);
|
|
13
|
-
throw err;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export { routingApi };
|
package/src/lib/routing/utils.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { routingApi } from "@lib/routing/api";
|
|
2
|
-
import { geojsonPolyline } from "@app/config/index";
|
|
3
|
-
import type { IRoute } from "@app/types/index";
|
|
4
|
-
|
|
5
|
-
async function getrouter(
|
|
6
|
-
param: number[][],
|
|
7
|
-
typeData: string
|
|
8
|
-
): Promise<IRoute[]> {
|
|
9
|
-
try {
|
|
10
|
-
const res = await routingApi(param);
|
|
11
|
-
|
|
12
|
-
if (!res?.data) return res;
|
|
13
|
-
|
|
14
|
-
const data: IRoute[] = res.data;
|
|
15
|
-
|
|
16
|
-
return data.map((route) => {
|
|
17
|
-
const updated = { ...route };
|
|
18
|
-
|
|
19
|
-
if (updated.route?.routes?.length) {
|
|
20
|
-
updated.route.routes = updated.route.routes.map((r) => ({
|
|
21
|
-
...r,
|
|
22
|
-
geometry:
|
|
23
|
-
typeData === "geojson" && typeof r.geometry === "string"
|
|
24
|
-
? geojsonPolyline(r.geometry)
|
|
25
|
-
: r.geometry,
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return updated as IRoute;
|
|
30
|
-
});
|
|
31
|
-
} catch (error) {
|
|
32
|
-
console.error(error);
|
|
33
|
-
throw error;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { getrouter };
|
package/src/lib/search/api.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { api } from "@app/lib";
|
|
2
|
-
import type { ISearchParam } from "@app/types";
|
|
3
|
-
|
|
4
|
-
export const searchPost = async (param: ISearchParam) => {
|
|
5
|
-
try {
|
|
6
|
-
const params = { params: param };
|
|
7
|
-
const response = await api.get("elastic/search", params);
|
|
8
|
-
return response.data;
|
|
9
|
-
} catch (error) {
|
|
10
|
-
console.error("Ошибка при поиске адреса:", error);
|
|
11
|
-
throw error;
|
|
12
|
-
}
|
|
13
|
-
};
|
package/src/lib/search/utils.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { searchPost } from "./api";
|
|
2
|
-
import { IAdditionalParamType } from "@app/types/index";
|
|
3
|
-
import { checkCoordinates } from "@app/lib/index";
|
|
4
|
-
import { REGEX } from "@app/config";
|
|
5
|
-
|
|
6
|
-
async function search(
|
|
7
|
-
param: string,
|
|
8
|
-
additionalParam?: IAdditionalParamType
|
|
9
|
-
): Promise<any> {
|
|
10
|
-
let searchData: any = {
|
|
11
|
-
text: "",
|
|
12
|
-
...additionalParam,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
if (param !== "") {
|
|
16
|
-
if (REGEX.test(param)) {
|
|
17
|
-
let coordinates = await checkCoordinates(param);
|
|
18
|
-
if (coordinates) {
|
|
19
|
-
searchData = {
|
|
20
|
-
lat: coordinates.lat ?? "",
|
|
21
|
-
lng: coordinates.lng ?? "",
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
} else {
|
|
25
|
-
searchData.text = param;
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
searchData.text = "";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const res = await searchPost(searchData);
|
|
33
|
-
return res;
|
|
34
|
-
} catch (error) {
|
|
35
|
-
console.error("Ошибка при выполнении поиска:", error);
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export { search };
|
package/tsconfig.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"outDir": "dist",
|
|
4
|
-
"rootDir": "src",
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"target": "ES2020",
|
|
7
|
-
"moduleResolution": "bundler",
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"declaration": true,
|
|
10
|
-
"declarationMap": true,
|
|
11
|
-
"strict": true,
|
|
12
|
-
"sourceMap": true,
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"emitDeclarationOnly": true,
|
|
15
|
-
"forceConsistentCasingInFileNames": true,
|
|
16
|
-
"allowSyntheticDefaultImports": true,
|
|
17
|
-
"paths": {
|
|
18
|
-
"@app/*": ["./src/app/*"],
|
|
19
|
-
"@lib/*": ["./src/lib/*"]
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"include": ["src/**/*.ts"]
|
|
23
|
-
}
|