sylvainjule / kirby-locator Goto Github PK
View Code? Open in Web Editor NEWA simple map & geolocation field, built on top of open-source services and Mapbox. Kirby 3 and 4.
A simple map & geolocation field, built on top of open-source services and Mapbox. Kirby 3 and 4.
When I move the marker on the map the coordinates are saved in XX.XXX and YY.YYY format, with a comma as decimal separator and with Citation marks. When I locate an address, lat and lon are saved in XX.XXX and YY.YYY format without citations.
Hello,
I got an error when zooming on the map field before selecting a place.
To reproduce the error set true
so saveZoom
and autoSaveZoom
then zoom the map before picking a location : you will get an error Invalid LatLng object: (undefined, undefined)
.
Otherwise, it's a great plugin ;)
hey there,
would you be interested in eg a field method toLocationLink()
to get the openstreetmap node link for a given POI? or would that be something you don't deem necessary? I'd make an API call to nominatim's reverse
function and cache the result, that's about it ..
I'd provide a PR if it's of interest, just let me know the best way to pursue this (page method, field method, etc)
// Edit:
I propose storing osm_id
from the response you get from Nominatim, since it represents the Node ID being used in OpenStreetMap links, eg https://openstreetmap.org/node/OSM_ID
- that would save a call to the API using lat
/ lon
to get it ..
Cheers!
While you can already change the displayed information, the order is fixed. But for German clients I would rather like to display the number after the street. That's how we write it. And I guess some people would like to use a completely different order.
For this you would have to change the display.includes('address')
in your Locator.vue to a loop iterating over the display
array.
When I put marker on the map, I get lon and lat with dots, like: 58.529276, 1.449215, but when I search for location and save like it's found, output is with comma for one or both, like: 58,529276, 1.449215
First of all thank you for this wonderful plugin.
I'm not sure this is really an issue, but by setting geocoding: mapbox
the latitude and longitude values are returned by the toLocation
method with a comma and not with a dot.
Nominatim:
<?= $location->lat() ?> // 41.894802
Mapbox:
<?= $location->lat() ?> // 41,894802
This difference can cause some problems in the frontend implementation of the map.
—
In the content folder the values lat
and lon
are stored differently between mapbox
and nominatim
.
Nominatim geocoding:
Map:
lat: "41.894802"
lon: "12.4853384"
city: Roma
country: Italia
Mapbox geocoding:
Map:
lat: 41.894802
lon: 12.4853384
city: Roma
country: Italia
For Mapbox only, doesn't suit Nominatim's usage policy.
increase version to 1.x to avoid strict semantic versioning:
https://getcomposer.org/doc/articles/versions.md#caret-version-range-
otherwise upgrading will be much harder for users.
so 0.5.0
will not upgrade to 0.6.0
.
For pre-1.0 versions it also acts with safety in mind and treats ^0.3 as >=0.3.0 <0.4.0
Thank you for this great plugin!
Would it be possible to also get the state names returned from Mapbox?
In my specific situation I'm trying to differentiate between cities of the same name in the same country, such as
Hi Sylvain,
i'm stumbling above another inconsistency in the data of openstreetmaps – an address in Berlin lacks the address.city
field and Berlin is returned as the address.state
which makes sense because its a federal city state in germany 🙈
what do you think is a good fix for this? adding state
as another fallback https://github.com/sylvainjule/kirby-locator/blob/master/src/field/Locator.vue#L336
I would love if the zoom factor gets stored as well, so I can choose the right one in the Panel that I want to replicate on the front-end.
Marker don't show up in my locator fields!
Hello Sylvain :)
In the panel, Mapbox tiles can't be loaded when using a "non public" token.
This is because the Kirby panel (since 3.4) blocks the referrer header (here).
I don't know if this should be an issue with Locator, the Kirby panel or Leaflet.
Locator could circumvent this issue by overriding the meta tag, with something like:
document.querySelector("meta[name=referrer]").content = "origin";
Kirby could solve this by using a less strict referrer policy. Something like "origin" or "no-referrer-when-downgrade"...
Leaflet could solve this by adding a referrer policy to their tiles. Actually they did this a few days ago, but considering their last "release" was in september 2020, I don't know how long it will take to get this option in a stable version...
I will crosspost an issue also on Kirby, and then link here.
Hello,
Thank you very much for this plugin. I’m struggling to have it set up with my blueprints:
composer require sylvainjule/locator
fields
: mymap:
type: locator
tiles: wikimedia
I’d expect this to add locator field in the panel but I get The field type "mymap" does not exist
. Am I doing something wrong?
I've been using this plugin for a handful of sites that include, in some way or another, a collection of multiple pages with locator fields. In the frontend, all pages are output as a set of markers on a full-screen map, each having a popup or linking to a page etc.
I'd like to suggest building an "all locations"-view as an optional panel section. This could display multiple markers on a large map, each marker linking to the respective page in the panel. I know it will come in handy at least for my current/upcoming projects.
Is this something you would consider building/reviewing a pull request for? I'll be working on at least one or two map sites this year, so these projects could justify helping out with such an addition to this plugin.
without a release at github it can not be easily installed from packagist afaik.
Hello @sylvainjule ,
After a clean install of kirby-webpack, I tried to install your plugin, but have this message:
The locator field is missing. Please add it to your installed fields or remove it from your blueprint
Here is my blueprint:
title: Step
preset: page
pages: false
fields:
map:
label: Location
type: locator
Don't understand what's going on....
Thanks for your help!
Hi,
please follow the kirby composer instructions
Both the type field and the getkirby/composer-installer dependency are required for your plugin to work, otherwise it won't be loaded correctly by Kirby.
The setup with a separate config.php file for Composer is no longer recommended as it can cause issues with the autoloading order. If you put your code directly into the index.php file and don't autoload it with Composer, Kirby will pick it up just fine.
https://getkirby.com/docs/guide/plugins/plugin-setup-basic#the-composer-json
Also what's the purpose of adding the vendor
dir to git?
Hello,
I installed the last version of locator and an error message keeps popping in kirby's panel:
"The field type "wathever" does not exist"
I tried to change the field name and the massage still is the same, with the new name between the quotation marks.
Here is a screenshot of the setup:
Normally everything should be fine but as I am learning coding, it could be my mistake...
Thank you for your work, it would be great if locator was integrated in kirby, it seems an essential function to me.
how do i remove a set location having entered one and deciding to have none?
Collapsing should probably disable interactions
In case this is possible from the data we can gather from the geolocation apis, it would be cool to include the country code in the data. This would allow showing a translated country name in the frontend by passing the country code to PHP internals, e.g. Locale::getDisplayRegion
.
When using Nomatim I had a strange bug that for some locations an address wouldn't be found while still returning house numbers and the location itself correctly. Some digging let me tho this line:
kirby-locator/src/field/Locator.vue
Line 452 in f2f94f0
In my case the location was actually at a (market) square so naturally the resonse address wasn't a road.
To fix this I suggest you change the line to:
'address': response.address.road ?? response.address.road ?? response.address.square,
So if no road is found the square will be used.
Cheers for the great plugin I thought it might be useful to anyone else struggling with this issue ✌️
In case search isn't precise enough.
Map (and pointer) is not draggable in Firefox on Windows10. Works in Chrome though.
I was wondering if there is any way to simply drop a pin on the map? It's somewhat related to #33 as we need to locate items that are not going to be easily geocoded. The workaround is to currently search for something in the vicinity and then drag the marker to the appropriate location.
(Thank you for this wonderful plugin!)
In the readme where the terms of services for the different tile services are listed, positron and voyager seem to have the same link. Also, this link doesn't point to the terms of services.
As I don't know any of those services (also couldn't find voyager by searching) I can't really contribute and fix the link myself. Positron also seems to link to "carto", which I'm not even sure if this is correct.
Would it be possible to have the option to display only the map, without the area that contains the lat/lng or other data?
I tried passing false
to the display
option, but in that case the map is just a few pixels high.
The address
is hidden, no matter if I add it to the display
list or display all as the default.
I think I found the mistake, though: https://github.com/sylvainjule/kirby-locator/blob/master/src/field/Locator.vue#L33-L36
You check if the display
list includes addressdetails
instead of just address
.
I used to have the State stored in our project data at nehforall.org, but now I see this plugin doesn't return the state by default. Is there a way to turn that data on? We really need it for our svg state icons.
Hi! I tried to install it with composer require sylvainjule/locator
on dev-master 3.0.0-beta-6.17
.
But I get this error:
[InvalidArgumentException]
Could not find a matching version of package sylvainjule/locator. Check the package spelling, your version constrai
nt and that the package is available in a stability which matches your minimum-stability (beta).
When used in a Structure Field, the options settings don't seem to work
locations:
label: Locations
type: structure
fields:
coordinates:
label: Location
type: locator
draggable: false # <- Still draggable
Does also not work, if I set the options globally in the config file.
Hey, thank you for the nice plugin. I was wondering if there is a way to enter latitude longitude directly. This would be very helpful if the geolocation does not work for whatever reason and dragging the map is not an option.
It would be handy to have an option to hide the map after the location has been assigned. It takes up quite a bit of room and is only needed the first time you use the field.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.