extensions
extensions copied to clipboard
Made a Geolocation extension
Hello, folks! I made a Geolocation extension. Enjoy!
This is pretty simple, I will give it a review later today if I don't forget
This is pretty simple, I will give it a review later today if I don't forget
Thanks!
Okay, I'm just gonna add Geocoding Blocks. I'm giving up on that idea. I will probably do a separate "Geocoding" extension.
Here ! It's finally done!
I can't find any blocks to actually get my location, which is a pretty necessary feature for a geolocation extension.
huh didn't notice that, maybe we're missing something?
I can't find any blocks to actually get my location, which is a pretty necessary feature for a geolocation extension.
it's an error with the extension. the block has the wrong menu so it points to one that doesn't exist (it should be coordinates)
I can't find any blocks to actually get my location, which is a pretty necessary feature for a geolocation extension.
it's an error with the extension. the block has the wrong menu so it points to one that doesn't exist (it should be
coordinates)
Thanks, I didn't notice
I can't find any blocks to actually get my location, which is a pretty necessary feature for a geolocation extension.
it's an error with the extension. the block has the wrong menu so it points to one that doesn't exist (it should be
coordinates)
You are right.
Dunno how I let that slip.
Fixed it!!
Fixed it!!
I'll check when I can
I just made a few changes :
- Changed the default timeout (bc I realised 5 seconds weren't enough)
- Fixed the
getCurrentfunction (the timeout and the accuracy weren't taken into account until this fix)
Get longitude and latitude doesn't seem to work for me in Safari (the block says it's supported and it's not an API limitation), and in Firefox longitude is negative where for me it should be positive according to my Maps app.
Perhaps there's something wrong with your computer or your phone. (No offense) It works for me on both Google Chrome and Firefox on Windows 10, 11, and Linux Mint.
@PPPDUD, could you check if the position the extension returns is valid?
Get longitude and latitude doesn't seem to work for me in Safari (the block says it's supported and it's not an API limitation), and in Firefox longitude is negative where for me it should be positive according to my Maps app.
Perhaps there's something wrong with your computer or your phone. (No offense) It works for me on both Google Chrome and Firefox on Windows 10, 11, and Linux Mint.
It's not the computer, I'm on a modern Mac with the latest software version. It works in Firefox, not Safari- it's not a browser limitation because the extension says I support geolocation and Apple's MapJS kit wouldn't work without geolocation capabilities, so something about the get location reporter doesn't work in Safari.
Also, the longitude is still negative, where according to my maps app, it should be positive.
Get longitude and latitude doesn't seem to work for me in Safari (the block says it's supported and it's not an API limitation), and in Firefox longitude is negative where for me it should be positive according to my Maps app.
Perhaps there's something wrong with your computer or your phone. (No offense) It works for me on both Google Chrome and Firefox on Windows 10, 11, and Linux Mint.
It's not the computer, I'm on a modern Mac with the latest software version. It works in Firefox, not Safari- it's not a browser limitation because the extension says I support geolocation and Apple's MapJS kit wouldn't work without geolocation capabilities, so something about the get location reporter doesn't work in Safari.
That's interesting. I don't get why it isn't working. It should work. Is the longitude still negative?
Should I add a "when user moves" block? (It would be a hat, ofc) It would be paired with latitude, longitude, accuracy blocks. It seems to be easily doable.
Get longitude and latitude doesn't seem to work for me in Safari (the block says it's supported and it's not an API limitation), and in Firefox longitude is negative where for me it should be positive according to my Maps app.
Perhaps there's something wrong with your computer or your phone. (No offense) It works for me on both Google Chrome and Firefox on Windows 10, 11, and Linux Mint.
It's not the computer, I'm on a modern Mac with the latest software version. It works in Firefox, not Safari- it's not a browser limitation because the extension says I support geolocation and Apple's MapJS kit wouldn't work without geolocation capabilities, so something about the get location reporter doesn't work in Safari.
That's interesting. I don't get why it isn't working. It should work. Is the longitude still negative?
Yes, but I'm not 180º on the other side of the world. A theory, I updated to the latest major macOS Tahoe release recently and it's a .0 version. I've discovered a few UI inconsistencies after the redesign so there may be potential functionality issues in the latest version, but it's very unlikely.
Should I add a "when user moves" block? (It would be a hat, ofc) It would be paired with latitude, longitude, accuracy blocks. It seems to be easily doable.
Depends on whether users would use it and how performant it would be
Hmm... it seems like I have location services disabled in settings and Firefox is attempting to override it, so it may be faulty. I'll test it later when I have time
Should I add a "when user moves" block? (It would be a hat, ofc) It would be paired with latitude, longitude, accuracy blocks. It seems to be easily doable.
@samuellouf That is genius, please add that! You might want to add a way to enable or disable that block though, since it's probably gonna eat up time pretty easily (see @Brackets-Coder's comment).
Should I add a "when user moves" block? (It would be a hat, ofc) It would be paired with latitude, longitude, accuracy blocks. It seems to be easily doable.
@samuellouf That is genius, please add that! You might want to add a way to enable or disable that block though, since it's probably gonna eat up time pretty easily (see @Brackets-Coder's comment).
Done !
I added some code that sends the event, gets the threads to which the event was sent, and returns the value in the get [WHAT] block.
async getCurrent(args, util) {
if (!(await this.isAllowed())) return "";
var coordinates =
util.thread._coordinates || (await getGeolocation(this.options));
// read the coordinates in the thread if present OR get the current coordinates
if (coordinates.success == true) {
return coordinates[args.WHAT];
} else {
return "";
}
}
async changePositionWatching(args) {
...
this.watcherID = navigator.geolocation.watchPosition(
(pos) => {
var threads = Scratch.vm.runtime.startHats(
"samuelloufgeolocation_onUserMove"
); // Trigger the hat
for (var thread of threads) { // for each thread
var coords = pos.toJSON().coords; // Turn the coordinates into JSON
coords.success = true; // Add success
// @ts-ignore
thread._coordinates = coords; // Add the coordinates to the thread
}
},
() => {},
this.options
);
...
}
