Skip to content

Commit e20821d

Browse files
Merge pull request #155 from yulinscottkang/v1/sdk-upgrade
chore: upgrade azure-maps-control and make it peerDependencies
2 parents 2772f11 + ffe5912 commit e20821d

File tree

6 files changed

+36
-28
lines changed

6 files changed

+36
-28
lines changed

MIGRATION.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
## Migrating from v0.x to v1.0
22

3+
### azure-maps-control dependency
4+
`azure-maps-control` is installed as a peerDependencies package, you will need to add it to your package.json.
5+
```
6+
npm install --save azure-maps-control@next
7+
```
8+
This will install `azure-maps-control` v3 to your application. You may upgrade it independently in the future. See [AzureMaps WebSDK release notes](https://learn.microsoft.com/azure/azure-maps/release-notes-map-control) for a list of new features and bug fixes.
9+
310
### Styling
411
v1.0 removes the internal css import from `azure-maps-control` to accommodate usage in Next.js. You will need to add the following stylesheet to your application manually. The stylesheet is required for the marker, popup and control components in `react-azure-maps` to work properly.
512
```javascript

__mocks__/azure-maps-control.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ module.exports = {
6767
isOpen: jest.fn(() => true),
6868
open: jest.fn(() => false),
6969
togglePopup: jest.fn(),
70+
setOptions: jest.fn(),
7071
close: jest.fn()
7172
}
7273
}))

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-azure-maps",
3-
"version": "1.0.0-beta.1",
3+
"version": "1.0.0-beta.2",
44
"description": "React Wrapper for Azure Maps",
55
"keywords": [
66
"react",
@@ -94,6 +94,7 @@
9494
"@types/jest": "^26.0.15",
9595
"@types/react": "^18.0.15",
9696
"@types/react-dom": "^18.0.6",
97+
"azure-maps-control": "^3.0.0-preview.7",
9798
"babel-preset-env": "^1.7.0",
9899
"concurrently": "^5.3.0",
99100
"cross-env": "^7.0.2",
@@ -118,13 +119,11 @@
118119
"typescript": "^4.1.2"
119120
},
120121
"peerDependencies": {
121-
"azure-maps-control": "^3.0.0-preview.6",
122-
"guid-typescript": "^1.0.9",
122+
"azure-maps-control": "^3.0.0-preview.7",
123123
"react": "^17.0.2 || ^18.0.0",
124124
"react-dom": "^17.0.2 || ^18.0.0"
125125
},
126126
"dependencies": {
127-
"azure-maps-control": "^3.0.0-preview.6",
128127
"guid-typescript": "^1.0.9"
129128
}
130129
}

src/components/AzureMapMarkers/AzureMapHtmlMarker/AzureMapHtmlMarker.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { render } from '@testing-library/react'
22
import { Map, Popup } from 'azure-maps-control'
33
import React from 'react'
44
import { AzureMapsContext } from '../../../contexts/AzureMapContext'
5-
import AzureMaphtmlMarker from './AzureMapHtmlMarker'
5+
import AzureMapHtmlMarker from './AzureMapHtmlMarker'
66
import { IAzureMapHtmlMarker } from '../../../types'
77
import atlas from 'azure-maps-control'
88

@@ -23,7 +23,7 @@ const wrapWithAzureMapContext = (props: IAzureMapHtmlMarker) => {
2323
mapRef
2424
}}
2525
>
26-
<AzureMaphtmlMarker {...{ ...props }} />
26+
<AzureMapHtmlMarker {...{ ...props }} />
2727
</AzureMapsContext.Provider>
2828
)
2929
}
@@ -81,13 +81,13 @@ describe('AzureMaphtmlMarker tests', () => {
8181
expect(markerRef.setOptions).toHaveBeenCalledWith({ htmlContent: '<div></div>' })
8282
})
8383

84-
it('should close marker popup', () => {
84+
it('should open marker popup', () => {
8585
render(wrapWithAzureMapContext({ isPopupVisible: true, markerContent: <div /> }))
8686
// Currently we only check if getOptions get called @TODO
8787
expect(markerRef.getOptions).toHaveBeenCalled()
8888
})
8989

90-
it('should open marker popup', () => {
90+
it('should close marker popup', () => {
9191
render(wrapWithAzureMapContext({ isPopupVisible: false, markerContent: <div /> }))
9292
// Currently we only check if getOptions get called @TODO
9393
expect(markerRef.getOptions).toHaveBeenCalled()

src/components/AzureMapMarkers/AzureMapHtmlMarker/AzureMapHtmlMarker.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const AzureMapHtmlMarker = memo(
1616
)
1717
const { mapRef } = useContext<IAzureMapsContextProps>(AzureMapsContext)
1818

19-
useCheckRefMount<MapType, boolean>(mapRef, true, mref => {
19+
useCheckRefMount<MapType, boolean>(mapRef, true, (mref) => {
2020
mref.markers.add(markerRef)
2121
events &&
2222
events.forEach(({ eventName, callback }) => {
@@ -38,13 +38,14 @@ const AzureMapHtmlMarker = memo(
3838

3939
useEffect(() => {
4040
if (markerRef && markerRef.getOptions().popup && mapRef) {
41-
const isMarkerPopupOpen = markerRef.getOptions().popup?.isOpen()
42-
if (isMarkerPopupOpen && isPopupVisible) {
43-
markerRef.getOptions().popup?.close()
44-
} else if (isMarkerPopupOpen !== undefined) {
45-
markerRef.getOptions().popup?.open()
46-
} else if ((isPopupVisible && isMarkerPopupOpen) || isPopupVisible) {
47-
markerRef.togglePopup()
41+
const popupRef = markerRef.getOptions().popup
42+
if (isPopupVisible) {
43+
popupRef?.setOptions({
44+
position: markerRef.getOptions().position
45+
})
46+
popupRef?.open(mapRef)
47+
} else {
48+
popupRef?.close()
4849
}
4950
}
5051
}, [isPopupVisible, options, mapRef])

yarn.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33

44

55
"@azure/msal-browser@^2.32.1":
6-
version "2.36.0"
7-
resolved "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-2.36.0.tgz#a95af979da1dd8572b6b3cb9fc86d51713d8ad91"
8-
integrity sha512-OrVDZ9ftO7ExqZVHripAt+doKg6G14YbP2LoSygiWQoSqoO4CejoXLRLqANc/HGg18N0p/oaRETw4IHZvwsxZw==
6+
version "2.37.0"
7+
resolved "https://registry.yarnpkg.com/@azure/msal-browser/-/msal-browser-2.37.0.tgz#32d7af74eef53f2692f8a9d6bd6818c78faf4c1b"
8+
integrity sha512-YNGD/W/tw/5wDWlXOfmrVILaxVsorVLxYU2ovmL1PDvxkdudbQRyGk/76l4emqgDAl/kPQeqyivxjOU6w1YfvQ==
99
dependencies:
10-
"@azure/msal-common" "^12.1.0"
10+
"@azure/msal-common" "13.0.0"
1111

12-
"@azure/msal-common@^12.1.0":
13-
version "12.1.0"
14-
resolved "https://registry.npmjs.org/@azure/msal-common/-/msal-common-12.1.0.tgz#e253a4912a359193c52c570a1e2585cfd0213bff"
15-
integrity sha512-9RUiv0evSHvYtvF7r9ksShw9FgCeT6Rf6JB/SOMbMzI0VySZDUBSE+0b9e7DgL2Ph8wSARIh3m8c5pCK9TRY3w==
12+
"@azure/msal-common@13.0.0":
13+
version "13.0.0"
14+
resolved "https://registry.yarnpkg.com/@azure/msal-common/-/msal-common-13.0.0.tgz#9c39184903b5d0fd6e643ccc12193fae220e912b"
15+
integrity sha512-GqCOg5H5bouvLij9NFXFkh+asRRxsPBRwnTDsfK7o0KcxYHJbuidKw8/VXpycahGXNxgtuhqtK/n5he+5NhyEA==
1616

1717
1818
version "7.10.4"
@@ -3103,10 +3103,10 @@ axobject-query@^2.2.0:
31033103
resolved "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz"
31043104
integrity sha512-Td525n+iPOOyUQIeBfcASuG6uJsDOITl7Mds5gFyerkWiX7qhUTdYUBlSgNMyVqtSJqwpt1kXGLdUt6SykLMRA==
31053105

3106-
azure-maps-control@^3.0.0-preview.6:
3107-
version "3.0.0-preview.6"
3108-
resolved "https://registry.yarnpkg.com/azure-maps-control/-/azure-maps-control-3.0.0-preview.6.tgz#e10591cfe7845f195b8884df210e96ca80b8d34c"
3109-
integrity sha512-+iQhVzdalQrXqFcUi3sSP2qD/Hj1ilg29/V1ajGqN3QzGjwgUr9yCNcr4VHdbXGnYJ2+thHk/TUlmXV8F09u0Q==
3106+
azure-maps-control@^3.0.0-preview.7:
3107+
version "3.0.0-preview.7"
3108+
resolved "https://registry.yarnpkg.com/azure-maps-control/-/azure-maps-control-3.0.0-preview.7.tgz#7e96a5adb8f537a19a214c5e3ace433ddae62c89"
3109+
integrity sha512-PedAjZ8rUQcMXktT1ylnq+Rx+mIsRXVcxmcP9204sjPzH09tl8JC+EDPwt0y2XQ5y1jKussjv8aoteA/bLNrzw==
31103110
dependencies:
31113111
"@azure/msal-browser" "^2.32.1"
31123112

0 commit comments

Comments
 (0)