How to turn the Geolocation Script to a macro for Sylvain Naudins Leaflet Plugin?

245 views
Skip to first unread message

Jan

unread,
Jul 2, 2018, 6:37:10 PM7/2/18
to TiddlyWiki
Hello,
I would like to have a macro which uses this script
https://www.w3schools.com/Html/tryit.asp?filename=tryhtml5_geolocation
to capture the geolocation.
It should trigger a Modal with a button to write
position.coords.longitude ,position.coords.latitude
to a field called points in a new tiddler.

(This is what I would furnish if I got the geolocation as a name/variable. somehow.I would also make a button also add it to a path.)

This would be a great feature to have in Sylvain Naudins Leaflet Plugin (http://sycom.github.io/TiddlyWiki-Plugins/#Leaflet%20plugin)

Thanks for your help!
Yours
Jan







Message has been deleted

SylvainComte

unread,
Jul 5, 2018, 10:48:51 AM7/5/18
to TiddlyWiki
Hello Jan,

I did reply to you yesterday, but my reply has been deleted :'-(

before retyping all, I have to be sure it will not be deleted again. So if anyone can explain why my reply went to trash?

cheers

Sylvain

Jan

unread,
Jul 5, 2018, 11:14:09 AM7/5/18
to tiddl...@googlegroups.com
Salut Sylvain,
I hoped you would reply (and don't worry, I still can see your reply...)
I will give it a try, but this would be my first javascript-addon, so maybe you will be faster than me...

Yours Jan
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/804ac082-c98d-4ec2-a356-4ba28bed0be9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jan

unread,
Jul 18, 2018, 7:53:28 PM7/18/18
to TiddlyWiki
Hello
I made several attempts to adapt this geolocation snippet https://www.w3schools.com/Html/tryit.asp?filename=tryhtml5_geolocation to TW.
I starting to think TW is not the easiest place to learn java script. Is there a documentation how to wrap in the code and define functions?
This is where I am right now, alas it throws red screen of embarassment.
_________________________________
/*\
title: $:/core/modules/macros/geolocation.js
type: application/javascript
module-type: macro

Macro to return the current Geoposition in Coordinates

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

/*
Information about this macro
*/

exports.name = "geolocation";

exports.params = [];

/*
Run the macro
*/
exports.run = function() {
if (navigator.geolocation) {
        navigator.geolocation.watchPosition(showPosition);
    } else {
         var geolocation = Geolocation is not supported by this browser;
    }
var geolocation = position.coords.latitude + "," + position.coords.longitude;
      return geolocation;
};

})();

__________________
Can anyone help?

Yours Jan

TonyM

unread,
Jul 18, 2018, 9:15:08 PM7/18/18
to TiddlyWiki
Jan,

When wanting to include JavaScript in TiddlyWiki I think you will find the developer forum and various resources more useful.

  • This has being discussed many times and there are architectural reasons why this is not so strait forward. 
  • However many plugins come from js resources.
  • You may also find the git issues relate to this https://github.com/Jermolene/TiddlyWiki5/issues
I have a keen interest in geolocation and would appreciate some features in TiddlyWiki however I have another approach that may be simpler.

Let me know if you want to start a conversation on this.

Regards
Tony


Regards
Tony

SylvainComte

unread,
Jul 19, 2018, 6:38:44 AM7/19/18
to TiddlyWiki
Hello,

I made an attempt, that need some ironing and is still buggy. But it may help you to progress. You can find it on the leaflet branch of the leaflet map plugin repo :

cheers,

Sylvain
PS: Sylvain Naudin is not the author of this plugin. He's a very cool guy though...

Jan

unread,
Jul 19, 2018, 6:30:56 PM7/19/18
to tiddl...@googlegroups.com
Salut Sylvain,
I am happy to see you work on the plugin...though I could not get it to work yet.
How would you call the macro? Simply <<geoloc>>?
Is there a demo somewhere?

Merci beaucoup (... et pardon pour avoir confendu vos noms)

Jan
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

SylvainComte

unread,
Aug 16, 2018, 10:07:18 AM8/16/18
to TiddlyWiki
Well Jan,

sorry for the delay. I was having (great) vacations and was off the grid. For me a <<geoLoc>> should (almost) work. Beware of the uppercase "L".

cheers,

Sylvain

Jan

unread,
Aug 16, 2018, 2:49:11 PM8/16/18
to tiddl...@googlegroups.com
Salut Sylvain,
Great! I will check this out immediately. I will be giving a course at
the beginning of september where it woud be terrific if I could already
use this.
Yours Jan

Jan

Jan

unread,
Aug 19, 2018, 6:59:33 AM8/19/18
to tiddl...@googlegroups.com
Salut Sylvain,
I tried to get it to work on szenio.de/drehorte. On an iphone I get the button (on the normal computer I don't I guess this is because there i have my geolocation deactivated...)
But what exactly does it do? Or what do I have to do to get the geoloc into a field?

-Jan



Am 16.08.2018 um 16:07 schrieb SylvainComte:

SylvainComte

unread,
Aug 20, 2018, 4:36:07 AM8/20/18
to TiddlyWiki
Hello Jan,

I went to your szenio.de/drehorte page. The button was here. I clicked here and it "worked" (e.g. It added a "point" field with my coordinates in the GeoLocTest tiddler). But there are some issues : each time the tiddler is modified, the button is re-rendered. So if you click on the button and then give a five star rating to the tiddler, you will have three buttons! I'll have to see this.

cheers,

Sylvain

Jan

unread,
Aug 20, 2018, 6:50:49 AM8/20/18
to tiddl...@googlegroups.com
Salut Sylvain,
this is what i expected the button to do ... but when I open the Tiddler in Firefox or Safari on my Iphone after pressing the button, I cannot see the field "point" it created. I don't know why. It would be nice if the button could give feedback with a notification... and perhaps show the coordinates if the point is created.

(By the way: We should start a new thread and announce the new Addon correctly...for this one still shows Sylvain Naudin's name in the reference)

Yours Jan.

SylvainComte

unread,
Aug 21, 2018, 4:01:08 AM8/21/18
to TiddlyWiki
Hello Jan,

Outch! As you report this bug, I did some research about this functionality. And discovered that it will not work in most browser if the website is not over httpShttps://caniuse.com/#feat=geolocation

About notifications : why not? Just have to think it the lightest and most unobstrusive way. Since for me this macro should remain very light.

When I got time, I will create a demo on a https github page in order to check. But I'm a bit overwhelmed just now. Sorry for that.

greetings

Sylvain

Jan

unread,
Aug 23, 2018, 1:32:50 PM8/23/18
to tiddl...@googlegroups.com
Salut Sylvain,
after I managed to load my site via https your plugin works, great.
When you manage to get rid of the button-multiplication this is really worth publishing.
A great step forward for the leaflet environment.
Thanks a lot!
(If you have a server, I built a simple php script for uploading Tiddlers, I think I will build a version for uploading tiddlers with points. )

Yours Jan

Sylvain Naudin

unread,
Aug 24, 2018, 7:04:17 AM8/24/18
to TiddlyWiki


Le jeudi 19 juillet 2018 12:38:44 UTC+2, SylvainComte a écrit :

Sylvain
PS: Sylvain Naudin is not the author of this plugin. He's a very cool guy though...

:D

Yep, I just see the thread with my name ;-) Sorry Sylvain, but thank you for your kind words :)
Reply all
Reply to author
Forward
0 new messages