Jeff VIP
Total posts: 745
01 Oct 2013 06:44

Hi,

After posting a request here, I'm happy to share my new geo field input template as a gift to the Cobalt community

https://s3.amazonaws.com/adwsfiles/zip/2013-10/geocomplete.zip

It uses the jQuery Geocoding and Places Autocomplete Plugin which you can find here: http://ubilabs.github.io/geocomplete/

Bear in mind that I am not a programmer and that it has been customized to my needs. I also commented out some code which I didn't need. There is no map display here neither.

Examples

After clicking on Show full address

Instructions

  1. Copy/extract the zip file to /components/com_cobalt/fields/geo/tmpl/input (I have included the normal and minified versions of geocomplete.js)

  2. Select the geocomplete template in the geo field settings

  3. Done!

Issues/improvements

There are some issues though which I couldn't solve

  1. The Google API and the geocomplete.js are included with each geo field. If you have multiple geo fields it still works but the API and js will be called multiple times, which according to Google might give some unpredictable results.

  2. I would like to have a "Detect my location button" but I don't know if that's possible.

If you wish to improve the code, just add your modified files here and share it with us.

Best regards,

Jeff

Last Modified: 02 Mar 2014

Comments have been disabled for this article and works only in read only mode.

Sergey
Total posts: 13,748
01 Oct 2013 07:10

I cannot find this file. PLease reupload.


Sergey
Total posts: 13,748
01 Oct 2013 07:45
  1. next version places will be loaded by deafult you will not need this
  1. Instead of this

You may use PHP

JFactory::getDocument()->addScript(JURI::root(TRUE) . "/components/com_cobalt/fields/geo/tmpl/input/jquery.geocomplete.min.js")

Then it will be added only once into

And i failed test. After I save record marker gets away. Or is it intended without markers and positions?

Anyway I'll use this script in filters and in input form too later.


Jeff VIP
Total posts: 745
01 Oct 2013 07:52

Sergey

And i failed test. After I save record marker gets away. Or is it intended without markers and positions?

This template is intended to simplify input and is without a map display and thus without markers and positions.

It should save all geo location attributes/fields though. You can check it by clicking on "Show full address" under the input field in the form.


Jeff VIP
Total posts: 745
01 Oct 2013 07:58

Please don't forget to activate the address fields you need in the field settings:

Otherwise no data will be saved


Jeff VIP
Total posts: 745
01 Oct 2013 08:03

Sergey

  1. next version places will be loaded by deafult you will not need this

Thank you. I know that only places needs to be added to Cobalt's default Google API call

Sergey

  1. next version places will be loaded by deafult you will not need this

Sergey

  1. Instead of this

You may use PHP

JFactory::getDocument()->addScript(JURI::root(TRUE) . "/components/com_cobalt/fields/geo/tmpl/input/jquery.geocomplete.min.js")

Do you mean replace in the template file?


pepperstreet VIP
Total posts: 3,837
01 Oct 2013 18:11

Following... :)


Jeff VIP
Total posts: 745
01 Oct 2013 19:58

Sergey

2 - yes. Add my example in the head of template.

Yep, it works :)


Jeff VIP
Total posts: 745
01 Oct 2013 20:28

Sergey

Anyway I'll use this script in filters and in input form too later.

In filters too? Does that mean it will only predict places that are stored with the records?

That would be pretty amazing.


Sergey
Total posts: 13,748
01 Oct 2013 23:44

In filters too? Does that mean it will only predict places that are stored with the records?

That would be pretty amazing.

This is for finding initial position for distant search.

Powered by Cobalt