# Kirby Geo Plugin

**URL:** <https://forum.getkirby.com/t/kirby-geo-plugin/3510>\
**Category:** Plugins\
**Created:** [March 4, 2016, 12:39pm UTC](https://forum.getkirby.com/t/kirby-geo-plugin/3510 "2016-03-04T12:39:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bastianallgeier](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bastianallgeier/32/7569_2.png) [@bastianallgeier](https://forum.getkirby.com/u/bastianallgeier)\
**Post date:** [March 4, 2016, 12:39pm UTC](https://forum.getkirby.com/t/kirby-geo-plugin/3510/1 "2016-03-04T12:39:41Z")

</div>

Hey,

for a client project I had to do all sorts of geolocation based tasks. I wanted to put the result into a plugin for quite a while and now it’s available:

[https://github.com/getkirby-plugins/geo-plugin](https://github.com/getkirby-plugins/geo-plugin)

It gives you some nice methods to work with geo points, calculate distances and run geolocation queries against the Google Geo Locator.

It also adds radius filters to all collections, which can be used to search for pages/files around a certain location.

It’s already compatible with the Kirby CLI, so if you got the CLI running you can simply install it with:

```auto
kirby plugin:install geo-plugin

```

I hope you like it!

---

<div class="post-metadata">

**Author:** ![jenstornell](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jenstornell/32/546_2.png) [@jenstornell](https://forum.getkirby.com/u/jenstornell)\
**Post date:** [March 4, 2016, 3:26pm UTC](https://forum.getkirby.com/t/kirby-geo-plugin/3510/2 "2016-03-04T15:26:22Z")

</div>

Nice! This opens up some new possibilities. It just gave me an idea of a panel field/tool.

**In the panel on a page there can be 3 fields:**

(not a blueprint, just a sketch, instead of an image)

```auto
Locate target 1: [input text]
Locate target 2: [input text]
Distance: [info] (visible if exists)

```

When losing focus from `target1` or `target2`, get distance with ajax and add it to the `distance` part of field. All 3 fields could be saved. Then the `distance` field would be “cached” until next ajax fetch.

With it you would don’t need lat, long to get distances between two points.

---

<div class="post-metadata">

**Author:** ![bastianallgeier](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/bastianallgeier/32/7569_2.png) [@bastianallgeier](https://forum.getkirby.com/u/bastianallgeier)\
**Post date:** [March 4, 2016, 4:04pm UTC](https://forum.getkirby.com/t/kirby-geo-plugin/3510/3 "2016-03-04T16:04:19Z")

</div>

To calculate the distance between two points isn’t too performance-hungry. The real performance hog is the geo locator. But it’s still a nice idea.

---

<div class="post-metadata">

**Author:** ![afincato](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/afincato/32/3446_2.png) [@afincato](https://forum.getkirby.com/u/afincato)\
**Post date:** [March 13, 2017, 4:07pm UTC](https://forum.getkirby.com/t/kirby-geo-plugin/3510/4 "2017-03-13T16:07:16Z")

</div>

Nice plugin!

The only problem: why is a comma used to separate `lat()` and `lng()` values?

Eg. `46,4958286, 11,3523424` instead of `46.4958286, 11.3523424`, which are the actual values present in the `json` file fetched from the Google APIs.

I went through the plugin to see where this was happening, but could not find anything.

I am now doing a `str_replace` to adjust this, but would be curious to know what is the reason behind it.

---

<div class="post-metadata">

**Author:** ![afincato](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/afincato/32/3446_2.png) [@afincato](https://forum.getkirby.com/u/afincato)\
**Post date:** [August 8, 2017, 9:49am UTC](https://forum.getkirby.com/t/kirby-geo-plugin/3510/5 "2017-08-08T09:49:37Z")

</div>

There seems to be a problem when using the `geo::locate()` command.

I opened an [issue here](https://github.com/getkirby-plugins/geo-plugin/issues/2).

Strangely enough, using google maps’ API gives a good result back, see — [https://maps.googleapis.com/maps/api/geocode/json?address=Mannheim,%20Germany](https://maps.googleapis.com/maps/api/geocode/json?address=Mannheim,%20Germany)

Probably google updated maps’ API?

---

<div class="post-metadata">

**Author:** ![jimbobrjames](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jimbobrjames/32/5802_2.png) [@jimbobrjames](https://forum.getkirby.com/u/jimbobrjames)\
**Post date:** [August 8, 2017, 4:21pm UTC](https://forum.getkirby.com/t/kirby-geo-plugin/3510/6 "2017-08-08T16:21:18Z")

</div>

Just a hunch, but is this a localisation issue? What language/timezone is your sever? Some countries use a , instead of a . for numbering. Explains why you cant find it in the code if its being done dynamically according to locale. It’s not a comma separator, i think its actually decimal character. Just a hunch, I’ve not used other languages before.

---

<div class="post-metadata">

**Author:** ![arphie](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/arphie/32/4984_2.png) [@arphie](https://forum.getkirby.com/u/arphie)\
**Post date:** [January 12, 2018, 6:09am UTC](https://forum.getkirby.com/t/kirby-geo-plugin/3510/7 "2018-01-12T06:09:41Z")

</div>

Hi,

i am currently using the plugin ( on my localhost). i want to get the distance from point A to B. point A is from the user and point B is from the database.

1. problem is that when ever i request something (over ajax), 7/10 request returns 500 error from the plugin.
2. when ever i use the geo class, the request takes too long to return a result.

please help 🙂 thanks

---

<div class="post-metadata">

**Author:** ![luxlogica](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/luxlogica/32/437_2.png) [@luxlogica](https://forum.getkirby.com/u/luxlogica)\
**Post date:** [January 17, 2018, 5:15am UTC](https://forum.getkirby.com/t/kirby-geo-plugin/3510/8 "2018-01-17T05:15:38Z")

</div>

@arphie I’m not sure I understand your issue - there seem to be too many areas where things could be going wrong, which may have nothing to do with the plugin. For instance: your problem (1) could be simply an issue with your ajax code. Similarly, the issue on point (2) could be related to your database or query code.

Would you be able to post examples of your code, so someone can try to help you troubleshoot?
