Skip to content

Commit

Permalink
Item11187: KML clusting now working
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/OpenLayersPlugin@12878 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
PaulAlexander authored and PaulAlexander committed Oct 26, 2011
1 parent 72d1235 commit 3e3d377
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 49 deletions.
4 changes: 4 additions & 0 deletions data/Applications/OpenLayers/Proxy.txt
@@ -0,0 +1,4 @@
%META:TOPICINFO{author="BaseUserMapping_333" comment="reprev" date="1319584347" format="1.1" reprev="3" version="3"}%
%INCLUDE{"%URLPARAM{"url" default="ThisurlwillneverExist"}%"}%

%META:TOPICMOVED{by="BaseUserMapping_333" date="1319584347" from="Applications/OpenLayers/Layers.Proxy" to="Applications/OpenLayers.Proxy"}%
8 changes: 5 additions & 3 deletions data/Applications/OpenLayers/WikiVectorForm.txt
@@ -1,9 +1,11 @@
%META:TOPICINFO{author="BaseUserMapping_333" comment="save topic" date="1319520384" format="1.1" reprev="1" version="2"}%
%META:TOPICINFO{author="BaseUserMapping_333" comment="save topic" date="1319582611" format="1.1" reprev="1" version="3"}%
| *Name* | *Type* | *Size* | *Values* | *Tooltips* | *Attributes* |
| Name | text | | | | |
| URL | text | | | | |
| Clustering | text | | | | |
| Style | text | | | | |
| Clustering | text | | | Clustering not implemented | |
| Format | text | | | Format not implemented | |
| Protocol | text | | | Protocol not implemented | |
| Style | text | | | Style not implemented | |
| IsBaseLayer | select | | false,true | | |

%META:FORM{name="LayerTypeForm"}%
Expand Down
117 changes: 71 additions & 46 deletions lib/Foswiki/Plugins/OpenLayersPlugin.pm
Expand Up @@ -215,15 +215,7 @@ sub typehandler_kml {
extractStyles: true,
extractAttributes: false
})
}),
styleMap: new OpenLayers.StyleMap({
"default": style,
"select": {
fillColor: "#8aeeef",
strokeColor: "#32a8a9"
}
})
isBaseLayer:$isBaseLayer
});
map.addLayers([kmllayer$layerweb$layertopic]);
Expand All @@ -240,7 +232,8 @@ sub typehandler_vector {
my ($layerweb, $layertopic) = ($layerObject->web(), $layerObject->topic());
my @fields = $layerObject->find('FIELD');
my %data;
my @returnString;
my @returnString;
my $proxy = '../Applications/OpenLayers'.'.Proxy?skin=text;'.'url=';

my $isBaseLayer = $data{IsBaseLayer};
$isBaseLayer = 'false' unless defined $isBaseLayer;
Expand All @@ -257,18 +250,22 @@ sub typehandler_vector {
} else {
return "<span class='foswikiAlert'>[[$layerweb.$layertopic]] does not contain a URL</span>";
}


push @returnString, <<"HERE";
OpenLayers.ProxyHost = '$proxy';
var wikilayer$layerweb$layertopic = new OpenLayers.Layer.Vector('$data{Name}',{
protocol: new OpenLayers.Protocol.HTTP({
url: '$data{URL}',
format: new OpenLayers.Format.GeoJSON({})
}),
isBaseLayer:$isBaseLayer,
style: style,
strategies: [new OpenLayers.Strategy.Fixed()]
});
},{isBaseLayer:$isBaseLayer});
map.addLayers([wikilayer$layerweb$layertopic]);
HERE

my $returnString = "\n".join("\n", @returnString)."\n";
Expand Down Expand Up @@ -497,45 +494,73 @@ HERE
$mapElement = 'openlayersmap';
$mapDiv = "<div id='$mapElement' style='height:$mapHeight; width:$mapWidth; position:relative;'></div>";
}

push @scriptVariable, <<"HERE";
var style = new OpenLayers.Style({
pointRadius: "\${radius}",
fillColor: "#ffcc66",
fillOpacity: 0.8,
strokeColor: "#cc6633",
label: "\${pointLabel}",
strokeWidth: "\${width}",
strokeOpacity: 0.8
}, {
context: {
width: function(feature) {
return (feature.cluster) ? 2 : 1;
},
pointLabel: function(feature) {
return (feature.cluster) ? feature.attributes.count : feature.attributes.pointLabel ;
},
radius: function(feature) {
var pix = 3;
if(feature.cluster) {
pix = Math.min(feature.attributes.count, 7) + 3;
}
return pix;

push @scriptVariable, <<"HERE";
var style = new OpenLayers.Style({
pointRadius: "\${radius}",
fillColor: "#ffcc66",
fillOpacity: 0.8,
strokeColor: "#cc6633",
label: "\${pointLabel}",
strokeWidth: "\${width}",
strokeOpacity: 0.8
}, {
context: {
width: function(feature) {
return (feature.cluster) ? 2 : 1;
},
pointLabel: function(feature) {
return (feature.cluster) ? feature.attributes.count : "" ;
},
radius: function(feature) {
var pix = 3;
if(feature.cluster) {
pix = Math.min(feature.attributes.count, 7) + 3;
}
}
});
return pix;
}
}
});
HERE
#
# push @scriptVariable, <<"HERE";
# var strategy = new OpenLayers.Strategy.Cluster();
# strategy.distance= 20;
# strategy.threshold=2;
# var styleselect = new OpenLayers.Style({fillColor: "#8aeeef",strokeColor: "#32a8a9"});
#
# var styleMap= new OpenLayers.StyleMap({
# "default": style,
# "select": styleselect });

# push @scriptVariable, <<"HERE";
# var style = new OpenLayers.Style({
# pointRadius: "\${radius}",
# fillColor: "#ffcc66",
# fillOpacity: 0.8,
# strokeColor: "#cc6633",
# label: "\${pointLabel}",
# strokeWidth: "\${width}",
# strokeOpacity: 0.8
# }, {
# context: {
# width: function(feature) {
# return (feature.cluster) ? 2 : 1;
# },
# pointLabel: function(feature) {
# return (feature.cluster) ? feature.attributes.count : feature.attributes.pointLabel ;
# },
# radius: function(feature) {
# var pix = 3;
# if(feature.cluster) {
# pix = Math.min(feature.attributes.count, 7) + 3;
# }
# return pix;
# }
# }
# });
# HERE
#
push @scriptVariable, <<"HERE";
var strategy = new OpenLayers.Strategy.Cluster();
strategy.distance= 20;
strategy.threshold=2;
var styleselect = new OpenLayers.Style({fillColor: "#8aeeef",strokeColor: "#32a8a9"});
var styleMap= new OpenLayers.StyleMap({
"default": style,
"select": styleselect });
HERE

# push @scriptVariable, <<"HERE";
# if(!map.getCenter()){
Expand Down

0 comments on commit 3e3d377

Please sign in to comment.