UNPKG

vue-cesium

Version:
1 lines 10.4 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 '@vue-cesium/utils/types'\nimport { useDatasources } from '@vue-cesium/composables'\nimport { kebabCase } from '@vue-cesium/utils/util'\nimport { hSlot } from '@vue-cesium/utils/private/render'\nimport { show, enableMouseEvent, data, sourceUri, clampToGround, credit } from '@vue-cesium/utils/cesium-props'\nimport { makeColor } from '@vue-cesium/utils/cesium-helpers'\nimport { VcEntityProps } from '../../entity/src'\nimport { datasourceEmits } from '@vue-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":";;;;;;;;;;AA2BO,MAAM,sBAAyB,GAAA;AAAA,EACpC,GAAG,IAAA;AAAA,EACH,GAAG,gBAAA;AAAA,EACH,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,KAAA;AAAA,IACN,OAAA,EAAS,MAAM,EAAC;AAAA,GAClB;AAAA,EACA,GAAG,IAAA;AAAA,EACH,GAAG,SAAA;AAAA,EACH,QAAA,EAAU,CAAC,QAAA,EAAU,MAAM,CAAA;AAAA,EAC3B,UAAY,EAAA;AAAA,IACV,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,EAAA;AAAA,GACX;AAAA,EACA,YAAc,EAAA,MAAA;AAAA,EACd,WAAa,EAAA;AAAA,IACX,IAAM,EAAA,CAAC,MAAQ,EAAA,MAAA,EAAQ,KAAK,CAAA;AAAA,IAC5B,OAAA,EAAS,OAAO,EAAE,CAAA,EAAG,oBAAoB,CAAG,EAAA,kBAAA,EAAoB,GAAG,kBAAmB,EAAA,CAAA;AAAA,IACtF,cAAgB,EAAA;AAAA,MACd,mBAAqB,EAAA,SAAA;AAAA,KACvB;AAAA,GACF;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA,CAAC,MAAQ,EAAA,MA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