• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

help with map display

loudy

Member
Is that possible to create a map to display the location for members based on colors?

I have 300 records with postal codes, as the following:
example
ID - Name - city - Postal code - team
22 - John Mac - London - T23E1 - Team 1
23 - Mark S. - London - T54E5 - Team 2

So if the person from team one the map marker will be the default red color, but if the person belongs to Team 2 the map marker will be Yellow.

As result when we look at the map we will know by visual how many members of the teams located in each area.

Please help.

Thanks,
 
Yes, use the "Media Icon" feature, where you specify an element that stores the path of an icon to use for the map pin, and set the "Media Path" to suit where you are storing them.

So (say) set path to "media relative" (so your path is relative to the ./media folder) you'd have values like /map_images/team_1.png, etc.

You could create those paths by using a calc element that does something like ...

Code:
return '/map_images/' . FabrikString::clean('{yourtable___teamname}') . '.png';

The clean() helper function returns a version of the string with all non alphanumeric characters changed to underscores, in lower case ... so "Team 1" would be converted to "team_1".

Then use your image editor of choice to make copies of the standard map pin, and change the color.

-- hugh
 
Hi cheesegrits, I'm getting empty map.

so here is my steps:
I created new lists:
List 1) Cities

and I added all the cities

List 2)
Client types:
team 1 called: psr
team 2 called: gar

List 3)
2016 clients:
Name
Postal Code
client type: data joint
city: data joint

then I added: in the forms: calc element to the main list as well google map.
I added the following lines:
return '/map_images/' . FabrikString::clean('{2016_clients___psr}') . '.png';
return '/map_images/' . FabrikString::clean('{2016_clients___gar}') . '.png';

then I added the following to the folder:
media/map_images/gar.png
media/map_images/psr.png

Is that possible to check please, and help me out to sort this.
 
OK, several problems.

Your map element wasn't set to anything for your example forms. I set those to random locations in England.

You hadn't selected the element to use as the "Data Icon" in the viz settings.

Your calc can only return a single value, you can't return multiple values.

Your don't have any elements called {2016_clients___psr} or {2016_clients___gar}. As I said, that needs to be the full name of the element that has the "team name", which I think is 2016_clients___type. So I set you calc to be ...

Code:
return '/map_images/' . FabrikString::clean('{2016_clients___type}') . '.png';

... which seems to work, as it's now showing psr.png and gar.png as the values on your list.

And lastly, as per the tooltip on the "Media Path", that's actually relative to /media/com_fabrik/images, not just /media. My bad, I got that wrong in my first response.

So ... I've fixed most of that, I just can't get at your images to move them to the right location (move your map_images folder into media/com_fabrik/images). Then they should show on the map.

-- hugh
 
great thank you,
I have imported my data and I adjusted the default location to Calgary, Canada
but for somehow all my locations shows as one map pin. not sure why it's not showing as 2 colors and it doesn't render the location of the postal code.

Please can you help
 
You have one pin because all your map lat/lon values are the same:

51.05011-114.08529

... which is in the Bow River by the 10th St bridge. And the Google maps API doesn't allow multiple markers with the same exact lat/lon.

You need to geolocate your map element to the actual PO Code.

However, there is a slight problem in trying to do that with your elements, as you are using a join for the City. Which means the JavaScript will get the id, like 7, instead of the name, Calgary. I'm working on a solution for that, but for now you'll have to do it long hand, by setting Geocode to just "Yes", then typing in "Brooks, T1R 1A7, Canada" and hitting Geocode.

I've done the first four or five on the list, and they now show up correctly on the map.
 
In your cron plugin settings for the geocode, you had specified the "Map Element" as you post code element, not the map element.

I set that as the map element, and ran it twice, set to a batch limit of 20, it seems to have encoded correctly.

I think you have still have some postcodes that are coming back as the same lat lon, you need to check that.

-- hugh
 
not sure as I see some postcodes lat and long created as duplicated even the postal codes are different.
also when I run the cron plugin manually I do not think it render. as I got 0 records updated.
 
You'll need to make sure your un-geocoded map elements are either empty, or their value exactly matches the "Empty value" in the plugin settings.

Have a look with phpMyAdmin (or whatever) and check to see what your default is for the ones that haven't been geocoded yet.

-- hugh
 
I have empty the list, and I re-imported the data again, now all the post code match the "empty value" in the plugin setting.

Should I just keep running the cron pluing, till all the geo codes get corrected.

Sorry for the trouble in this. :(
 

Attachments

  • sample.PNG
    sample.PNG
    150.8 KB · Views: 192
Last edited:
Ah, I see the problem.

OK, you'll need to update this file:

https://github.com/Fabrik/fabrik/commit/280e1725833d42351af310eb126c83a8cf21355b

Unfortunately we just missed the 3.5.2 release, so you'll have to do a github update after updating to 3.5.2.

Or you could just save this file:

https://raw.githubusercontent.com/F...1355b/plugins/fabrik_cron/geocode/geocode.php

... and upload it to ./plugins/fabrk_cron/geocode AFTER doing a 3.5.2 update (on all Fabrik plugins).

I don't usually recommend cherry picking files, but this should be safe.

-- hugh
 
Great thank you, the cron task worked, I have almost 738 records, only 638 records that are working now and displaying on the map:
the reset still not rendering. when I run the cron task it says 0 records updated:
all the remaining records a the post codes match the "empty value" in the plugin setting:
51.042736 -114.087087

Any idea ?
 
I think I figure out the issue,
when I imported the postal codes I imported as: N6B2E4
and it was rendering fine for all 638 postal coeds.

the remaining postal codes need space so if I add it as: B5E 3U8
it renders now.

Not sure why, and what is the best way to import the postal codes with or without space?

Please help
 
I have no idea. That's entirely up to Google. We just provide Google with the address data you gave us, they hand back a result or an error code. If it's an error code (they can't find the address), we just ignore it, and move on.

-- hugh
 
BTW, if you enable logging on the plugin, then look in the #__fabrik_log database (with phpyAdmin, or whatever), you'll see a 'plg.cron.geocode.information' log entry for any failed geocode attempt, which should give you the error Google respond with..

-- hugh
 
I see, actually, I tried to find the latitude & longitude for the postal codes without space, and I did not get any results in http://www.latlong.net/

when I added the space for those postal codes it works fine, so it seems the issues are from the postal codes itself.

Thank you for all your help and directions,

Have a great weekend.
 
BTW, your map is going to take quite a long time to load with 700+ markers. You have probably noticed that your page takes a long time to display anything. I just enabled "Defer Loading", under the "AJAX" options for that map. What that does is loads the page with an empty map, so the page shows up immediately, then kicks off an AJAX refresh off the map. So instead of a blank page for 20 seconds or so, you have a map with an AJAX loading spinner.

You can always turn that off if you want, but this is the exact scenario I added that option a month or so ago for.

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

Thank you.

Members online

Back
Top