Skip to content

Commit b79972b

Browse files
committed
fix: defaults
1 parent e25bc57 commit b79972b

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/GEOComp.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,18 @@ var GEOComp = (function () {
117117
ArrayControl,
118118
`${JSON.stringify(i18nObjs.defaultData, null, 2)}`
119119
),
120-
zoom: NumberControl,
121-
maxZoom: NumberControl,
122-
rotation: NumberControl,
120+
zoom: withDefault(NumberControl, 10),
121+
maxZoom: withDefault(NumberControl, 30),
122+
rotation: withDefault(NumberControl, 0),
123+
projection: stringSimpleControl("EPSG:3857"),
123124
bbox: arrayStringExposingStateControl("bbox", [0, 0, 0, 0]),
124125
menuTitle: stringSimpleControl(""),
125126
menuContent: stringSimpleControl(""),
126127
events: jsonObjectExposingStateControl("events"),
127128
event: jsonObjectExposingStateControl("event"),
128129
feature: jsonObjectExposingStateControl("feature"),
129130
onEvent: eventHandlerControl(eventDefintions),
130-
projection: stringSimpleControl(""),
131+
131132
features:
132133
featureControl({
133134
menu: false,
@@ -140,7 +141,7 @@ var GEOComp = (function () {
140141
splitscreen: false,
141142
tracker: false,
142143
timeline: false,
143-
gpsCentered: false,
144+
gpsCentered: true,
144145
north: false,
145146
largeButtons: true,
146147
scaleToBottom: false,

src/vendors/Geo.jsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ function Geo(props) {
143143
controls: [],
144144
view: new View({
145145
center: fromLonLat(props.center.length == 2 ? props.center : geoLoc),
146-
zoom: props.zoom || 10,
147-
maxZoom: props.maxZoom || 30,
146+
zoom: props.zoom,
147+
maxZoom: props.maxZoom,
148148
rotation: props.rotation,
149-
projection: props.projection || 'EPSG:3857'
149+
projection: props.projection
150150
}),
151151
target: 'GEO_' + geoId,
152152
layers: [],
@@ -584,40 +584,43 @@ function Geo(props) {
584584
// Notification Control
585585
olMap.addControl(notification);
586586

587-
//loadLayers(olMap)
588-
589587
//Add map init event
590588
fireEvent('map:init', olMap);
591589

592590
setMap(olMap)
593591
}
594-
}, [geoRef, props.features]);
592+
}, [geoRef, props.features, props.projection]);
595593

596594

597595
useEffect(() => {
598596
if (map) {
599597
geoRef.style.height = `${props.height}px`;
600-
//geoRef.style.width=`${props.width}px`;
601598
}
602599
}, [props.height, props.width])
603600

604601
//Zoom handling
605602
useEffect(() => {
606-
if (map) map.getView().setZoom(props.zoom)
603+
if (map) {
604+
map.getView().setZoom(Math.min(props.zoom, props.maxZoom))
605+
}
607606
}, [props.zoom]);
607+
608608
//Max zoom handling
609609
useEffect(() => {
610610
if (map) {
611611
map.getView().setMaxZoom(props.maxZoom)
612612
map.getView().setZoom(Math.min(props.zoom, props.maxZoom))
613613
}
614614
}, [props.maxZoom]);
615+
616+
615617
//rotation handling
616618
useEffect(() => {
617619
if (map) {
618620
map.getView().setRotation(props.rotation)
619621
}
620622
}, [props.rotation]);
623+
621624
//Center the location on map
622625
useEffect(() => {
623626
if (map) {

0 commit comments

Comments
 (0)