Skip to content

Commit

Permalink
Item11187: Moved all data forms to Applications/OpenLayers/Layers
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/OpenLayersPlugin@12909 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
PaulAlexander authored and PaulAlexander committed Oct 28, 2011
1 parent c8d3cbb commit 08380b9
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 59 deletions.
11 changes: 11 additions & 0 deletions data/Applications/OpenLayers/Layers/ALA_GreatBarrierReef.txt
@@ -0,0 +1,11 @@
%META:TOPICINFO{author="BaseUserMapping_333" comment="save topic" date="1319760020" format="1.1" reprev="2" version="2"}%
-- Main.AdminUser - 26 Oct 2011

%META:FORM{name="Applications/OpenLayers/WMSLayerForm"}%
%META:FIELD{name="Name" attributes="" title="Name" value="Great Barrier Reef"}%
%META:FIELD{name="URL" attributes="" title="URL" value="http://spatial.ala.org.au/geoserver/ALA/wms"}%
%META:FIELD{name="ServerParams" attributes="" title="ServerParams" value="layers: %22ALA:gbr_gbr100%22,srs: %22EPSG:4326%22,transparent: %22true%22,format: %22image/png%22"}%
%META:FIELD{name="ClientOptions" attributes="" title="ClientOptions" value="visibility:false, wrapDateLine:true, opacity:0.8"}%
%META:FIELD{name="IsBaseLayer" attributes="" title="IsBaseLayer" value=""}%
%META:FIELD{name="IsVisible" attributes="" title="IsVisible" value=""}%
%META:TOPICMOVED{by="BaseUserMapping_333" date="1319760020" from="Sandbox.ALA_GreatBarrierReef" to="Applications/OpenLayers/Layers.ALA_GreatBarrierReef"}%
16 changes: 16 additions & 0 deletions data/Applications/OpenLayers/Layers/ALA_Magpie.txt
@@ -0,0 +1,16 @@
%META:TOPICINFO{author="BaseUserMapping_333" comment="save topic" date="1319759893" format="1.1" reprev="4" version="4"}%
speciesLayer = new OpenLayers.Layer.WMS(
"Australian Magpie",
"http://biocache.ala.org.au/ws/webportal/wms/reflect",
{ layers: 'ALA:occurrences',srs: 'EPSG:900913',format: 'image/png',cql_filter: "Australian Magpie",transparent: true, env:'color:22a467;name:circle;size:3;opacity:0.8',exceptions:'application-vnd.ogc.se_inimage'
}
);

%META:FORM{name="Applications/OpenLayers/WMSLayerForm"}%
%META:FIELD{name="Name" attributes="" title="Name" value="Australian Magpie"}%
%META:FIELD{name="URL" attributes="" title="URL" value="http://biocache.ala.org.au/ws/webportal/wms/reflect"}%
%META:FIELD{name="ServerParams" attributes="" title="ServerParams" value="layers: 'ALA:occurrences',srs: 'EPSG:4326',format: 'image/png',cql_filter: %22Australian Magpie%22,transparent: true, env:'color:22a467;name:circle;size:3;opacity:0.8',exceptions:'application-vnd.ogc.se_inimage'"}%
%META:FIELD{name="ClientOptions" attributes="" title="ClientOptions" value=""}%
%META:FIELD{name="IsBaseLayer" attributes="" title="IsBaseLayer" value=""}%
%META:FIELD{name="IsVisible" attributes="" title="IsVisible" value=""}%
%META:TOPICMOVED{by="BaseUserMapping_333" date="1319759893" from="Sandbox.ALA_Magpie" to="Applications/OpenLayers/Layers.ALA_Magpie"}%
13 changes: 13 additions & 0 deletions data/Applications/OpenLayers/Layers/Demis_Layer.txt
@@ -0,0 +1,13 @@
%META:TOPICINFO{author="BaseUserMapping_333" comment="save topic" date="1319759946" format="1.1" reprev="2" version="2"}%
-- Main.AdminUser - 25 Oct 2011

%META:FORM{name="Applications/OpenLayers/WorldWindForm"}%
%META:FIELD{name="Name" attributes="" title="Name" value="Demis World"}%
%META:FIELD{name="URL" attributes="" title="URL" value="http://www2.demis.nl/wms/ww.ashx?"}%
%META:FIELD{name="TileSize" attributes="" title="TileSize" value="45"}%
%META:FIELD{name="ZoomLevels" attributes="" title="ZoomLevels" value="11"}%
%META:FIELD{name="ServerParams" attributes="" title="ServerParams" value="T:'WorldMap'"}%
%META:FIELD{name="ClientOptions" attributes="" title="ClientOptions" value="tileSize: new OpenLayers.Size(512,512), wrapDateLine:true"}%
%META:FIELD{name="IsBaseLayer" attributes="" title="IsBaseLayer" value=""}%
%META:FIELD{name="IsVisible" attributes="" title="IsVisible" value=""}%
%META:TOPICMOVED{by="BaseUserMapping_333" date="1319759946" from="Sandbox.Demis_Layer" to="Applications/OpenLayers/Layers.Demis_Layer"}%
13 changes: 13 additions & 0 deletions data/Applications/OpenLayers/Layers/MyKMLFeatures.txt
@@ -0,0 +1,13 @@
%META:TOPICINFO{author="BaseUserMapping_333" comment="save topic" date="1319768451" format="1.1" reprev="7" version="7"}%
%META:TOPICPARENT{name="Sandbox.WebHome"}%
-- Main.AdminUser - 25 Oct 2011

%META:FORM{name="Applications/OpenLayers/KMLLayerForm"}%
%META:FIELD{name="Name" attributes="" title="Name" value="KML Attachment"}%
%META:FIELD{name="URL" attributes="" title="URL" value="http://element-bp.nexus.csiro.au/pub/Applications/OpenLayers/Layers/MyKMLFeatures/atrophotergum2.kml"}%
%META:FIELD{name="ExtractAttributes" attributes="" title="ExtractAttributes" value="on"}%
%META:FIELD{name="ExtractStyles" attributes="" title="ExtractStyles" value="on"}%
%META:FIELD{name="Clustering" attributes="" title="Clustering" value="20,5"}%
%META:FIELD{name="IsVisible" attributes="" title="IsVisible" value=""}%
%META:FILEATTACHMENT{name="atrophotergum2.kml" attachment="atrophotergum2.kml" attr="" comment="" date="1319518468" path="atrophotergum2.kml" size="93480" user="BaseUserMapping_333" version="1"}%
%META:TOPICMOVED{by="BaseUserMapping_333" date="1319759825" from="Sandbox.MyKMLFeatures" to="Applications/OpenLayers/Layers.MyKMLFeatures"}%
33 changes: 33 additions & 0 deletions data/Applications/OpenLayers/Layers/TRIN_Specimens.txt
@@ -0,0 +1,33 @@
%META:TOPICINFO{author="BaseUserMapping_333" comment="reprev" date="1319760777" format="1.1" reprev="11" version="11"}%
%META:TOPICPARENT{name="Sandbox.TestTopic0"}%
%STARTSECTION{"json"}%{
"type": "FeatureCollection",
"features": [
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[-81, 42]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[-71, -7]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[-21, 63]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[19, -24]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[4, 42]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[-116, 61]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[-17, 40]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[32, 35]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[83, 38]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[133, -28]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[-53, -18]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[99, 3]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[137, 42]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[77, 21]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[83, 31]}},
{"type":"Feature","properties":{}, "geometry":{"type":"Point", "coordinates":[24, 52]}}
]
}%ENDSECTION{"json"}%

%META:FORM{name="Applications/OpenLayers/WikiVectorForm"}%
%META:FIELD{name="Name" attributes="" title="Name" value="TRIN Specimens as GeoJSON"}%
%META:FIELD{name="URL" attributes="" title="URL" value="Applications/OpenLayers/Layers/TRIN_Specimens"}%
%META:FIELD{name="Clustering" attributes="" title="Clustering" value="on"}%
%META:FIELD{name="Format" attributes="" title="Format" value=""}%
%META:FIELD{name="Protocol" attributes="" title="Protocol" value=""}%
%META:FIELD{name="Style" attributes="" title="Style" value="default"}%
%META:FIELD{name="IsBaseLayer" attributes="" title="IsBaseLayer" value="false"}%
%META:TOPICMOVED{by="BaseUserMapping_333" date="1319760752" from="Sandbox.TRIN_SpongeSpecimens" to="Applications/OpenLayers/Layers.TRIN_Specimens"}%
82 changes: 33 additions & 49 deletions data/System/OpenLayersPlugin.txt
Expand Up @@ -36,74 +36,58 @@ render a [[http://www.demis.nl][DEMIS]] world map
| *Parameter* | *Description* | *Example* | *Default* |
| =mapwidth= | the width of the map div | | full screen width |
| =mapheight= | the height of the map div | | =600= |
| =viewport= | the longitude,latitude of the viewport | | =159,-38= |
| =mapelement= | the html div element in which the map will be rendered | | =openlayersmap= |
| =viewport= | the longitude,latitude or the web.topic name of the layer (listed in =layers=) which will be used to set the bounds of the viewport | | =159,-38= |
| =viewportzoom= | the default zoom level of viewport, -1 = no zoom. Values range from 1...n-1 (n = mapnumzoomlevels) | | =-1= |
| =layers= | comma separated list of user assigned layerID's. (see below) e.g. ="BaseLayer,Overlay,Environmental"= | | If no layers exist the default Demis map is rendered |
| =layerid_type="WW"= <br /> =layerid_type="WMS"= <br /> =layerid_type="KML"= <br /> =layerid_type="GOOGLE"= | (per layer option) the layer type.<ul><li>WW WorldWind</li><li>WMS Web Map Service</li><li>KML Google Earth data file</li></ul>, e.g. Environmental_type="WMS" | | |
| =layerid_url= | (per layer option) the url for the map server | | |
| =layerid_name= | (per layer option) the display name for the layer | Global Administrative Areas | layerid listed in =layers= |
| =layerid_serverparams= | (per layer option) the parameters that are passed to the map server |e.g. layers: 'ALA:world',srs: 'EPSG:4326',format: 'image/png' | |
| =layerid_clientoptions= | (per layer option) the client options used by the OpenLayers javascript library when rendering the layer in the client's browser, these are not sent to the map server. | =visibility:false, wrapDateLine:true= | |
| =layerid_isbaselayer= | (per layer option) is the layer a base layer on which | | ="on"= |
| =layerid_layeropacity= | (per layer option) the opacity of the layer if =isbaselayer="off"= . Base layers are not semi-transparent | | ="0.5"= |
| =layerid_tilesize= | (per layer option) the tile size to request from the map server | | ="512"= |
| =layerid_zoomlevels= | (per layer option) the width of the map div | | ="11"= |
| =layers= | comma separated list of topics, each with an defined [[%SCRIPTURL{view}%/%WEB%.%TOPIC%#Defined_Forms][OpenLayers form attached]] | | If no layers exist the default Demis map is rendered |


Example

<verbatim class="tml">
%OPENLAYERSMAP{
mapwidth="600"
layers="myBase,myOverlay"
mapwidth="n600"
viewport="159,-32"
viewport1="Applications/OpenLayers/Layers/ALA_GreatBarrierReef"
viewportzoom="-1"

myBase_type="WW"
myBase_url="http://www2.demis.nl/wms/ww.ashx?"
myBase_name="Demis World"
myBase_serverparams="T:'WorldMap'"
myBase_clientoptions="tileSize: new OpenLayers.Size(512,512), wrapDateLine:true"
myBase_tilesize="45"
myBase_zoomlevels="11"

myOverlay_type="WMS"
myOverlay_isbaselayer="off"
myOverlay_layeropacity="0.4"
myOverlay_url="http://spatial.ala.org.au/geoserver/ALA/wms"
myOverlay_name="Global Administrative Areas - World Boundary"
myOverlay_serverparams="layers: 'ALA:world',srs: 'EPSG:4326',format: 'image/png'"
myOverlay_clientoptions="visibility:false, wrapDateLine:true"
}%
mapprojection="EPSG:4326"
layertopics="Applications/OpenLayers/Layers/DefaultMap,Applications/OpenLayers/Layers/Demis_Layer,Applications/OpenLayers/Layers/ALA_GreatBarrierReef,Applications/OpenLayers/Layers/TRIN_Specimens,Applications/OpenLayers/Layers/MyKMLFeatures"
mapelement="myMap"
styleobject=""
basetopics=""
}%
</verbatim>


Preview
%OPENLAYERSMAP{
mapwidth="600"
layers="myBase,myOverlay"
mapwidth="n600"
viewport="159,-32"
viewport1="Applications/OpenLayers/Layers/ALA_GreatBarrierReef"
viewportzoom="-1"
mapprojection="EPSG:4326"
layertopics="Applications/OpenLayers/Layers/DefaultMap,Applications/OpenLayers/Layers/Demis_Layer,Applications/OpenLayers/Layers/ALA_GreatBarrierReef,Applications/OpenLayers/Layers/TRIN_Specimens,Applications/OpenLayers/Layers/MyKMLFeatures"
mapelement1="myMap"
styleobject=""
basetopics=""
}%
<div id="myMap" style="position:relative;"></div>

myBase_type="WW"
myBase_url="http://www2.demis.nl/wms/ww.ashx?"
myBase_name="Demis World"
myBase_serverparams="T:'WorldMap'"
myBase_clientoptions="tileSize: new OpenLayers.Size(512,512), wrapDateLine:true"
myBase_tilesize="45"
myBase_zoomlevels="11"

myOverlay_type="WMS"
myOverlay_isbaselayer="off"
myOverlay_layeropacity="0.4"
myOverlay_url="http://spatial.ala.org.au/geoserver/ALA/wms"
myOverlay_name="Global Administrative Areas - World Boundary"
myOverlay_serverparams="layers: 'ALA:world',srs: 'EPSG:4326',format: 'image/png'"
myOverlay_clientoptions="visibility:false, wrapDateLine:true"
}%


<div id="myMap" style="position:relative;"></div>
---++ Defined Forms
OpenLayers comes installed with dataforms defining various layers that can be rendered.
Set the Web Preferences to point the variable OPENLAYERSPLUGIN_MAPSWEB to the location of these forms and add links for these forms the WEBFORMS varaible in your [[WebPreferences]] that are used

---+++ Defining your own forms
Below is a table of the various Layer types and variables which can be set from a layer form. Ensure you attach the [[Applications/OpenLayers/LayerTypeForm][LayerTypeForm]] and set the value of LayerType to the one of (google, kml, vector, wfs, wms, or worldwind).
|*LayerType*|*Fields*|*sample*|
|google| | |
|kml|Name,URL,Clustering|MyKMLFeatures|
|vector|Name,URL,Clustering|Wiki|
|wfs| | |
|wms|Name,URL, ServerParams{Object}, ClientOptions{Object}|[[%OPENLAYERSPLUGIN_MAPSWEB%.WMSLayerForm][ALA_GreatBarrierReef]]|
|worldwind|Name,URL,TileSize,ZoomLevels,ServerParams,ClientOptions,IsBaseLayer,IsVisible|[[%OPENLAYERSPLUGIN_MAPSWEB%.WorldWindForm][Demis]]|

---++ Installation

Expand Down
30 changes: 20 additions & 10 deletions lib/Foswiki/Plugins/OpenLayersPlugin.pm
Expand Up @@ -231,11 +231,11 @@ sub typehandler_kml {
if ($clustering eq 'true') {
$style=<<"HERE";
//Create a style map object and set the 'default' intent to the
var vector_style_map$layerweb$layertopic = new OpenLayers.StyleMap({
var vector_style_map$layertopic = new OpenLayers.StyleMap({
'default': style
});
//Add the style map to the vector layer threshold, distance
kmllayer$layerweb$layertopic.styleMap = vector_style_map$layerweb$layertopic;
kmllayer$layertopic.styleMap = vector_style_map$layertopic;
HERE
}

Expand All @@ -249,19 +249,20 @@ HERE
}

push @returnString, <<"HERE";
var kmllayer$layerweb$layertopic = new OpenLayers.Layer.Vector(
var kmllayer$layertopic = new OpenLayers.Layer.Vector(
"$data{Name}",
{ strategies: [new OpenLayers.Strategy.Fixed() $strategy],
protocol: new OpenLayers.Protocol.HTTP({
url: "$data{URL}",
format: new OpenLayers.Format.KML({
extractStyles: $extractStyles,
placemarksDesc: 'flee',
extractAttributes: $extractAttributes
})
})
});
map.addLayers([kmllayer$layerweb$layertopic]);
map.addLayers([kmllayer$layertopic]);
$style
HERE

Expand Down Expand Up @@ -297,11 +298,11 @@ sub typehandler_vector {
$strategy = ", new OpenLayers.Strategy.Cluster()";
$style=<<"HERE";
//Clustering = $clustering Create a style map object and set the 'default' intent to the
var wikilayer_style_map$layerweb$layertopic = new OpenLayers.StyleMap({
var wikilayer_style_map$layertopic = new OpenLayers.StyleMap({
'default': style
});
//Add the style map to the vector layer
wikilayer$layerweb$layertopic.styleMap = wikilayer_style_map$layerweb$layertopic;
wikilayer$layertopic.styleMap = wikilayer_style_map$layertopic;
HERE
}

Expand All @@ -316,15 +317,15 @@ HERE

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

Expand Down Expand Up @@ -377,20 +378,24 @@ sub _OPENLAYERSMAP {

my @mapMetadata;
my @scriptVariable;
my $viewPortLayer;

my $mapHeight = $params->{mapheight};
$mapHeight = '600' unless defined $mapHeight;
$mapHeight = $mapHeight.'px';
# push @mapMetadata, "mapHeight:$mapHeight";

my $mapWidth = $params->{mapwidth};
$mapWidth = 'my800' unless defined $mapWidth;
$mapWidth = 'my800' unless defined $mapWidth; #FullWidth
$mapWidth = $mapWidth.'px';
# push @mapMetadata, "mapHeight:$mapWidth";

my $mapViewPort = $params->{viewport};
$mapViewPort = '159,-32' unless defined $mapViewPort;
# push @mapMetadata, "mapViewPort:$mapViewPort";
if ($mapViewPort =~ /$params->{layertopics}/) {
$viewPortLayer = 'true';
}

my $mapViewPortZoom = $params->{viewportzoom};
$mapViewPortZoom = '1' unless defined $mapViewPortZoom;
Expand Down Expand Up @@ -629,6 +634,11 @@ HERE
# map.render('$mapElement');
# HERE

if ($viewPortLayer eq 'true') {
# Set View port to bounds of $mapViewPort
}


push @scriptVariable, <<"HERE";
// if (map.isValidLonLat(viewportcorner) && $mapViewPortZoom) {
// map.moveTo(viewportcorner,$mapViewPortZoom);
Expand All @@ -637,7 +647,7 @@ HERE
var proj = new OpenLayers.Projection("EPSG:4326");
if (map.isValidLonLat(viewportcorner) && $mapViewPortZoom) {
var point = new OpenLayers.LonLat(133, -28);
var point = new OpenLayers.LonLat(viewportcorner);
point.transform(proj, map.getProjectionObject());
map.setCenter(point, 4);
//map.moveTo(viewportcorner,$mapViewPortZoom);
Expand Down

0 comments on commit 08380b9

Please sign in to comment.