GoogleMap element - no location selected

sdavies68

Member
Hi,

I currently have a googlemap element defined. Its in a form which has two sql tables and groups associated with it. I have a googlemap element defined. I can get it to create a static map which has the location at 0,0 (even though the default is in Australia), but if I set it as a full map I get

"no location selected"
 
What do you get in form view?

Your settings are working on my site - but I can produce the same error message if setting the googlemaps element to NULL directly in the DB.

So is anything stored at all in the googlemap element?
Do you get JS errors on record save?

Fabrik needs a Joomla bootstrap template (BS2, like Protostar coming with Joomla).
 
We have our own bootstrap template.

I dont believe I get any JS errors.

I never save or edit the table its always a readonly details view. The table is generated from an external source. I am using the googlemap element to show the address on the map. The element in the DB will always be NULL. What should it be set to?
 
Ah. I don't think "geocode on load" works for detail view, only form view. In detail view, it'll just try and use the value in the database.

So you'll either need to edit and save each record by hand, which is obviously not realistic if you have lots of data, or data which changes frequently ... or ... try the 'geocode' Scheduled Task plugin. This plugin was designed specifically for situations like yours, where you are importing address data, and need to automatically geocode it, and fill in the map element data.

You'll need to do a github update if you haven't done one already, and "discover" the geocode cron plugin. The settings should be self explanatory.

-- hugh
 
Hi Hugh, Thanks for this, I sort worked that out from what troester side. I did an update yesterday and found the geocode cron, and though, why not use that.

But I cannot get the geocode working either. It just times out even on a batch = 1. the php maxtimeout error is recorded in the httpd logs.

I get nothing recorded in the #_fabrik_log
 
Its ok, it was just taking a very, very long time. I emptied the records out and had just 300 records (instead of 44,000) and it took a long time to complete.

Is there anyway this cron schedule can be run from a command line?
 
There was a couple of nasty issues which may or may not have been affecting you (depending whether you have any list joins) which I've fixed ...

https://github.com/Fabrik/fabrik/commit/630f03d5e68fc828cd576be436a514d8171ffa74

Note that Google will "tar pit" you after a certain number of geocode queries within a short period of time, so responses from their API will take longer and longer. And they do apply cutoff rate limits, where they will blacklist you for X minutes or hours if you run too many requests. I forget what the numbers are. So I usually set my batch limit to about 300 or so, and my delay to 200.

You *definitely* don't want to try and run 44,000 in one batch! I'd let it run in batches of a few hundred every ten minutes or so, and take a day to do it.

You can't run it from the command line, no. Either by hand with the Run button, or through the scheduled method. Note that the scheduled method relies on your site getting page loads on the front end. This stuff doesn't actually run out of 'cron', it runs as a plugin on a J! page load (right at the very end of processing after the content has been sent to the browser), so if there are no hits on the front end of your site, the cron tasks won't run.

-- hugh
 
Thanks Hugh. I had my batch set at 20 and it was running 4 hours with no result. If I deleted entries out of the address table and cut it from 44,000 to 300 it would run and geocode ok. But with the 44,000 entries it does not even get around to sending data off to google (I have a tcpdump running looking for the requests). I think the routing is trying to load the complete table first before attempting any geocoding as when I run it the cpu load on the server just goes through the roof and the memory just keeps climbing.

I have implemented the new code.

Regards

Stephen
 
I think the routing is trying to load the complete table first
Yes, in crons.php it's doing
Code:
                if ($plugin->requiresTableData())
                {
                    $thisListModel->setLimits(0, 0);
                    $nav = $thisListModel->getPagination(0, 0, 0);
so I assume it's resetting all limits.
You could
copy your list
add a prefilter googlemap ISNULL (assuming you only want to geocode empty ones)
+ (as long as nearly all googlemaps are NULL)
add prefilter to limit the rows (id > ... AND id <...)
use this list in the cron geocode

@Hugh: there seems to be an issue with HTML/URL encoded in the cron:
It's correctly geocoding "Bern" but not "Z?rich"
(it's ok with geocode in form view)
 
Oh yeah, sorry I wasn't thinking too clearly last night. Yeah, it is going to load up every row in the table (subject to pre-filters) even if you have a batch size set, and it's only going to process the batch count.

Notes to self / thinking out loud ...

I think I need to do a little more work on it. Cron plugins can disable automatic loading of the table, with the requiresTableData() method, which tells the main plugin model not to load it. Which is what this plugin did until last night, and I had some code which just did a manual query to load the main table, rather than calling the $listModel->getData() ... but that didn't load any joins, which was breaking the test I was doing, which used join/CDD for state/city ...

Anyway ... I think what I probably need to do is if the "geocode when ..." is not set to "always", i.e. if it's set to only process "empty" fields, handle the table loading inside the plugin itself, and make the batch size compulsory. Then I can do a query like "WHERE map_element IS NULL OR map_element = 'xxxxx' LIMIT y" (where xxxx is the defined default value and y is the batch size).

That way, the plugin could gradually work through an extremely large table, without selecting all the rows, and just processing the first X (batch size) empty rows on each run.

But if "always" is set for "geocode when", just let the main model select all rows, ad process all rows. It'd be up to the user to only do that on small tables.

-- hugh
 
Re the encoding, I just tried with a random address I got from Google maps ...

Brauerstrasse 102
8004 Z?rich
Switzerland

... and it correctly encoded that?

-- hugh
 
Yes, seems to be no issue after all.
"Schweiz, Z?rich" is ok.
"Z?rich, Schweiz" will be located somewhere in Netherlands - but I think this is Google. Still wondering why it is different in form view.
 
In form view, we are using the full Google Maps v3 Javascript API. In the cron job, we can't use that ('cos we're running from PHP on the server), so it uses the much more simple minded query string method, by simply hitting the URL ...

Code:
http://maps.googleapis.com/maps/api/geocode/json?address=Brauerstrasse%20102,8004%20Z?rich,Switzerland&sensor=false

... which returns a JSON document. If you copy and paste that URL, you'll see the response.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top