document.addEventListener("deviceready",function(){varmapDiv=document.getElementById("map_canvas");varoptions={'camera': {'target': data[0].position,'zoom': 3}};varmap=plugin.google.maps.Map.getMap(mapDiv,options);map.on(plugin.google.maps.event.MAP_READY,onMapReady);});functiononMapReady(){varmap=this;varlabel=document.getElementById("label");//------------------------------------------------------// Create a marker cluster.// Providing all locations at the creating is the best.//------------------------------------------------------map.addMarkerCluster({//debug: true,//maxZoomLevel: 5,markers: data,icons: [{min: 2,max: 100,url: "./img/blue.png",anchor: {x: 16,y: 16}},{min: 100,max: 1000,url: "./img/yellow.png",anchor: {x: 16,y: 16}},{min: 1000,max: 2000,url: "./img/purple.png",anchor: {x: 24,y: 24}},{min: 2000,url: "./img/red.png",anchor: {x: 32,y: 32}},]},function(markerCluster){//-----------------------------------------------------------------------// Display the resolution (in order to understand the marker cluster)//-----------------------------------------------------------------------markerCluster.on("resolution_changed",function(prev,newResolution){varself=this;label.innerHTML="<b>zoom = "+self.get("zoom")+", resolution = "+self.get("resolution")+"</b>";});markerCluster.trigger("resolution_changed");//----------------------------------------------------------------------// Remove the marker cluster// (Don't remove/add repeatedly. This is really bad performance)//----------------------------------------------------------------------varremoveBtn=document.getElementById("removeClusterBtn");removeBtn.addEventListener("click",function(){markerCluster.remove();},{once: true});//------------------------------------// If you tap on a marker,// you can get the marker instnace.// Then you can do what ever you want.//------------------------------------varhtmlInfoWnd=newplugin.google.maps.HtmlInfoWindow();markerCluster.on(plugin.google.maps.event.MARKER_CLICK,function(position,marker){varhtml=["<div style='width:250px;min-height:100px'>","<img src='img/starbucks_logo.gif' align='right'>","<strong>"+(marker.get("title")||marker.get("name"))+"</strong>"];if(marker.get("address")){html.push("<div style='font-size:0.8em;'>"+marker.get("address")+"</div>");}if(marker.get("phone")){html.push("<a href='tel:"+marker.get("phone")+"' style='font-size:0.8em;color:blue;'>Tel: "+marker.get("phone")+"</div>");}html.push("</div>");htmlInfoWnd.setContent(html.join(""));htmlInfoWnd.open(marker);});});}