Skip to content

Made a Geolocation extension #1943

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

samuellouf
Copy link
Contributor

Hello, folks!
I made a Geolocation extension.
Enjoy!

@github-actions github-actions bot added the pr: new extension Pull requests that add a new extension label Feb 19, 2025
@yuri-kiss
Copy link
Member

This is pretty simple, I will give it a review later today if I don't forget

@yuri-kiss yuri-kiss self-assigned this Feb 19, 2025
@samuellouf
Copy link
Contributor Author

This is pretty simple, I will give it a review later today if I don't forget

Thanks!

@samuellouf
Copy link
Contributor Author

samuellouf commented Feb 20, 2025

Okay, I'm just gonna add Geocoding Blocks. I'm giving up on that idea. I will probably do a separate "Geocoding" extension.

@samuellouf
Copy link
Contributor Author

Here ! It's finally done!

Copy link
Contributor

@Brackets-Coder Brackets-Coder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me! All protocols are being followed and I don't see any reason why this can't be merged now.

"use strict";

function getGeolocation(
options = { enableHighAccuracy: true, timeout: 5000, maximumAge: 0 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with geolocation apis but will the timeout affect anything?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will slow it down iirc

Comment on lines +159 to +171
async getCurrent(args) {
if (!(await this.isAllowed())) return "";
var coordinates = await getGeolocation();
if (coordinates.success == true) {
return coordinates[args.WHAT];
} else {
return "";
}
}

async isAllowed() {
return await Scratch.canGeolocate();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yuri-kiss are we allowed to make block functions themselves asynchronous or should we put asynchronous functions inside them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they can be async

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: new extension Pull requests that add a new extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants