Professional Documents
Culture Documents
$link.appendChild(document.createTextNode($marker.getTitle().rep
lace(/ /g, '_')));
$maxContent.appendChild($link);
if(i<$length-1){
$maxContent.appendChild(document.createTextNode(' | '));
}
}
$minContent.appendChild(document.createElement('br'));
$link=document.createElement('a');
$link.href='javascript:return void()';
$link.onclick=function(){
$this.map.getInfoWindow().maximize();
};
$link.appendChild(document.createTextNode('Show links'));
$minContent.appendChild($link);
$minContent.appendChild(document.createTextNode(' | '));
// if map fully zoomed in then no need for zoom in links and might
as well show links by default
$link=document.createElement('a');
$link.href='javascript:return void()';
$link.onclick=function(){
$map.setCenter($clusterMarker._clusterBounds.getCenter(), $map.g
etBoundsZoomLevel($clusterMarker._clusterBounds));
};
$link.appendChild(document.createTextNode('Fit map to cluster'));
$minContent.appendChild($link);
$minContent.appendChild(document.createTextNode(' | '));
$link=document.createElement('a');
$link.href='javascript:return void()';
$link.onclick=function(){
// $map.panTo($clusterMarker._clusterBounds.getCenter());
$map.zoomIn();
};
$link.appendChild(document.createTextNode('Zoom in'));
$minContent.appendChild($link);
$clusterMarker.openInfoWindow($minContent, {maxContent:$maxContent, maxT
itle:"Markers within this cluster"});
// debug option: just display a simple infowindow
// $clusterMarker.openInfoWindowHtml($indexes.length+' markers in t
his cluster');
};
// make these three event handlers into anon functions in constructor?
ClusterMarker.prototype.zoomEnd=function(){
this._cancelMoveEnd=true;
this.refresh();
};
ClusterMarker.prototype.moveEnd=function(){
if(this._cancelMoveEnd){
this._cancelMoveEnd=false;
} else {
this.refresh();
}
};
ClusterMarker.prototype.mapTypeChanged=function(){
// refresh can be assigned directly to listener if no other functio
ns are required
this.refresh();
};
ClusterMarker.prototype.fitMapToMarkers=function($markers, $maxZoom){
var $this=this, $bounds=new GLatLngBounds(), $refresh=false;
if(typeof($markers)==='undefined' || $markers===null){
var $markers=this.markers;
}
var $length=$markers.length;
while($length--){
if(!$markers[$length].isHidden()){
$bounds.extend($markers[$length].getLatLng());
$refresh=true;
}
}
if($refresh){
var $zoom=$this.map.getBoundsZoomLevel($bounds);
if(typeof($maxZoom)!=='undefined'){
$zoom=$zoom>$maxZoom?$maxZoom:$zoom;
}
$this.map.setCenter($bounds.getCenter(), $zoom);
}
};
ClusterMarker.prototype.getMinUnclusterLevel=function($marker){
var $this=this, $map=$this.map, $maxZoomLevel=$map.getCurrentMapType().g
etMaximumResolution(), $isClustered, $markers=$this.markers, $length=$markers.le
ngth, $indexes=[], i, $zoomLevel;
while($length--){
if($marker!==$markers[$length]){
$indexes.push($markers[$length]._ClusterMarker_.index);
// will need updating when remove single (or more) markers is implemented t
o avoid undefined elements in this.markers array
}
}
if($marker._clusterMarker){
$zoomLevel=$map.getZoom()+1;
} else {
$zoomLevel=0;
}
$length=$indexes.length;
while($zoomLevel<=$maxZoomLevel){
$isClustered=false;
i=$length;
while(!$isClustered && i--){
if($this.markerIconsIntersect($marker, $markers[$indexes
[i]], $zoomLevel)){ // add support for hidden markers?
$isClustered=true;
}
}
if(!$isClustered){
break;
}
$zoomLevel++;
}
return $zoomLevel; // should return $zoomLevel-1 ??
/*
if($isUnclustered){
return $zoomLevel; // -1 ?
} else {
// marker is unclusterable with the current map type
return false;
}
*/
};
ClusterMarker.prototype.setDoNotCluster=function($marker, $state){
$marker._ClusterMarker_.doNotCluster=$state;
this.refresh();
};
ClusterMarker.prototype.newMethod=function(){
};