Skip to content

Commit 291d648

Browse files
committed
Merge branch 'chore/SD-1526-ui-maps-fixes' into chore/ts-ci-test
2 parents 9a95f68 + d9bccbe commit 291d648

File tree

5 files changed

+51
-17
lines changed

5 files changed

+51
-17
lines changed

packages/ripple-ui-maps/src/components/map/RplMap.vue

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ let mapAccentColor: string = ''
44

55
<script setup lang="ts">
66
import { RplIcon } from '@dpc-sdp/ripple-ui-core/vue'
7-
import type { IRplMapFeature, IRplMapLayer } from './../../types'
7+
import type {
8+
IRplMapFeature,
9+
IRplMapInstance,
10+
IRplMapLayer
11+
} from './../../types'
812
import {
913
onMounted,
1014
onUnmounted,
@@ -26,7 +30,7 @@ import RplMapCluster from './../cluster/RplMapCluster.vue'
2630
import RplMapLayerList from './../layer-list/RplMapLayerList.vue'
2731
import markerIconDefaultSrc from './../feature-pin/icon-pin.svg?url'
2832
import markerIconSelectedSrc from './../feature-pin/icon-pin-selected.svg?url'
29-
import useMapControls from './../../composables/useMapControls.ts'
33+
import useMapControls from './../../composables/useMapControls'
3034
import {
3135
getfeaturesAtMapPixel,
3236
zoomToClusterExtent,
@@ -49,7 +53,7 @@ interface Props {
4953
pinStyle?: Function
5054
centerActivePin?: boolean
5155
mapHeight?: number
52-
popupType?: 'sidebar' | 'popover'
56+
popupType?: 'sidebar' | 'popover' | 'sidepanel'
5357
hasSidePanel?: boolean
5458
noresults?: boolean
5559
getFeatureTitle?: (feature: any) => string
@@ -73,7 +77,7 @@ const props = withDefaults(defineProps<Props>(), {
7377
hasSidePanel: false,
7478
initialCenter: () => [144.9631, -36.8136], // melbourne CBD
7579
homeViewExtent: () => [144.9631, -36.8136], // melbourne CBD
76-
pinStyle: (feature) => {
80+
pinStyle: (feature: IRplMapFeature) => {
7781
let color = feature.color || mapAccentColor || 'red'
7882
const ic = new Icon({
7983
src: markerIconDefaultSrc,
@@ -94,7 +98,7 @@ const props = withDefaults(defineProps<Props>(), {
9498
})
9599
96100
const emit = defineEmits<{
97-
(e: 'updateSelectedLayers', payload: [value: string[]]): void
101+
(e: 'updateSelectedLayers', value: string[]): void
98102
(e: 'togglePopup', payload: rplEventPayload & { action: 'open' }): void
99103
}>()
100104
@@ -103,10 +107,16 @@ const { emitRplEvent } = useRippleEvent('rpl-map', emit)
103107
const zoom = ref(props.initialZoom)
104108
const rotation = ref(0)
105109
const view = ref(null)
106-
const mapPosition = ref({})
110+
const mapPosition = ref<{
111+
center: number[] | undefined
112+
zoom: number | undefined
113+
}>({
114+
center: undefined,
115+
zoom: undefined
116+
})
107117
108118
const { setRplMapRef, popup, deadSpace, defaultExtent } =
109-
inject('rplMapInstance')
119+
inject<IRplMapInstance>('rplMapInstance')
110120
111121
// Reference to ol/map instance
112122
const mapRef = ref<{ map: Map } | null>(null)
@@ -314,7 +324,7 @@ watch(
314324
() => popup.value,
315325
(newPopup) => {
316326
if (newPopup.isOpen) {
317-
let title = popup.value?.title
327+
let title: string | string[] = popup.value?.title
318328
const features = Array.isArray(popup.value?.feature)
319329
? popup.value.feature
320330
: [popup.value.feature]

packages/ripple-ui-maps/src/components/map/__fixture__/VectorLayer.example.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<script setup lang="ts">
1313
import { GeoJSON } from 'ol/format'
1414
import { Style, Fill, Stroke } from 'ol/style'
15+
import { IRplMapInstance } from '../../../types'
1516
import { computed, inject, onMounted, nextTick } from 'vue'
1617
interface Props {
1718
results: any[]
@@ -47,7 +48,7 @@ const areaUrl = computed(() => {
4748
4849
return arcGISURL
4950
})
50-
const { rplMapRef, popup } = inject('rplMapInstance')
51+
const { rplMapRef, popup } = inject<IRplMapInstance>('rplMapInstance')
5152
5253
const defaultStyleFn = new Style({
5354
fill: new Fill({

packages/ripple-ui-maps/src/components/map/utils.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { transform, transformExtent } from 'ol/proj.js'
33
import { getDistance } from 'ol/sphere.js'
44
import { inAndOut } from 'ol/easing.js'
55
import Map from 'ol/Map.js'
6+
import { MapDeadSpace } from '../../types'
67

78
export const haversineDistance = (coord1, coord2) => getDistance(coord1, coord2)
89

@@ -186,13 +187,6 @@ export const centerMap = (
186187
})
187188
}
188189

189-
type MapDeadSpace = {
190-
top?: number
191-
bottom?: number
192-
left?: number
193-
right?: number
194-
}
195-
196190
type MapDefaultExtent = [number, number, number, number]
197191

198192
export const fitExtent = (

packages/ripple-ui-maps/src/composables/useMapControls.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { inject, ref, onMounted } from 'vue'
22
import { useEventListener } from '@vueuse/core'
33
import { easeOut } from 'ol/easing'
44
import { fitDefaultExtent } from './../components/map/utils'
5+
import { IRplMapInstance } from '../types'
56

67
export default (mapRef) => {
7-
const { deadSpace, defaultExtent } = inject('rplMapInstance')
8+
const { deadSpace, defaultExtent } = inject<IRplMapInstance>('rplMapInstance')
89

910
const isFullScreen = ref(false)
1011
const supportsFullScreen = ref(false)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
1+
import type { Ref } from 'vue'
2+
13
export interface IRplMapFeature {
24
id: string
35
lat: number
46
lng: number
57
title?: string
68
description?: string
79
data?: Record<string, any>
10+
color?: string
811
}
912

1013
export interface IRplMapLayer {
1114
id: string
1215
label: string
1316
image: string
1417
}
18+
19+
export type MapDeadSpace = {
20+
top?: number
21+
bottom?: number
22+
left?: number
23+
right?: number
24+
}
25+
26+
export interface IRplMapPopup {
27+
title?: string
28+
isOpen: boolean
29+
position: number[]
30+
feature?: any
31+
trigger?: any
32+
color?: string
33+
isArea?: boolean
34+
}
35+
36+
export interface IRplMapInstance {
37+
rplMapRef: Ref<any>
38+
setRplMapRef: (mapInstance: any) => void
39+
popup: Ref<IRplMapPopup>
40+
defaultExtent: [number, number, number, number]
41+
deadSpace: Ref<MapDeadSpace>
42+
}

0 commit comments

Comments
 (0)