UNPKG

casc-cesium

Version:

Vue 3.x components for CesiumJS.

1 lines 10.5 kB
{"version":3,"file":"index.mjs","sources":["../../../../../../packages/components/datasources/geojson/index.ts"],"sourcesContent":["/*\n * @Author: zouyaoji@https://github.com/zouyaoji\n * @Date: 2021-09-16 09:28:13\n * @LastEditTime: 2022-04-06 15:00:36\n * @LastEditors: zouyaoji\n * @Description:\n * @FilePath: \\vue-cesium@next\\packages\\components\\datasources\\geojson\\index.ts\n */\nimport type { PropType, VNode } from 'vue'\nimport { createCommentVNode, defineComponent, getCurrentInstance, h } from 'vue'\nimport type {\n AnyObject,\n VcColor,\n VcComponentInternalInstance,\n VcComponentPublicInstance,\n VcDatasource,\n VcPickEvent,\n VcReadyObject\n} from 'casc-cesium-utils/types'\nimport { useDatasources } from 'casc-cesium-composables'\nimport { kebabCase } from 'casc-cesium-utils/util'\nimport { hSlot } from 'casc-cesium-utils/private/render'\nimport { show, enableMouseEvent, data, sourceUri, clampToGround, credit } from 'casc-cesium-utils/cesium-props'\nimport { makeColor } from 'casc-cesium-utils/cesium-helpers'\nimport { VcEntityProps } from '../../entity/src'\nimport { datasourceEmits } from 'casc-cesium-utils/emits'\n\nexport const geojsonDatasourceProps = {\n ...show,\n ...enableMouseEvent,\n entities: {\n type: Array as PropType<Array<VcEntityProps>>,\n default: () => []\n },\n ...data,\n ...sourceUri,\n describe: [Function, Object],\n markerSize: {\n type: Number,\n default: 48\n },\n markerSymbol: String,\n markerColor: {\n type: [Object, String, Array] as PropType<VcColor>,\n default: () => ({ x: 0.2549019607843137, y: 0.4117647058823529, z: 0.8823529411764706 }),\n watcherOptions: {\n cesiumObjectBuilder: makeColor\n }\n },\n stroke: {\n type: [Object, String, Array] as PropType<VcColor>,\n default: () => ({ x: 1, y: 1, z: 0 }),\n watcherOptions: {\n cesiumObjectBuilder: makeColor\n }\n },\n strokeWidth: {\n type: Number,\n default: 2\n },\n fill: {\n type: [Object, String, Array] as PropType<VcColor>,\n default: () => ({ x: 1, y: 1, z: 0, w: 0.39215686274509803 }),\n watcherOptions: {\n cesiumObjectBuilder: makeColor\n }\n },\n ...clampToGround,\n ...credit,\n destroy: {\n type: Boolean,\n default: false\n }\n}\nexport default defineComponent({\n name: 'VcDatasourceGeojson',\n props: geojsonDatasourceProps,\n emits: datasourceEmits,\n setup(props, ctx) {\n // state\n const instance = getCurrentInstance() as VcComponentInternalInstance\n instance.cesiumClass = 'GeoJsonDataSource'\n const datasourcesState = useDatasources(props, ctx, instance)\n\n if (undefined === datasourcesState) {\n return\n }\n\n instance.createCesiumObject = async () => {\n const options: any = datasourcesState.transformProps(props)\n return Cesium.GeoJsonDataSource.load(props.data, options)\n }\n\n return () =>\n ctx.slots.default\n ? h(\n 'i',\n {\n class: kebabCase(instance.proxy?.$options.name || ''),\n style: { display: 'none !important' }\n },\n hSlot(ctx.slots.default)\n )\n : createCommentVNode(kebabCase(instance.proxy?.$options.name || ''))\n }\n})\n\nexport type VcDatasourceGeojsonProps = {\n /**\n * Specify whether the data source is displayed.\n * Default value: true\n */\n show?: boolean\n /**\n * Specify whether to respond to mouse pick events.\n * Default value: true\n */\n enableMouseEvent?: boolean\n /**\n * Specify the collection of entities to be added to this data source.\n */\n entities?: Array<VcEntityProps>\n /**\n * A url, GeoJSON object, or TopoJSON object to be loaded.\n */\n data: Cesium.Resource | string | AnyObject\n /***\n * Overrides the url to use for resolving relative links.\n */\n sourceUri?: string\n /**\n * A function which returns a Property object (or just a string), which converts the properties into an html description.\n */\n describe?: (properties: AnyObject, nameProperty: string) => string | AnyObject\n /**\n * The default size of the map pin created for each point, in pixels.\n * Default value: 48\n */\n markerSize?: number\n /**\n * The default symbol of the map pin created for each point.\n */\n markerSymbol?: string\n /**\n * The default color of the map pin created for each point.\n * Default value: { x: 0.2549019607843137, y: 0.4117647058823529, z: 0.8823529411764706 }\n */\n markerColor?: VcColor\n /**\n * The default color of polylines and polygon outlines.\n * Default value: { x: 1, y: 1, z: 0 }\n */\n stroke?: VcColor\n /**\n * The default width of polylines and polygon outlines.\n * Default value: 2\n */\n strokeWidth?: number\n /**\n * The default color for polygon interiors.\n * Default value: { x: 1, y: 1, z: 0, w: 0.39215686274509803 }\n */\n fill?: VcColor\n /**\n * true if we want the features clamped to the ground.\n */\n clampToGround?: boolean\n /**\n * A credit for the data source, which is displayed on the canvas.\n */\n credit?: string\n /**\n * Whether to destroy the data source in addition to removing it.\n * Default value: false\n */\n destroy?: boolean\n /**\n * Triggers before the VcDatasourceGeojson is loaded.\n */\n onBeforeLoad?: (instance: VcComponentInternalInstance) => void\n /**\n * Triggers when the VcDatasourceGeojson is successfully loaded.\n */\n onReady?: (readyObject: VcReadyObject) => void\n /**\n * Triggers when the component load failed.\n */\n onUnready?: (e: any) => void\n /**\n * Triggers when the VcDatasourceGeojson is destroyed.\n */\n onDestroyed?: (instance: VcComponentInternalInstance) => void\n /**\n * Triggers when the mouse is pressed on this datasource.\n */\n onMousedown?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse bounces up on this datasource.\n */\n onMouseup?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse clicks on this datasource.\n */\n onClick?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse clicks outside this datasource.\n */\n onClickout?: (evt: VcPickEvent) => void\n /**\n * Triggers when the left mouse button double-clicks this datasource.\n */\n onDblclick?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse moves on this datasource.\n */\n onMousemove?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse moves over to this datasource.\n */\n onMouseover?: (evt: VcPickEvent) => void\n /**\n * Triggers when the mouse moves out of this datasource.\n */\n onMouseout?: (evt: VcPickEvent) => void\n /**\n * Triggers whenever a new property is assigned. datasource.clock.\n */\n onDefinitionChanged?: (property: Cesium.Property) => void\n /**\n * Triggers when a new cluster will be displayed. datasource.clustering.\n */\n onClusterEvent?: (\n entities: Array<Cesium.Entity>,\n cluster: { billboard: Cesium.Billboard; label: Cesium.Label; point: Cesium.PointPrimitive }\n ) => void\n /**\n * Triggers when entities are added or removed from the collection.datasource.entities\n */\n onCollectionChanged?: (\n collection: Cesium.EntityCollection,\n addedArray: Array<Cesium.Entity>,\n removedArray: Array<Cesium.Entity>,\n changedArray: Array<Cesium.Entity>\n ) => void\n /**\n * Triggerswhen the underlying data changes.\n */\n onChangedEvent?: (datasource: VcDatasource) => void\n /**\n * Triggers if an error is encountered during processing.\n */\n onErrorEvent?: (datasource: VcDatasource, error: any) => void\n /**\n * Triggers when the data source either starts or stops loading.\n */\n onLoadingEvent?: (datasource: VcDatasource, isLoading: boolean) => void\n}\n\nexport type VcDatasourceGeojsonRef = VcComponentPublicInstance<VcDatasourceGeojsonProps>\n\nexport interface VcDatasourceGeojsonSlots {\n /**\n * Slot for vc-entity.\n */\n default: () => VNode[]\n}\n"],"names":[],"mappings":";;;;;;;;;AAOY,MAAC,sBAAsB,GAAG;AACtC,EAAE,GAAG,IAAI;AACT,EAAE,GAAG,gBAAgB;AACrB,EAAE,QAAQ,EAAE;AACZ,IAAI,IAAI,EAAE,KAAK;AACf,IAAI,OAAO,EAAE,MAAM,EAAE;AACrB,GAAG;AACH,EAAE,GAAG,IAAI;AACT,EAAE,GAAG,SAAS;AACd,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;AAC9B,EAAE,UAAU,EAAE;AACd,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,EAAE;AACf,GAAG;AACH,EAAE,YAAY,EAAE,MAAM;AACtB,EAAE,WAAW,EAAE;AACf,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;AACjC,IAAI,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC;AAC5F,IAAI,cAAc,EAAE;AACpB,MAAM,mBAAmB,EAAE,SAAS;AACpC,KAAK;AACL,GAAG;AACH,EAAE,MAAM,EAAE;AACV,IAA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