On 28/10/2020 15:14, Benjamin Grassineau wrote:
Do you think it would be possible to add a geolocalisation function to
APE ? Or to create an independant function wich could be added by a
markup ? It would be yet very useful for my website.
Do you mean having an Openstreetmap automatically centered, or insert a
pin, over the visitor's location? (1)
Or do you want an editor to be able to add a pin while editing the
source text of the wiki page? (2)
Some hosting providers (e.g. OVH) have an ip2location module installed
on their servers and you can get an approximate latitude and longitude
in PHP from the $_SERVER array. It shouldn't be complicated to create a
custom markup, or a GUI button, that inserts the coordinates in an APE
definition list.
While this would be easy and automatic, there are 2 difficulties --
1. The coordinates may be incorrect or missing for some users -- for
example my home location doesn't show, but others do.
2. If you change hosting providers it may not work on the new service.
In fact, I've tried to do this with JavaScript but I did not arrived !
It's true that I am not very cumfortable with this language. I tried
to use the |getCurrentPosition()| method.
This would be the way to go for modern browsers, but it is done in 2
steps -- you first need to request location permissions from the
browser, and then if the visitor grants them you can request the
geographic coordinates. So depending on what you want to achieve (1) or
(2) above, it needs to be done differently. (1) needs to be implemented
in APE, (2) can be independent.
Here too it is not 100% reliable: the user may refuse to grant the
permissions, or the coordinates may be imprecise or incorrect, but this
as good as it gets.
Petko
_______________________________________________
pmwiki-users mailing list
pmwiki-users@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-users