Skip to content
GitLab
Explore
Sign in
Commits on Source (3)
Support setting showsCompass, showsMapTypeContrl and showsZoomControl properties on map.
· 203ab994
Zandor Smith
authored
Apr 05, 2022
203ab994
Add check if the props are correct values.
· 7295ae29
Zandor Smith
authored
Apr 05, 2022
7295ae29
Version bump. (v0.9.0)
· d47d9049
Zandor Smith
authored
Apr 05, 2022
d47d9049
Hide whitespace changes
Inline
Side-by-side
package.json
View file @
d47d9049
{
"name"
:
"@zandor300/react-apple-mapkitjs"
,
"version"
:
"0.
8.1
"
,
"version"
:
"0.
9.0
"
,
"description"
:
"A react wrapper for apple mapkit.js"
,
"main"
:
"lib/index.js"
,
"scripts"
:
{
...
...
src/lib/AppleMaps.js
View file @
d47d9049
import
React
,
{
Component
}
from
'
react
'
import
TokenManager
from
"
./TokenManager
"
import
ColorScheme
from
"
./ColorScheme
"
;
import
FeatureVisibility
from
"
./FeatureVisibility
"
;
import
MapType
from
"
./MapType
"
;
class
AppleMaps
extends
Component
{
constructor
(
props
)
{
...
...
@@ -10,7 +13,15 @@ class AppleMaps extends Component {
}
componentDidMount
()
{
const
{
children
,
initialMapType
,
token
,
colorScheme
}
=
this
.
props
const
{
children
,
initialMapType
,
token
,
colorScheme
,
showsCompass
,
showsMapTypeControl
,
showsZoomControl
}
=
this
.
props
TokenManager
.
getInstance
().
setToken
(
token
)
...
...
@@ -29,10 +40,31 @@ class AppleMaps extends Component {
// Set initial mapType
if
(
initialMapType
!==
undefined
)
{
this
.
map
.
mapType
=
initialMapType
if
(
!
MapType
.
isOneOf
(
initialMapType
))
{
console
.
error
(
"
Invalid initialMapType provided to AppleMaps component.
"
)
}
else
{
this
.
map
.
mapType
=
initialMapType
}
}
if
(
colorScheme
!==
undefined
)
{
this
.
map
.
colorScheme
=
colorScheme
if
(
!
ColorScheme
.
isOneOf
(
colorScheme
))
{
console
.
error
(
"
Invalid colorScheme provided to AppleMaps component.
"
)
}
else
{
this
.
map
.
colorScheme
=
colorScheme
}
}
if
(
showsCompass
!==
undefined
)
{
if
(
!
FeatureVisibility
.
isOneOf
(
showsCompass
))
{
console
.
error
(
"
Invalid showsCompass provided to AppleMaps component.
"
)
}
else
{
this
.
map
.
showsCompass
=
showsCompass
}
}
if
(
showsMapTypeControl
!==
undefined
)
{
this
.
map
.
showsMapTypeControl
=
showsMapTypeControl
}
if
(
showsZoomControl
!==
undefined
)
{
this
.
map
.
showsZoomControl
=
showsZoomControl
}
// Annotations
...
...
@@ -90,13 +122,33 @@ class AppleMaps extends Component {
width
,
height
,
autoAdjust
,
colorScheme
colorScheme
,
showsCompass
,
showsMapTypeControl
,
showsZoomControl
}
=
this
.
props
TokenManager
.
getInstance
().
setToken
(
token
)
if
(
colorScheme
!==
prevProps
.
colorScheme
)
{
this
.
map
.
colorScheme
=
colorScheme
if
(
!
ColorScheme
.
isOneOf
(
colorScheme
))
{
console
.
error
(
"
Invalid colorScheme provided to AppleMaps component.
"
)
}
else
{
this
.
map
.
colorScheme
=
colorScheme
}
}
if
(
showsCompass
!==
prevProps
.
showsCompass
)
{
if
(
!
FeatureVisibility
.
isOneOf
(
showsCompass
))
{
console
.
error
(
"
Invalid showsCompass provided to AppleMaps component.
"
)
}
else
{
this
.
map
.
showsCompass
=
showsCompass
}
}
if
(
showsMapTypeControl
!==
prevProps
.
showsMapTypeControl
)
{
this
.
map
.
showsMapTypeControl
=
showsMapTypeControl
}
if
(
showsZoomControl
!==
prevProps
.
showsZoomControl
)
{
this
.
map
.
showsZoomControl
=
showsZoomControl
}
if
((
...
...
src/lib/ColorScheme.js
View file @
d47d9049
const
Light
=
"
light
"
const
Dark
=
"
dark
"
const
isOneOf
=
(
value
)
=>
{
switch
(
value
)
{
case
Light
:
case
Dark
:
return
true
default
:
return
false
}
}
export
default
{
Light
,
Dark
Dark
,
isOneOf
}
src/lib/FeatureVisibility.js
0 → 100644
View file @
d47d9049
const
Adaptive
=
"
adaptive
"
const
Hidden
=
"
hidden
"
const
Visible
=
"
visible
"
const
isOneOf
=
(
value
)
=>
{
switch
(
value
)
{
case
Adaptive
:
case
Hidden
:
case
Visible
:
return
true
default
:
return
false
}
}
export
default
{
Adaptive
,
Hidden
,
Visible
,
isOneOf
}
src/lib/MapType.js
View file @
d47d9049
...
...
@@ -3,9 +3,22 @@ const MutedStandard = "mutedStandard"
const
Hybrid
=
"
hybrid
"
const
Satellite
=
"
satellite
"
const
isOneOf
=
(
value
)
=>
{
switch
(
value
)
{
case
Standard
:
case
MutedStandard
:
case
Hybrid
:
case
Satellite
:
return
true
default
:
return
false
}
}
export
default
{
Standard
,
MutedStandard
,
Hybrid
,
Satellite
Satellite
,
isOneOf
}
src/lib/index.jsx
View file @
d47d9049
...
...
@@ -2,5 +2,8 @@ export { default as AppleMaps } from './AppleMaps'
export
{
default
as
Annotation
}
from
'
./Annotation
'
export
{
default
as
ImageAnnotation
}
from
'
./ImageAnnotation
'
export
{
default
as
CurrentLocationOverride
}
from
'
./CurrentLocationOverride
'
export
{
default
as
MapType
}
from
'
./MapType
'
;
export
{
default
as
ColorScheme
}
from
'
./ColorScheme
'
;
// Enums
export
{
default
as
MapType
}
from
'
./MapType
'
export
{
default
as
ColorScheme
}
from
'
./ColorScheme
'
export
{
default
as
FeatureVisibility
}
from
'
./FeatureVisibility
'