Skip to content
Snippets Groups Projects
Commit 39bba520 authored by Brandon Bergren's avatar Brandon Bergren
Browse files

Fix #656406: Add support for MarkerClusterer.

parent a4f5d5e9
No related branches found
Tags 6.x-2.0-beta1
No related merge requests found
......@@ -284,6 +284,9 @@ function gmap_admin_settings(&$form_state) {
if (!isset($opts['markermanager']) || !is_array($opts['markermanager'])) {
$opts['markermanager'] = array();
}
if (!isset($opts['markerclusterer']) || !is_array($opts['markerclusterer'])) {
$opts['markerclusterer'] = array();
}
if (!isset($opts['clusterer']) || !is_array($opts['clusterer'])) {
$opts['clusterer'] = array();
}
......@@ -311,6 +314,13 @@ function gmap_admin_settings(&$form_state) {
'markerMinZoom' => 4,
'markerMaxZoom' => 0,
), $opts['markermanager']);
$opts['markerclusterer'] = array_merge(array(
'filename' => 'markerclusterer_packed.js',
'gridSize' => 60,
'maxZoom' => 17,
// @@@ Some way of representing MarkerStyleOptions?
), $opts['markerclusterer']);
$opts['clusterer'] = array_merge(array(
'filename' => 'Clusterer2.js',
......@@ -343,7 +353,8 @@ function gmap_admin_settings(&$form_state) {
'#options' => array(
'gmap' => t('No manager (use GMap API directly)'),
'gmarkermanager' => t("Google's GMarkerManager"),
'markermanager' => t('Gmaps Utility Library MarkerManager'),
'markermanager' => t('GMaps Utility Library MarkerManager'),
'markerclusterer' => t('GMaps Utility Library MarkerClusterer'),
'clusterer' => t("Jef Poskanzer's Clusterer"),
'clustermarker' => t("Martin Pearman's ClusterMarker"),
),
......@@ -411,7 +422,7 @@ function gmap_admin_settings(&$form_state) {
'#parents' => array('gmap_markermanager', 'gmarkermanager', 'markerMaxZoom'),
);
// Gmaps Utility Library -- MarkerManager
// GMaps Utility Library -- MarkerManager
$form['gmap_markermanager']['markermanager'] = array(
'#type' => 'fieldset',
'#title' => t('MarkerManager settings'),
......@@ -469,6 +480,36 @@ function gmap_admin_settings(&$form_state) {
'#parents' => array('gmap_markermanager', 'markermanager', 'markerMaxZoom'),
);
// GMaps Utility Library -- MarkerClusterer
$form['gmap_markermanager']['markerclusterer'] = array(
'#type' => 'fieldset',
'#title' => t('MarkerClusterer settings'),
'#description' => t('MarkerClusterer creates and manages per-zoom-level clusters for large amounts of markers (hundreds or thousands.) To use, you must download it from <a href="@url">here</a> and place it in the <em>thirdparty</em> folder.', array('@url' => 'http://gmaps-utility-library-dev.googlecode.com/svn/tags/markerclusterer/1.0/src/')),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['gmap_markermanager']['markerclusterer']['filename'] = array(
'#type' => 'textfield',
'#title' => t('Filename'),
'#description' => t('Name of downloaded file in the thirdparty folder. Default: %default', array('%default' => 'markerclusterer_packed.js')),
'#default_value' => $opts['markerclusterer']['filename'],
);
$form['gmap_markermanager']['markerclusterer']['gridSize'] = array(
'#type' => 'textfield',
'#title' => t('Grid Size'),
'#description' => t('The grid size of a cluster in pixels. Each cluster will be a square. If you want the algorithm to run faster, you can set this value larger.'),
'#size' => 4,
'#maxlength' => 4,
'#default_value' => $opts['markerclusterer']['gridSize'],
);
$form['gmap_markermanager']['markerclusterer']['maxZoom'] = array(
'#type' => 'select',
'#title' => t('Maximum zoom'),
'#options' => drupal_map_assoc(range(0, 17)),
'#description' => t('At this zoom and above, all markers will be shown without clustering.'),
'#default_value' => $opts['markerclusterer']['maxZoom'],
);
// Jef Poskanzer's Clusterer
$form['gmap_markermanager']['clusterer'] = array(
'#type' => 'fieldset',
......
/* $Id$ */
/**
* @file
* GMap Markers
* Gmaps Utility Library MarkerClusterer API version
*/
/*global Drupal, GMarker, MarkerClusterer */
// Replace to override marker creation
Drupal.gmap.factory.marker = function (loc, opts) {
return new GMarker(loc, opts);
};
Drupal.gmap.addHandler('gmap', function (elem) {
var obj = this;
obj.bind('init', function () {
// Set up the markermanager.
obj.mc = new MarkerClusterer(obj.map, [], Drupal.settings.gmap_markermanager);
});
obj.bind('addmarker', function (marker) {
// @@@ Would be really nice to have bulk adding support in gmap.
obj.mc.addMarkers([marker.marker]);
});
obj.bind('delmarker', function (marker) {
obj.mc.removeMarker(marker.marker);
});
obj.bind('clearmarkers', function () {
obj.mc.clearMarkers();
});
});
......@@ -37,3 +37,10 @@ Google Maps API Utility Library addon
This is an improved version of GMarkerManager.
Website: http://code.google.com/p/gmaps-utility-library/
Tested version: 1.0
MarkerClusterer.js
----------------
Google Maps API Utility Library addon
This javascript library creates and manages per-zoom-level clusters for large amounts of markers (hundreds or thousands).
Website: http://code.google.com/p/gmaps-utility-library-dev/
Tested version: 1.0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment