AugustMiller / kirby-map-field

đź—ş An easy way to use maps and location data in Kirby.
MIT License
41 stars 4 forks source link

Loading /maps/keys error on localhost #13

Open fourpixels opened 7 years ago

fourpixels commented 7 years ago

Hey there, Great job on the plugin - works like a charm!

I just have one problem - when trying to run it, I was having an issue that the javascript was trying to load /maps/keys via ajax:

https://github.com/AugustMiller/kirby-map-field/blob/master/fields/map/assets/js/map.js#L41

Can't we have some kind of dynamic injection of site base url? I will create a vhost, but it's still strange, as /maps/keys/ might be used by something else.

Any ideas?

AugustMiller commented 7 years ago

Ah, right—this doesn't accommodate a pretty common use case, which is running the site in a subfolder.

I'll look into attaching the key to the map element itself. Not sure what prompted the route + ajax method in the first place!

Thanks for flagging.

fourpixels commented 7 years ago

Hey, I already found the way you structure the data passed to the html. And because I needed a reverse geocoding (getting address after user has dragged the ping) I think I can prepare two PRs for that ;)

AugustMiller commented 7 years ago

I think what you're describing in your most recent comment is a separate issue?

Reverse-geocoding is a great idea—it'll be important not to clobber the text entered in the search field (and/or trigger an infinite loop), but we could add a second field below (along with lat / lng) that shows the reverse-geocoded street address, or a simply-formatted version thereof. Storage of the various "parts" that Google sends is a bigger challenge, but I'm curious what your ideas are!

One thing I've wanted to do for ages (semi-related) is basically capture that entire location response and all the various "parts," and store those into a big Yaml object. The main problem here is how to render that data into the admin—it's often unpredictable (addresses differ by country), so there would need to be a variety of "templates" so to speak, for each format.