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.
    Dismiss Notice

Googlemaps Visualisation Heat Maps

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

  1. clivegarnham

    clivegarnham New Member

    Level: Community
    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: Community
    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: Community
    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
     
    xycofryx likes this.
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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: Community
    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
     
    xycofryx likes this.
  6. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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: Community
    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: Community
    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: Community
    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: Community
    (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)
     
  11. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    @clivegarnham - did you ever test this?

    The weighted heatmap seems to be working well for me.

    -- hugh
     
  12. clivegarnham

    clivegarnham New Member

    Level: Community
    Hi,

    Yes, I've tried it, without much success. I thought it might be a problem with my data as initially it looked like my weighting factor was in a text field, but changing it to numeric made no difference. The maps it produces look like the weighting factor is 1 for every data item. I started looking through your code to see if I could work out what the problem was, rather than asking for more of your time. However, if it is working for you perhaps I could see your test data, and compare that to mine to see if I can work out what the problem is?

    Thanks again for your time on this,

    Clive
     
  13. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    I'm using one of my standard map viz datasets, which is a list of US cities by state and ZIP. I've added a "weighting" field (and selected that in the map viz options as the weighting element) and just played around with changing the weightings by hand. I've filtered the list down to just zip codes in Providence, RI, which is a data set of 12 rows.

    So here's all weightings set to 1:

    View attachment 17100
    View attachment 17101

    Here's all weightings set to 10 (which I thought would look the same as all 1, but isn't):

    View attachment 17102
    View attachment 17103

    And here's the 10's, but with one set to 20 and one set to 30:

    View attachment 17104
    View attachment 17105

    -- hugh
     
  14. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    So it's definitely working, but the weighting numbers don't exactly behave like you might expect (which is down to Google, obviously). You might want to play around with a small dataset and tweaking numbers by hand, to see what kind of effect to expect.

    -- hugh
     

Share This Page