Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Mappable module and clusterer


Reply

8 Posts   686 Views

Avatar
wmk

7 September 2011 at 2:06am Community Member, 45 Posts

Hi,

i just played around with uncle cheese's Mappable module - it's a great time saver. But trying to activate the clusterer i get a javascript error:

marker.getLatLng is not a function

I downloaded the code for markercluster.js and activated it via

$gmap->setClusterer(true, 100, 9, '/mysite/javascript/markerclusterer.js');

Any hints?

Avatar
UncleCheese

9 September 2011 at 5:54am (Last edited: 17 September 2011 9:00am), 4085 Posts

I might try removing the leading slash for one.. not sure if that will path right. Second, you might not be using the right clustered script. The one that I'm using is here: [REMOVED]

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
cumquat

9 September 2011 at 10:05pm Community Member, 198 Posts

Hi there guys,

can i ask how you are implementing the cluster function please.

It's something i would like to do, just not sure how to go about it. I got the mappable module working with help form UC and this will be my next step as i have quite a few clusters of markers in various towns and villages.

Regards

Mick

Avatar
UncleCheese

13 September 2011 at 1:56am 4085 Posts

You need to download the script in this thread and place it in your javascript dir, then just run the function you see above in cumquat's post..

$map = $yourDataObjectSet->GoogleMap($width, $height);
$map->setClusterer(true, 100, 9, 'path/to/clusterer.js');

I forget what all those arguments are.. you can look in the API to see what those are. I think the 9 is the zoom..

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
cumquat

13 September 2011 at 8:07pm (Last edited: 14 September 2011 5:07am), Community Member, 198 Posts

Hi ya,

Cheers for that, dumb question time,

Currently i run it with a very simple function that just brings back all the hospitals and police stations in a table with the code below,

public function Hospitals() {
      
      return DataObject::get("HospitalEx");
      
}

and then on my template page i just have

   $Hospitals.GoogleMap

and that works great, but i'm just not sure where to slip in the

$map->setClusterer(true, 100, 9, 'path/to/clusterer.js');


i've set the default size of the map in _config file with

GoogleMapUtil::set_map_size(980, 500);

Sorry if this is obvious to everyone else.

cheers

mick

Avatar
cumquat

15 September 2011 at 1:51am (Last edited: 15 September 2011 1:58am), Community Member, 198 Posts

Ok I'm further forward but i'm getting the same error as WMK

Error: a.getLatLng is not a function
Source File: http://awebsiteaddress/mysite/javascript/markerclusterer_packed.js
Line: 1


I'm using the file that UC linked to.

WMK did you get it working?

my current function is,

public function Hosp() {
   $HospitalEx = DataObject::get("HospitalEx");
   $map = $HospitalEx->GoogleMap(980, 600);
   $map->setClusterer(true, 100, 9, 'mysite/javascript/markerclusterer_packed.js');
   return $map;
   }

Mick

Avatar
UncleCheese

17 September 2011 at 9:01am 4085 Posts

Hi, guys,

I've fixed this in the latest commit. The clusterer.js is now included with the module, and that bug has been fixed. Just use $map->setClusterer(true);

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
cumquat

19 September 2011 at 9:38pm Community Member, 198 Posts

Bloody marvellous,

cheers for that it all works and everything :o)

Mick.