Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zoom props in geolocation control #38

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/controls/react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function main() {
<MMapDefaultFeaturesLayer />
<MMapControls position="left">
<MMapZoomControl />
<MMapGeolocationControl />
<MMapGeolocationControl zoom={11} />
</MMapControls>
<MMapControls position="bottom">
<MMapZoomControl />
Expand Down
4 changes: 3 additions & 1 deletion example/controls/vanilla/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ async function main() {
[new MMapDefaultSchemeLayer({}), new MMapDefaultFeaturesLayer({})]
);

map.addChild(new MMapControls({position: 'left'}, [new MMapZoomControl({}), new MMapGeolocationControl({})]));
map.addChild(
new MMapControls({position: 'left'}, [new MMapZoomControl({}), new MMapGeolocationControl({zoom: 11})])
);
map.addChild(new MMapControls({position: 'bottom'}, [new MMapZoomControl({})]));
map.addChild(
new MMapControls({position: 'right'}, [
Expand Down
2 changes: 1 addition & 1 deletion example/controls/vue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function main() {
<MMapDefaultFeaturesLayer />
<MMapControls position="left">
<MMapZoomControl />
<MMapGeolocationControl />
<MMapGeolocationControl :zoom="11" />
</MMapControls>
<MMapControls position="bottom">
<MMapZoomControl />
Expand Down
6 changes: 5 additions & 1 deletion src/controls/MMapGeolocationControl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type MMapGeolocationControlProps = {
easing?: EasingFunctionDescription;
/** Map location animate duration */
duration?: number;
/** Map zoom after geolocate position */
zoom?: number;
};

const defaultProps = Object.freeze({duration: 500});
Expand All @@ -28,7 +30,8 @@ const MMapGeolocationControlVuefyOptions: CustomVuefyOptions<MMapGeolocationCont
onGeolocatePosition: Function as TVue.PropType<MMapGeolocationControlProps['onGeolocatePosition']>,
source: String,
easing: [String, Object, Function] as TVue.PropType<EasingFunctionDescription>,
duration: {type: Number, default: defaultProps.duration}
duration: {type: Number, default: defaultProps.duration},
zoom: {type: Number}
}
};

Expand Down Expand Up @@ -88,6 +91,7 @@ class MMapGeolocationControl extends mappable.MMapGroupEntity<MMapGeolocationCon
map?.update({
location: {
center: this._position,
zoom: this._props.zoom,
duration: this._props.duration,
easing: this._props.easing
}
Expand Down
2 changes: 1 addition & 1 deletion src/controls/MMapGeolocationControl/self.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading