Commit e3c5f95b authored by Matt Strum's avatar Matt Strum
Browse files

Finished node marker clustering changes.

parent bb11f108
......@@ -213,6 +213,11 @@
waitingIcon.visible = false;
chooseCMWindow.waitingIcon.visible = false;
}
public function resetZoom():void {
map.setZoom(4);
map.panTo(new LatLng(38,-97));
}
]]>
</mx:Script>
......@@ -237,20 +242,24 @@
toolTip="View the most recent RSpec"/>
<mx:VRule height="14"/>
<mx:ComboBox id="slicesCombobox" dataProvider="{slicesMenu}" labelFunction="getSliceLabel" change="sliceSelected(event)"></mx:ComboBox>
<mx:CheckBox label="Mine" id="onlyMyResourcesCheckbox" click="userResourcesOnly = onlyMyResourcesCheckbox.selected; pgHandler.map.drawMap()"/>
<mx:CheckBox label="Show Mine Only" id="onlyMyResourcesCheckbox" click="userResourcesOnly = onlyMyResourcesCheckbox.selected; pgHandler.map.drawMap()"/>
<mx:Spacer width="100%"/>
<mx:Label text="Initialized" id="progressLabel" fontStyle="normal" fontWeight="bold"/>
<mx:SWFLoader id="waitingIcon" source="@Embed('../images/waiting.swf')" visible="false"/>
<mx:Spacer width="100%"/>
<mx:Label text="{pgHandler.CurrentUser.uid}"/>
<pgmap:ImageButton id="infoButton"
source="@Embed('../images/information.png')"
click="showAbout()"
toolTip="View more information" />
<pgmap:ImageButton id="resetZoomButton"
source="@Embed('../images/zoom.png')"
click="resetZoom();"
toolTip="Reset zoom" />
<pgmap:ImageButton id="fullscreenButton"
source="@Embed('../images/arrow_out.png')"
click="toggleFullScreen()"
toolTip="Toggle fullscreen" />
<pgmap:ImageButton id="infoButton"
source="@Embed('../images/information.png')"
click="showAbout()"
toolTip="View more information" />
</mx:ApplicationControlBar>
<maps:Map height="100%" width="100%" id="map" preinitialize="mappreinit()"
......
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
width="140" height="150"
horizontalAlign="center" verticalGap="0">
width="170" height="160"
horizontalAlign="center" verticalGap="2">
<mx:Script>
<![CDATA[
......@@ -17,8 +17,13 @@
public function Load(cluster:ArrayCollection):void
{
var nodeCount:int = 0;
for each(var ng:NodeGroup in cluster)
{
addNodeGroup(ng);
nodeCount += ng.collection.length;
}
clusterLabel.text = nodeCount + " Nodes in " + cluster.length + " Groups";
}
public function addNodeGroup(ng:NodeGroup):void {
......@@ -55,7 +60,7 @@
else
city = fullAddress;
ng.city = city;
ngButton.label = city;
ngButton.label = city + " (" + ng.collection.length + ")";
} catch (err:Error) { }
}
});
......@@ -67,31 +72,27 @@
geocoder.reverseGeocode(new LatLng(ng.latitude, ng.longitude));
} else {
ngButton.label = ng.city;
ngButton.label = ng.city + " (" + ng.collection.length + ")";
}
nodeGroupButtonsVbox.addChild(ngButton);
}
public function setZoomButton(bounds:LatLngBounds):void {
if(zoomButton == null)
{
Alert.show("ERR");
return;
}
zoomButton.addEventListener(MouseEvent.CLICK,
function zoomin(evt:MouseEvent):void {
var map : Map = Common.Main().map;
var bzl : Number = map.getBoundsZoomLevel(bounds);
if(map.getZoom() != bzl)
map.setZoom(bzl);
map.panTo( bounds.getCenter() );
map.panTo( bounds.getCenter() );
});
}
]]>
</mx:Script>
<mx:Label text="Label"/>
<mx:VBox width="90%" height="100%" id="nodeGroupButtonsVbox">
<mx:Label text="Label" id="clusterLabel"/>
<mx:VBox width="170" height="114" id="nodeGroupButtonsVbox" verticalGap="2" horizontalGap="2" paddingBottom="2" paddingLeft="2" paddingRight="2" paddingTop="2" borderStyle="solid">
</mx:VBox>
<mx:Button label="Zoom" id="zoomButton"/>
<mx:Button label="Zoom" id="zoomButton" icon="@Embed('../../images/zoom_in.png')"/>
</mx:VBox>
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
width="140" height="150"
horizontalAlign="center" verticalGap="0">
horizontalAlign="center" verticalGap="0" paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0">
<mx:Script>
<![CDATA[
......
......@@ -34,7 +34,11 @@ package pgmap
}
private var markers:ArrayCollection;
private var nodeGroupClusters:ArrayCollection;
private var clusterMarkers:ArrayCollection;
private var linkLineOverlays:ArrayCollection;
private var linkLabelOverlays:ArrayCollection;
private var nodeGroupClusters:ArrayCollection;
private function addMarker(g:NodeGroup):void
{
......@@ -111,8 +115,8 @@ package pgmap
new InfoWindowOptions({
customContent:groupInfo,
customoffset: new Point(0, 10),
width:140,
height:150,
width:125,
height:160,
drawDefaultFrame:true
}));
});
......@@ -174,23 +178,25 @@ package pgmap
bounds.getCenter(),
new MarkerOptions({
icon:new iconLabelSprite(totalNodes.toString()),
iconAllignment:MarkerOptions.ALIGN_RIGHT,
iconOffset:new Point(-2, -2),
//iconAllignment:MarkerOptions.ALIGN_RIGHT,
iconOffset:new Point(-20, -20),
hasShadow: true
}));
m.addEventListener(MapMouseEvent.CLICK, function(e:Event):void {
m.openInfoWindow(
m.openInfoWindow(
new InfoWindowOptions({
customContent:clusterInfo,
customoffset: new Point(0, 10),
width:150,
height:150,
width:180,
height:170,
drawDefaultFrame:true
}));
});
main.map.addOverlay(m);
clusterMarkers.addItem(m);
}
public function addLink(lg:LinkGroup):void {
......@@ -209,6 +215,7 @@ package pgmap
}));
main.map.addOverlay(polyline);
linkLineOverlays.addItem(polyline);
// Add link marker
var ll:LatLng = new LatLng((drawGroup.latitude1 + drawGroup.latitude2)/2, (drawGroup.longitude1 + drawGroup.longitude2)/2);
......@@ -220,6 +227,7 @@ package pgmap
});
main.map.addOverlay(t);
linkLabelOverlays.addItem(t);
} else {
// Add line
var blankline:Polyline = new Polyline([
......@@ -268,25 +276,9 @@ package pgmap
main.setProgress("Drawing map",Common.waitColor);
markers = new ArrayCollection();
for each(var g:NodeGroup in main.pgHandler.Nodes.collection) {
addMarker(g);
}
nodeGroupClusters = new ArrayCollection();
var added:ArrayCollection = new ArrayCollection();
for each(var o:Object in markers) {
if(!added.contains(o)) {
var overlapping:ArrayCollection = new ArrayCollection();
getOverlapping(o, overlapping);
if(overlapping.length > 0) {
added.addAll(overlapping);
nodeGroupClusters.addItem(overlapping);
addNodeGroupCluster(overlapping);
}
}
}
// Draw links first
linkLabelOverlays = new ArrayCollection();
linkLineOverlays = new ArrayCollection();
var drawSlice:Boolean = main.userResourcesOnly && main.selectedSlice != null && main.selectedSlice.status != null;
if(drawSlice) {
for each(var drawGroup:LinkGroup in main.pgHandler.Links.collection) {
......@@ -313,6 +305,52 @@ package pgmap
}
}
// Draw markers
markers = new ArrayCollection();
for each(var g:NodeGroup in main.pgHandler.Nodes.collection) {
addMarker(g);
}
// Combine overlapping markers
clusterMarkers = new ArrayCollection();
nodeGroupClusters = new ArrayCollection();
var added:ArrayCollection = new ArrayCollection();
for each(var o:Object in markers) {
if(!added.contains(o)) {
var overlapping:ArrayCollection = new ArrayCollection();
getOverlapping(o, overlapping);
if(overlapping.length > 0) {
added.addAll(overlapping);
nodeGroupClusters.addItem(overlapping);
addNodeGroupCluster(overlapping);
}
}
}
// Remove link items that are blocking markers
for each(var linkLabel:TooltipOverlay in linkLabelOverlays)
{
var removed:Boolean = false;;
var d:DisplayObject = linkLabel.foreground;
for each(var clusterMarker:Marker in clusterMarkers) {
if(linkLabel.foreground.hitTestObject(clusterMarker.foreground)) {
main.map.removeOverlay(linkLabel);
removed = true;
break;
}
}
if(!removed)
{
for each(var ngo:Object in markers) {
var nodegroupMarker:Marker = ngo.marker;
if(linkLabel.foreground.hitTestObject(nodegroupMarker.foreground)) {
main.map.removeOverlay(linkLabel);
break;
}
}
}
}
main.setProgress("Done", Common.successColor);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment