map-ol-utils 0.0.1

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.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var A=Object.create;var i=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var F=(e,r)=>{for(var o in r)i(e,o,{get:r[o],enumerable:!0})},y=(e,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of D(r))!S.call(e,n)&&n!==o&&i(e,n,{get:()=>r[n],enumerable:!(a=E(r,n))||a.enumerable});return e};var s=(e,r,o)=>(o=e!=null?A(N(e)):{},y(r||!e||!e.__esModule?i(o,"default",{value:e,enumerable:!0}):o,e)),M=e=>y(i({},"__esModule",{value:!0}),e);var I={};F(I,{createBaseLayer:()=>c,createMapInstance:()=>u,disposeMap:()=>d,emitter:()=>p,getMapInstance:()=>f,resetMap:()=>z});module.exports=M(I);var m=s(require("mitt"),1),G=(0,m.default)(),p=G;var w=require("ol/source"),B=require("ol/layer"),k=require("ol/source");var g=s(require("ol/Map"),1),l=s(require("ol/View"),1),h=require("ol/control");var t,u=(e={})=>{let r=Object.assign({zoom:9,maxZoom:18,minZoom:9,baseLayer:"vec-layer",projection:"EPSG:4326",center:[119.72,30.12],layers:[c()],tk:"c77eddc667c5bed016fded560baf93e7"},e||{});return t||(t=new g.default({layers:[c()],view:new l.default(r),controls:(0,h.defaults)({attribution:!1,zoom:!1,rotate:!1})}),t.activeBaseLayer=r.baseLayer,t.getLayerByName=x,t.removeLayerByName=v,t.changeLayersByNames=L,t.on("pointermove",o=>{t.getTargetElement().style.cursor=t.hasFeatureAtPixel(o.pixel)?"pointer":""}),t)},f=()=>{},z=()=>{},d=()=>{};var C=require("ol/tilegrid"),b=require("ol/format"),T=s(require("ol/layer/Vector"),1),P=s(require("ol/source/Vector"),1),_=s(require("ol/tilegrid/WMTS"),1),c=(e=!0)=>new B.Tile({minZoom:8,maxZoom:21,source:new w.XYZ({tileGrid:new C.TileGrid({tileSize:256,resolutions:[.005493214,.002746607,.001373303,686652e-9,343326e-9,171663e-9,85831e-9,42916e-9,21458e-9,10729e-9,5364e-9,2682e-9,1341e-9],origin:[118.122911693886,31.2869311022836],extent:[116.43263049006,28.6201742126026,123.705594256347,31.9765041681924]}),projection:"EPSG:4326",urls:e?["https://ywtg.citybrain.hangzhou.gov.cn/hzsyvector_dark/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9456/hzsyvector_dark/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9457/hzsyvector_dark/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9458/hzsyvector_dark/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9459/hzsyvector_dark/{z}/{y}/{x}","https://cb.hangzhoumap.gov.cn/E36CCEA93443D1495DB9B9F2B2FFE348CB1A367D75176F815040AB19E54CDCA5DAAA25813AF965E2ABD0CC2463DD1223/PBS/rest/services/hzsyvector_dark/Mapserver/tile/{z}/{y}/{x}"]:["https://ywtg.citybrain.hangzhou.gov.cn/hzsyvector/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9456/hzsyvector/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9457/hzsyvector/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9458/hzsyvector/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9459/hzsyvector/{z}/{y}/{x}","https://cb.hangzhoumap.gov.cn/E36CCEA93443D1495DB9B9F2B2FFE348CB1A367D75176F815040AB19E54CDCA5DAAA25813AF965E2ABD0CC2463DD1223/PBS/rest/services/hzsyvector/Mapserver/tile/{z}/{y}/{x}"]})});var x=e=>t.getAllLayers().find(r=>r.getClassName()===e),v=e=>{let r=t.getAllLayers().find(o=>o.getClassName()===e);r&&t.removeLayer(r)},L=(e,r)=>{t.getAllLayers().filter(a=>r.includes(a.getClassName())).forEach(a=>{a.setVisible(e==null?void 0:e.includes(a.getClassName()))})};0&&(module.exports={createBaseLayer,createMapInstance,disposeMap,emitter,getMapInstance,resetMap});
@@ -0,0 +1,50 @@
1
+ import { Map } from 'ol';
2
+ import { Layer, Tile } from 'ol/layer';
3
+ import { Source, XYZ } from 'ol/source';
4
+ import { Emitter, EventType } from 'mitt';
5
+ import { CustomMap as CustomMap$1 } from 'map-venus/src';
6
+
7
+ interface CustomMap extends Map {
8
+ activeBaseLayer?: string;
9
+ changeBaseLayer?: () => void;
10
+ removeLayerByName?: (name: string) => void;
11
+ getLayerByName?: (name: string) => Layer<Source> | undefined;
12
+ changeLayersByNames?: (activeNames: Array<string>, allLayerNames: Array<string>) => void;
13
+ }
14
+ type LayerConfig = {
15
+ zIndex?: number;
16
+ visible?: boolean;
17
+ minZoom?: number;
18
+ maxZoom?: number;
19
+ layerName: string;
20
+ };
21
+ type DataItemConfig = {
22
+ lng: string | number;
23
+ lat: string | number;
24
+ img: string | undefined;
25
+ activeImg?: string | undefined;
26
+ text?: string;
27
+ offsetX?: number;
28
+ offsetY?: number;
29
+ scale?: number;
30
+ showText?: boolean;
31
+ anchor?: Array<number>;
32
+ rawData?: any;
33
+ rotation?: number;
34
+ };
35
+ type GeoData = {
36
+ id: string;
37
+ geom: string;
38
+ props: string;
39
+ };
40
+
41
+ declare const emitter: Emitter<Record<EventType, any>>;
42
+
43
+ declare const createBaseLayer: (isDark?: boolean) => Tile<XYZ>;
44
+
45
+ declare const createMapInstance: (config?: {}) => CustomMap$1;
46
+ declare const getMapInstance: () => void;
47
+ declare const resetMap: () => void;
48
+ declare const disposeMap: () => void;
49
+
50
+ export { type CustomMap, type DataItemConfig, type GeoData, type LayerConfig, createBaseLayer, createMapInstance, disposeMap, emitter, getMapInstance, resetMap };
@@ -0,0 +1,62 @@
1
+ import {Map} from 'ol';
2
+ import {Layer, Tile} from 'ol/layer';
3
+ import {Source, XYZ} from 'ol/source';
4
+ import {Emitter, EventType} from 'mitt';
5
+ import {CustomMap as CustomMap$1} from 'map-venus/src';
6
+
7
+ interface CustomMap extends Map {
8
+ activeBaseLayer?: string;
9
+ changeBaseLayer?: () => void;
10
+ removeLayerByName?: (name: string) => void;
11
+ getLayerByName?: (name: string) => Layer<Source> | undefined;
12
+ changeLayersByNames?: (activeNames: Array<string>, allLayerNames: Array<string>) => void;
13
+ }
14
+
15
+ type LayerConfig = {
16
+ zIndex?: number;
17
+ visible?: boolean;
18
+ minZoom?: number;
19
+ maxZoom?: number;
20
+ layerName: string;
21
+ };
22
+ type DataItemConfig = {
23
+ lng: string | number;
24
+ lat: string | number;
25
+ img: string | undefined;
26
+ activeImg?: string | undefined;
27
+ text?: string;
28
+ offsetX?: number;
29
+ offsetY?: number;
30
+ scale?: number;
31
+ showText?: boolean;
32
+ anchor?: Array<number>;
33
+ rawData?: any;
34
+ rotation?: number;
35
+ };
36
+ type GeoData = {
37
+ id: string;
38
+ geom: string;
39
+ props: string;
40
+ };
41
+
42
+ declare const emitter: Emitter<Record<EventType, any>>;
43
+
44
+ declare const createBaseLayer: (isDark?: boolean) => Tile<XYZ>;
45
+
46
+ declare const createMapInstance: (config?: {}) => CustomMap$1;
47
+ declare const getMapInstance: () => void;
48
+ declare const resetMap: () => void;
49
+ declare const disposeMap: () => void;
50
+
51
+ export {
52
+ type CustomMap,
53
+ type DataItemConfig,
54
+ type GeoData,
55
+ type LayerConfig,
56
+ createBaseLayer,
57
+ createMapInstance,
58
+ disposeMap,
59
+ emitter,
60
+ getMapInstance,
61
+ resetMap
62
+ };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import y from"mitt";var m=y(),p=m;import{XYZ as x}from"ol/source";import{Tile as v}from"ol/layer";import{WMTS as T}from"ol/source";import g from"ol/Map";import l from"ol/View";import{defaults as h}from"ol/control";var e,u=(r={})=>{let t=Object.assign({zoom:9,maxZoom:18,minZoom:9,baseLayer:"vec-layer",projection:"EPSG:4326",center:[119.72,30.12],layers:[s()],tk:"c77eddc667c5bed016fded560baf93e7"},r||{});return e||(e=new g({layers:[s()],view:new l(t),controls:h({attribution:!1,zoom:!1,rotate:!1})}),e.activeBaseLayer=t.baseLayer,e.getLayerByName=n,e.removeLayerByName=c,e.changeLayersByNames=i,e.on("pointermove",o=>{e.getTargetElement().style.cursor=e.hasFeatureAtPixel(o.pixel)?"pointer":""}),e)},f=()=>{},z=()=>{},d=()=>{};import{TileGrid as L}from"ol/tilegrid";import{GeoJSON as J,WKB as O}from"ol/format";import Z from"ol/layer/Vector";import V from"ol/source/Vector";import $ from"ol/tilegrid/WMTS";var s=(r=!0)=>new v({minZoom:8,maxZoom:21,source:new x({tileGrid:new L({tileSize:256,resolutions:[.005493214,.002746607,.001373303,686652e-9,343326e-9,171663e-9,85831e-9,42916e-9,21458e-9,10729e-9,5364e-9,2682e-9,1341e-9],origin:[118.122911693886,31.2869311022836],extent:[116.43263049006,28.6201742126026,123.705594256347,31.9765041681924]}),projection:"EPSG:4326",urls:r?["https://ywtg.citybrain.hangzhou.gov.cn/hzsyvector_dark/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9456/hzsyvector_dark/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9457/hzsyvector_dark/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9458/hzsyvector_dark/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9459/hzsyvector_dark/{z}/{y}/{x}","https://cb.hangzhoumap.gov.cn/E36CCEA93443D1495DB9B9F2B2FFE348CB1A367D75176F815040AB19E54CDCA5DAAA25813AF965E2ABD0CC2463DD1223/PBS/rest/services/hzsyvector_dark/Mapserver/tile/{z}/{y}/{x}"]:["https://ywtg.citybrain.hangzhou.gov.cn/hzsyvector/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9456/hzsyvector/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9457/hzsyvector/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9458/hzsyvector/{z}/{y}/{x}","https://ywtg.citybrain.hangzhou.gov.cn:9459/hzsyvector/{z}/{y}/{x}","https://cb.hangzhoumap.gov.cn/E36CCEA93443D1495DB9B9F2B2FFE348CB1A367D75176F815040AB19E54CDCA5DAAA25813AF965E2ABD0CC2463DD1223/PBS/rest/services/hzsyvector/Mapserver/tile/{z}/{y}/{x}"]})});var n=r=>e.getAllLayers().find(t=>t.getClassName()===r),c=r=>{let t=e.getAllLayers().find(o=>o.getClassName()===r);t&&e.removeLayer(t)},i=(r,t)=>{e.getAllLayers().filter(a=>t.includes(a.getClassName())).forEach(a=>{a.setVisible(r==null?void 0:r.includes(a.getClassName()))})};export{s as createBaseLayer,u as createMapInstance,d as disposeMap,p as emitter,f as getMapInstance,z as resetMap};
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "map-ol-utils",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "description": "Openlayers utils library",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "author": "Tomxuetao",
10
+ "license": "ISC",
11
+ "main": "./dist/index.cjs",
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js",
18
+ "require": "./dist/index.cjs"
19
+ }
20
+ },
21
+ "keywords": [
22
+ "ol",
23
+ "map",
24
+ "openlayers",
25
+ "openlayers-utils"
26
+ ],
27
+ "dependencies": {
28
+ "ol": "^10.5.0",
29
+ "mitt": "^3.0.1",
30
+ "proj4": "^2.15.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/proj4": "^2.5.6"
34
+ },
35
+ "peerDependencies": {
36
+ "ol": ">=10.5.0"
37
+ },
38
+ "scripts": {
39
+ "build": "tsup",
40
+ "dev": "tsup --watch"
41
+ }
42
+ }