1. Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.

Googlemaps Visualisation Heat Maps

Discussion in 'Standard Support' started by clivegarnham, Mar 7, 2018.

  1. clivegarnham

    clivegarnham New Member

    Level: Standard
    Google Maps seem to allow 2 different ways to create heat maps: a JS API for client-side maps and Fusion Tables for server-generated heat maps. Is it possible it do either of these with the Fabrik Googlemaps visualisation? I want to show the greatest concentrations of a (large) number of locations, based on UK Postcode districts (i.e. the bit before the space).
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    Nope, not currently, although I'm always up for adding features to the map viz (I actually enjoy working on it, lol).

    Is your heat map data directly related to a Fabrik 'googlemap' element? So the lat/lon data for the heat map is contained in the map element?

    Do you need to display any actual map "pins", or just the heatmap?

    I can't make any promises, but depending on the answers to those questions, I may have a look at adding heatmap as an option, next time I need some Coding Fun.

    -- hugh
     
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    I couldn't resist. Turns out it was relatively easy to add heatmap as an option. Here's a snapshot of my "Cities in Rhode Island" map, as a heatmap:

    heatmap.png

    ... and here's the commit:

    https://github.com/Fabrik/fabrik/commit/64bf801c3a92bdbbfc6b68fa40c5437da15a17d2

    So do a full github update, and make sure you clear your browser cache (to pick up changes to the Javascript). The new heatmap option is a radio button in the Options tab.

    Of course, it'll only work if your data is in a googlemap element, same as if you were doing a normal map viz.

    If you need to convert your dataset from separate lat/lon fields to a Fabrik googlemap field (which uses the format "(lat,lon):zoom"), it's not too difficult to add a map element) to your form, and then run a query by hand (in phpMyAdmin or whatever) to set the data, like ...

    Code (Text):

    UPDATE yourtable SET mapfield = CONCAT('(', latfield, ',' lonfield . '):12');
     
    Replace table and field names as appropriate, and change 12 to whatever you want the default zoom level to be (in form/details view, doesn't effect the map viz).

    -- hugh
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    Another issue you may run in to with generating maps from very large datasets is slow loading. You can mitigate this by making sure the list you build the map from has only the absolutely essential elements published (id, map, and maybe the "Postcode" if you need to filter on that). This may mean copying the list, and in the copy, unpublish anything you don't need for the map viz, and build the viz on the copy.

    You can also set the "Defer loading" option, so rather than building the dataset during page load (and thus having a long wait before the page even loads at all), the page and (empty) map load, with a "loading spinner", and the map loads via AJAX.

    -- hugh
     
  5. clivegarnham

    clivegarnham New Member

    Level: Standard
    Hugh,

    That's great, thank you so much. Its almost exactly what I want!!!

    My data is organised so each row contains the postcode district, location, and a numeric weight or strength. Ideally I want the heat map to recognize the weight and show the heat of each location accordingly - the higher the number, the more heat that place has. I could denormalize the data (i.e. rather than 1 record with weight=3 I could have 3 records for the same postcode), but that would mean a table of ~250,000 records rather than 2,800. I'm pretty sure that the Google API can cope with this, so hopefully it shouldn't be too hard.

    Thanks again,
    Clive
     
  6. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    The API usage isn't a problem, it's the backend stuff ... need to add YAFO (Yet Another Option) to designate the weighting element, add that data from the list into the marker structure that gets handed to the Javascript, and modify the Javascript to add that data to the structure that gets passed to the API.

    I'll see if I have some "spare" time soon(ish).

    -- hugh
     
  7. clivegarnham

    clivegarnham New Member

    Level: Standard
    Hugh,

    Many thanks for your help with this, I guess you are still pretty busy at the moment. Is there any way I can help? Perhaps I could do some of the run-of-the-mill stuff for you? Adding another option can't be that hard, there must be other code in there that does something pretty similar, perhaps I could copy and change the necessary bits for you...?

    Thanks,
    Clive
     
  8. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    I'll take a look at it now. Had some Real Life stuff going on that ate into my coding time.

    -- hugh
     
  9. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    OK, try this:

    https://github.com/Fabrik/fabrik/commit/d09c7c0a6781991044a3e743a46b8ba500940698

    No, it's not hard - technically it's trivial. It's just time consuming adding and testing new options. And there's a very finite limit on the time I can invest in any given month for the cost of a sub. It's all too easy to get to the point where I could be earning more per hour wearing a paper hat and asking people if they want fries with that. :)

    -- hugh
     
  10. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    (as you can see from the time on my last two posts, it took 58 minutes ... so you can easily figure out my hourly rate on your sub this month, assuming you don't have any more issues I need to work on. I'm not trying to be an ass, just setting expectations of what a sub buys you)
     

Share This Page