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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

Mappable module and clusterer


Go to End


8 Posts   1202 Views

Avatar
wmk

Community Member, 87 Posts

7 September 2011 at 2:06am

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

Forum Moderator, 4102 Posts

9 September 2011 at 5:54am

Edited: 17/09/2011 9:00am

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

Community Member, 201 Posts

9 September 2011 at 10:05pm

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

Forum Moderator, 4102 Posts

13 September 2011 at 1:56am

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

Community Member, 201 Posts

13 September 2011 at 8:07pm

Edited: 14/09/2011 5:07am

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

Community Member, 201 Posts

15 September 2011 at 1:51am

Edited: 15/09/2011 1:58am

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

Forum Moderator, 4102 Posts

17 September 2011 at 9:01am

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

Community Member, 201 Posts

19 September 2011 at 9:38pm

Bloody marvellous,

cheers for that it all works and everything :o)

Mick.