Googlemap coordinates from another element

Opusxc

New Member
I am a newby to Fabrik (and not technical) and am struggling to figure a way to get this to work ...

I have a list (_locations) in which I have the Googlemap plugin and that works great. I have have another list (_assets) which I have linked (dbjoin) to the location.

What I would like to do now is show the googlemap in the _assets forms and list but cant see how when I add the googlemap plugin into _assets to get the map coordinates from _locations.

Thanks for any help you can provide !
 
You'll need to pull the data in from _locations with an "autofill" form plugin. That isn't part of the core, so you'll either need to "discover" it in the J! extension manager (if you've ever done a full github update, which will have put the code there but not installed it), or download it from our downloads area and install the ZIP.

Then create a map element on your _assets form.

Then add the autofill plugin to the _assets form, and set:

List: _locations
Lookup field: id (or whatever the primary key is on that table)
Field to observe: location (or whatever the join element you have for the location is called)
Map data: {"_locations___map":"_assets___map"}

Change the full element names in the map data to match your _locations and _assets element names.

And probably set "autofill confirmation" and "autofill on load" to No in the options tab. Don't change any of the other options.

Then when you select anything from the locations join on the _assets form, the autofill plugin will make an AJAX call to the server, retrieve the map data and insert it into the assets map element. The map element will detect the change, and automatically update.

BTW - it's a good idea to NOT use _ as the first or last character in table or element names. It won't actually break anything as the first character of a table name, but it will break things if it's the last character of the table or the first character of an element name. So you are OK, but best to just avoid using _ as a prefix or suffix.

-- hugh
 
Hi Hugh,

Thank you so much for the help. BTW all my tables (and hence elements) are prefixed with "oxic".

I have given it a go and while the map shows, it is not getting the correct coordinates from the _map element when I edit an existing record or create a new one.

Could this be because on the _assets_locations element I use a cascadingdropdown plugin (not a databasejoin) ?

My structure looks like this:

List: _sites
Elements: _id, _site

List: _locations
Elements: _id, _site (databasejoin on _sites), _location, _map

List: _assets
Elements: _id, _site, _location, _map
Element plugins:
_site = databasejoin
_location = cascadingdropdown (on _site + _location)

Form: _assets
Plugin : autofill
Lookup list = _locations
Lookup field = _location (in _locations)
Field to observe = _location (in _assets)
Map data = {"oxic_locations___map":"oxic_assets____location_map"}

Again, many thanks.
 
No, the "lookup field" needs to be 'id'

Lookup field: id (or whatever the primary key is on that table)

And the 'value' of your 'location' CDD on the assets form needs to be 'id' as well.

-- hugh
 
Sorry, did not explain correctly ...

The Lookup field in _locations is the "id" and the value being stored in the CCD is also the "id". If I look at the data in the two tables for the test record, they both have a value of "1".)

Still only showing the "default" map which is setup in the googlemap element ... so not finding the
 
In which case, I dunno. Works for me. I set up a quick test case before answering the question. If you'd like to take out a support sub, I can log in to your site and take a look.

Sent from my HTC6545LVW using Tapatalk
 
Looks like I'll need a front end user for testing, as you have things like WHERE clauses on your join element for {$my->id}, so I see nothing in the "sites" join, etc.

But loading an existing "Asset Records Search" row, if I change the "Location" from "Garden A" to "Garden C", the map definitely changes, the marker moves a couple of gardens over.

-- hugh
 
If you run the asset search form in the backend and change the location, then the map and pin does change. But it does not seem to be happening anywhere on the front end ... there is a public facing (no need to login) search here ... https://opusxc.opusxenta.com/d-search ... which if you search for "s" it will show 3 records which you can see in the backend as well but in the front end the map is not the same as in the backend.

Thanks
 
Another thing to consider ... in the backend if you open the "Asset Search" form, then if you edit a record and change the location the map is correct but if you just view the record it does not show the correct map.
 
*sigh*

OK, I banged my head on this for about 2 hours. Finally figured it out.

You had set the map element on that form to "Save in database: NO". So editing and saving the records wasn't actually saving the map data.

Maybe you were relying on "autofill on load" to work for the details view, but it won't, for several reasons. Mostly because in details view, you only have the "read only" data for the other elements. So for example, the "location" join will only have the label ("Northern"), not the value ('3'). So the autofill won't work. And also, it kinda pointless doing autofills in details view. Just use the stored values.

So, I turned off autofill on load, and set the map element back to record in database. Re-saved the 3 records to force the map element to update. And hey presto, it works.

It'd be appreciated if you could bump up to Pro support for a while. That really chewed up a lot of time, and was way above and beyond what I'd usually do for Standard support. But it was annoying me that I couldn't figure it out, so I got stubborn about it, lol.

-- hugh
 
Thanks Hugh, that works. I was trying not to rely on ACL to stop a user from saving a record in the "view" function so turned off the "save to DB".

Will bump the subscription up.

Would like to chat about project work ... can we go out of the forum for this ?

Regards
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top