new layerswitcher, improved google layer, boxes layer, grid fix
git-svn-id: http://svn.openlayers.org/trunk/openlayers@1096 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
128
art/layer-switcher-maximize.svg
Normal file
128
art/layer-switcher-maximize.svg
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://web.resource.org/cc/"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="18.000000px"
|
||||||
|
height="18.000000px"
|
||||||
|
id="svg2"
|
||||||
|
sodipodi:version="0.32"
|
||||||
|
inkscape:version="0.43"
|
||||||
|
sodipodi:docbase="/home/sderle/projects/openlayers/layerswitcher/art"
|
||||||
|
sodipodi:docname="layer-switcher-maximize.svg"
|
||||||
|
inkscape:export-filename="/Users/phil/Documents/work/metacarta/2svn.openlayers.net/follower/code/b-edits-1/openlayers/assets/ui_elements/zoom-minus-mini.png"
|
||||||
|
inkscape:export-xdpi="90.000000"
|
||||||
|
inkscape:export-ydpi="90.000000">
|
||||||
|
<defs
|
||||||
|
id="defs4" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="16"
|
||||||
|
inkscape:cx="9"
|
||||||
|
inkscape:cy="9"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="layer4"
|
||||||
|
inkscape:window-width="1226"
|
||||||
|
inkscape:window-height="800"
|
||||||
|
inkscape:window-x="42"
|
||||||
|
inkscape:window-y="25" />
|
||||||
|
<metadata
|
||||||
|
id="metadata7">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="background"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1">
|
||||||
|
<g
|
||||||
|
id="g2110"
|
||||||
|
transform="matrix(-7.849624e-17,1,-1,-7.849624e-17,18,0)">
|
||||||
|
<path
|
||||||
|
transform="matrix(0,-1.00316,1.00316,0,-2.844e-2,18.02844)"
|
||||||
|
d="M 17.971654 9 A 8.9716539 8.9716539 0 1 1 0.028346062,9 A 8.9716539 8.9716539 0 1 1 17.971654 9 z"
|
||||||
|
sodipodi:ry="8.9716539"
|
||||||
|
sodipodi:rx="8.9716539"
|
||||||
|
sodipodi:cy="9"
|
||||||
|
sodipodi:cx="9"
|
||||||
|
id="path2059"
|
||||||
|
style="fill:#00008b;fill-opacity:1;stroke:none;stroke-width:39.98414612;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
sodipodi:type="arc" />
|
||||||
|
<rect
|
||||||
|
transform="matrix(0,-1,1,0,0,0)"
|
||||||
|
y="4.3599998e-06"
|
||||||
|
x="-9.0000048"
|
||||||
|
height="18"
|
||||||
|
width="9"
|
||||||
|
id="rect2061"
|
||||||
|
style="fill:#00008b;fill-opacity:1;stroke:none;stroke-width:39.98414612;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer4"
|
||||||
|
inkscape:label="zoom"
|
||||||
|
style="display:inline">
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;display:inline;font-family:Helvetica"
|
||||||
|
x="1.5214844"
|
||||||
|
y="-3.2949219"
|
||||||
|
id="text2114"
|
||||||
|
sodipodi:linespacing="125%"
|
||||||
|
transform="scale(1,-1)"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan2118"
|
||||||
|
x="1.5214844"
|
||||||
|
y="-3.2949219">+</tspan></text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer2"
|
||||||
|
inkscape:label="overlay"
|
||||||
|
style="display:none">
|
||||||
|
<path
|
||||||
|
style="font-size:12.000000px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125.00000%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;font-family:Verdana"
|
||||||
|
d="M 2.9678210,9.0332227 C 2.9678314,9.5015070 3.1752531,9.8938504 3.5900866,10.210254 C 3.6463464,10.254553 3.9451742,10.453889 4.4865710,10.808262 L 8.1568835,13.247754 C 8.2693886,13.323691 8.4240759,13.393300 8.6209460,13.456582 C 8.8107943,13.519862 9.0041535,13.551503 9.2010240,13.551504 C 9.5736843,13.551503 9.8936056,13.431269 10.160789,13.190801 C 10.427980,12.950332 10.561574,12.659238 10.561572,12.317520 C 10.561574,11.861896 10.322511,11.488536 9.8443836,11.197442 L 8.5998522,10.428575 L 14.548408,10.428575 C 15.026535,10.428577 15.406221,10.298849 15.687470,10.039395 C 15.968721,9.7799443 16.109345,9.4318977 16.109345,8.9952540 C 16.109345,8.5396330 15.961690,8.1915865 15.666377,7.9511133 C 15.364034,7.7106494 14.980831,7.5904152 14.516767,7.5904102 L 8.6314928,7.5904102 L 9.9920390,6.7076368 C 10.160793,6.5937365 10.290871,6.4481897 10.382274,6.2709962 C 10.466652,6.0874870 10.508840,5.8913153 10.508837,5.6824805 C 10.508840,5.3281127 10.378761,5.0338552 10.118602,4.7997070 C 9.8584498,4.5655745 9.5279814,4.4485043 9.1271961,4.4484962 C 8.7615757,4.4485043 8.4029823,4.5624104 8.0514147,4.7902149 L 3.9697741,7.5239649 C 3.6393151,7.7454540 3.4002529,7.9542820 3.2525866,8.1504493 C 3.0627532,8.3972503 2.9678314,8.6756875 2.9678210,8.9857618 L 2.9678210,9.0332227"
|
||||||
|
id="text2082"
|
||||||
|
sodipodi:nodetypes="csccsssscccssscccssssccscc" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer3"
|
||||||
|
inkscape:label="pan triangle"
|
||||||
|
style="display:none">
|
||||||
|
<path
|
||||||
|
sodipodi:type="star"
|
||||||
|
style="fill:#ffffff;fill-opacity:1.0000000;stroke:none;stroke-width:39.984146;stroke-linejoin:round;stroke-miterlimit:4.0000000;stroke-dasharray:none;stroke-opacity:1.0000000"
|
||||||
|
id="path2107"
|
||||||
|
sodipodi:sides="3"
|
||||||
|
sodipodi:cx="6.8031497"
|
||||||
|
sodipodi:cy="5.1874018"
|
||||||
|
sodipodi:r1="5.0880113"
|
||||||
|
sodipodi:r2="2.5440056"
|
||||||
|
sodipodi:arg1="1.0471976"
|
||||||
|
sodipodi:arg2="2.0943951"
|
||||||
|
inkscape:flatsided="false"
|
||||||
|
inkscape:rounded="0.0000000"
|
||||||
|
inkscape:randomized="0.0000000"
|
||||||
|
d="M 9.3471551,9.5937489 L 5.5311469,7.3905753 L 1.7151384,5.1874015 L 5.5311469,2.9842283 L 9.3471555,0.78105489 L 9.3471553,5.1874018 L 9.3471551,9.5937489 z "
|
||||||
|
transform="matrix(0.000000,-1.331000,1.331000,0.000000,2.038879,16.92102)" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 6.1 KiB |
142
art/layer-switcher-minimize.svg
Normal file
142
art/layer-switcher-minimize.svg
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://web.resource.org/cc/"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
inkscape:export-ydpi="90.000000"
|
||||||
|
inkscape:export-xdpi="90.000000"
|
||||||
|
inkscape:export-filename="/home/sderle/projects/openlayers/layerswitcher/img/layer-switcher-minimize.png"
|
||||||
|
sodipodi:docname="layer-switcher-minimize.svg"
|
||||||
|
sodipodi:docbase="/home/sderle/projects/openlayers/layerswitcher/art"
|
||||||
|
inkscape:version="0.43"
|
||||||
|
sodipodi:version="0.32"
|
||||||
|
id="svg2"
|
||||||
|
height="18.000000px"
|
||||||
|
width="18.000000px">
|
||||||
|
<defs
|
||||||
|
id="defs4" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
inkscape:window-y="26"
|
||||||
|
inkscape:window-x="42"
|
||||||
|
inkscape:window-height="800"
|
||||||
|
inkscape:window-width="1226"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:cy="9.3025513"
|
||||||
|
inkscape:cx="9"
|
||||||
|
inkscape:zoom="16"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
borderopacity="1.0"
|
||||||
|
bordercolor="#666666"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
id="base" />
|
||||||
|
<metadata
|
||||||
|
id="metadata7">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
style="display:inline"
|
||||||
|
id="layer1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
inkscape:label="background">
|
||||||
|
<rect
|
||||||
|
style="fill:#00008b;fill-opacity:0;stroke:none;stroke-width:39.984146;stroke-linejoin:round;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
|
||||||
|
id="rect2061"
|
||||||
|
width="18.014498"
|
||||||
|
height="18.000000"
|
||||||
|
x="-18.014502"
|
||||||
|
y="4.3599998e-06"
|
||||||
|
transform="matrix(0.000000,-1.000000,1.000000,0.000000,0.000000,0.000000)"
|
||||||
|
inkscape:export-xdpi="90"
|
||||||
|
inkscape:export-ydpi="90"
|
||||||
|
inkscape:export-filename="/home/sderle/projects/openlayers/layerswitcher/art/layer-switcher-minimize.png" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
inkscape:label="graticule"
|
||||||
|
id="layer5"
|
||||||
|
inkscape:groupmode="layer">
|
||||||
|
<text
|
||||||
|
xml:space="preserve"
|
||||||
|
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;display:inline;font-family:Helvetica"
|
||||||
|
x="5.2802601"
|
||||||
|
y="-3.8032362"
|
||||||
|
id="text1432"
|
||||||
|
sodipodi:linespacing="125%"
|
||||||
|
transform="scale(1,-1)"><tspan
|
||||||
|
sodipodi:role="line"
|
||||||
|
id="tspan1434"
|
||||||
|
x="5.2802601"
|
||||||
|
y="-3.8032362">-</tspan></text>
|
||||||
|
<rect
|
||||||
|
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.99699599px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||||
|
id="rect1438"
|
||||||
|
width="13.003004"
|
||||||
|
height="13.002999"
|
||||||
|
x="2.498498"
|
||||||
|
y="2.4984975" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
style="display:none"
|
||||||
|
inkscape:label="zoom"
|
||||||
|
id="layer4"
|
||||||
|
inkscape:groupmode="layer">
|
||||||
|
<text
|
||||||
|
transform="scale(1.000000,-1.000000)"
|
||||||
|
sodipodi:linespacing="125.00000%"
|
||||||
|
id="text2114"
|
||||||
|
y="-3.4077148"
|
||||||
|
x="3.7485352"
|
||||||
|
style="font-size:18.000000;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#ffffff;fill-opacity:1.0000000;stroke:#ffffff;stroke-width:1.0000000px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1.0000000;font-family:Helvetica;text-anchor:start;writing-mode:lr-tb"
|
||||||
|
xml:space="preserve"><tspan
|
||||||
|
y="-3.4077148"
|
||||||
|
x="3.7485352"
|
||||||
|
id="tspan2118"
|
||||||
|
sodipodi:role="line">−</tspan></text>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
style="display:none"
|
||||||
|
inkscape:label="overlay"
|
||||||
|
id="layer2"
|
||||||
|
inkscape:groupmode="layer">
|
||||||
|
<path
|
||||||
|
sodipodi:nodetypes="csccsssscccssscccssssccscc"
|
||||||
|
id="text2082"
|
||||||
|
d="M 2.9678210,9.0332227 C 2.9678314,9.5015070 3.1752531,9.8938504 3.5900866,10.210254 C 3.6463464,10.254553 3.9451742,10.453889 4.4865710,10.808262 L 8.1568835,13.247754 C 8.2693886,13.323691 8.4240759,13.393300 8.6209460,13.456582 C 8.8107943,13.519862 9.0041535,13.551503 9.2010240,13.551504 C 9.5736843,13.551503 9.8936056,13.431269 10.160789,13.190801 C 10.427980,12.950332 10.561574,12.659238 10.561572,12.317520 C 10.561574,11.861896 10.322511,11.488536 9.8443836,11.197442 L 8.5998522,10.428575 L 14.548408,10.428575 C 15.026535,10.428577 15.406221,10.298849 15.687470,10.039395 C 15.968721,9.7799443 16.109345,9.4318977 16.109345,8.9952540 C 16.109345,8.5396330 15.961690,8.1915865 15.666377,7.9511133 C 15.364034,7.7106494 14.980831,7.5904152 14.516767,7.5904102 L 8.6314928,7.5904102 L 9.9920390,6.7076368 C 10.160793,6.5937365 10.290871,6.4481897 10.382274,6.2709962 C 10.466652,6.0874870 10.508840,5.8913153 10.508837,5.6824805 C 10.508840,5.3281127 10.378761,5.0338552 10.118602,4.7997070 C 9.8584498,4.5655745 9.5279814,4.4485043 9.1271961,4.4484962 C 8.7615757,4.4485043 8.4029823,4.5624104 8.0514147,4.7902149 L 3.9697741,7.5239649 C 3.6393151,7.7454540 3.4002529,7.9542820 3.2525866,8.1504493 C 3.0627532,8.3972503 2.9678314,8.6756875 2.9678210,8.9857618 L 2.9678210,9.0332227"
|
||||||
|
style="font-size:12.000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#ffffff;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;font-family:Verdana;text-anchor:start;writing-mode:lr-tb" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
style="display:none"
|
||||||
|
inkscape:label="pan triangle"
|
||||||
|
id="layer3"
|
||||||
|
inkscape:groupmode="layer">
|
||||||
|
<path
|
||||||
|
transform="matrix(0.000000,-1.331000,1.331000,0.000000,2.038879,16.92102)"
|
||||||
|
d="M 9.3471551,9.5937489 L 5.5311469,7.3905753 L 1.7151384,5.1874015 L 5.5311469,2.9842283 L 9.3471555,0.78105489 L 9.3471553,5.1874018 L 9.3471551,9.5937489 z "
|
||||||
|
inkscape:randomized="0.0000000"
|
||||||
|
inkscape:rounded="0.0000000"
|
||||||
|
inkscape:flatsided="false"
|
||||||
|
sodipodi:arg2="2.0943951"
|
||||||
|
sodipodi:arg1="1.0471976"
|
||||||
|
sodipodi:r2="2.5440056"
|
||||||
|
sodipodi:r1="5.0880113"
|
||||||
|
sodipodi:cy="5.1874018"
|
||||||
|
sodipodi:cx="6.8031497"
|
||||||
|
sodipodi:sides="3"
|
||||||
|
id="path2107"
|
||||||
|
style="fill:#ffffff;fill-opacity:1.0000000;stroke:none;stroke-width:39.984146;stroke-linejoin:round;stroke-miterlimit:4.0000000;stroke-opacity:1.0000000"
|
||||||
|
sodipodi:type="star" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 6.6 KiB |
67
examples/LayerSwitcher.html
Normal file
67
examples/LayerSwitcher.html
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="imagetoolbar" content="no"> <!--ie image gizmo OFF!-->
|
||||||
|
<style type="text/css">
|
||||||
|
#map {
|
||||||
|
width: 800px;
|
||||||
|
height: 475px;
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<!-- gmaps api key for http://openlayers.org/~euzuro -->
|
||||||
|
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA9XNhd8q0UdwNC7YSO4YZghQELW4Ku31wWCtlZquTlkHLCFh9LBTYvc_eIShlmo0YZwSitw0fQ1ZyXA'></script>
|
||||||
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
<!--
|
||||||
|
var lon = 5;
|
||||||
|
var lat = 40;
|
||||||
|
var zoom = 5;
|
||||||
|
var map, layer, glayer;
|
||||||
|
|
||||||
|
function init(){
|
||||||
|
map = new OpenLayers.Map( $('map') );
|
||||||
|
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||||
|
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
|
||||||
|
map.addLayer(layer);
|
||||||
|
|
||||||
|
glayer = new OpenLayers.Layer.Google("goog");
|
||||||
|
map.addLayer(glayer);
|
||||||
|
|
||||||
|
layer = new OpenLayers.Layer.WFS( "wfs",
|
||||||
|
"http://labs.metacarta.com/search/WFS?",
|
||||||
|
{maxfeatures: 1},
|
||||||
|
{ featureClass: OpenLayers.Feature.WFS});
|
||||||
|
map.addLayer(layer);
|
||||||
|
|
||||||
|
|
||||||
|
map.setCenter(new OpenLayers.LonLat(0, 0), 2);
|
||||||
|
|
||||||
|
map.addControl( new OpenLayers.Control.LayerSwitcher() );
|
||||||
|
}
|
||||||
|
|
||||||
|
function add() {
|
||||||
|
|
||||||
|
markers2 = new OpenLayers.Layer.Markers("markers2");
|
||||||
|
map.addLayer(markers2);
|
||||||
|
|
||||||
|
|
||||||
|
var icon = new OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png',new OpenLayers.Size(10,17));
|
||||||
|
marker = new OpenLayers.Marker(new OpenLayers.LonLat(2, 41), icon);
|
||||||
|
markers.addMarker(marker);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function remove() {
|
||||||
|
markers.removeMarker(marker);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -->
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body onload="init()">
|
||||||
|
<div id="map"></div>
|
||||||
|
<div style="background-color:green" onclick="add()"> click to add the marker to the map</div>
|
||||||
|
<div style="background-color:red" onclick="remove()"> click to remove the marker from the map</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
49
examples/boxes.html
Normal file
49
examples/boxes.html
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<style type="text/css">
|
||||||
|
#map {
|
||||||
|
width: 512px;
|
||||||
|
height: 512px;
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
<!--
|
||||||
|
box_extents = [
|
||||||
|
[-10, 50, 5, 60],
|
||||||
|
[-75, 41, -71, 44],
|
||||||
|
[-122.6, 37.6, -122.3, 37.9],
|
||||||
|
[10, 10, 20, 20]
|
||||||
|
];
|
||||||
|
|
||||||
|
function init(){
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
|
||||||
|
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||||
|
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
|
||||||
|
|
||||||
|
var boxes = new OpenLayers.Layer.Boxes( "Boxes" );
|
||||||
|
|
||||||
|
for (var i = 0; i < box_extents.length; i++) {
|
||||||
|
ext = box_extents[i];
|
||||||
|
bounds = new OpenLayers.Bounds(ext[0], ext[1], ext[2], ext[3]);
|
||||||
|
box = new OpenLayers.Marker.Box(bounds);
|
||||||
|
box.events.register("click", box, function (e) {
|
||||||
|
this.setBorder("yellow");
|
||||||
|
});
|
||||||
|
boxes.addMarker(box);
|
||||||
|
}
|
||||||
|
|
||||||
|
map.addLayers([ol_wms, boxes]);
|
||||||
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
|
map.zoomToMaxExtent();
|
||||||
|
}
|
||||||
|
// -->
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body onload="init()">
|
||||||
|
<h1>OpenLayers Example</h1>
|
||||||
|
<div id="map"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
function init(){
|
function init(){
|
||||||
map = new OpenLayers.Map( $('map') );
|
map = new OpenLayers.Map( $('map') );
|
||||||
gmap = new OpenLayers.Layer.Google( "Google" );
|
gmap = new OpenLayers.Layer.Google( "Google" , {type: G_HYBRID_MAP });
|
||||||
map.addLayer(gmap);
|
map.addLayer(gmap);
|
||||||
|
|
||||||
markers = new OpenLayers.Layer.Markers("markers");
|
markers = new OpenLayers.Layer.Markers("markers");
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
|
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
|
||||||
map.addControl( new OpenLayers.Control.LayerSwitcher() );
|
map.addControl( new OpenLayers.Control.LayerSwitcher() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function add() {
|
function add() {
|
||||||
@@ -49,7 +50,6 @@
|
|||||||
<body onload="init()">
|
<body onload="init()">
|
||||||
<h1>OpenLayers With Google Layer Example</h1>
|
<h1>OpenLayers With Google Layer Example</h1>
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
<div style="background-color:green" onclick="add()"> click to add the marker to the map</div>
|
|
||||||
<div style="background-color:red" onclick="remove()"> click to remove the marker from the map</div>
|
<div style="background-color:red" onclick="remove()"> click to remove the marker from the map</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 249 B |
@@ -58,6 +58,7 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
|
|||||||
"OpenLayers/Layer.js",
|
"OpenLayers/Layer.js",
|
||||||
"OpenLayers/Icon.js",
|
"OpenLayers/Icon.js",
|
||||||
"OpenLayers/Marker.js",
|
"OpenLayers/Marker.js",
|
||||||
|
"OpenLayers/Marker/Box.js",
|
||||||
"OpenLayers/Popup.js",
|
"OpenLayers/Popup.js",
|
||||||
"OpenLayers/Tile.js",
|
"OpenLayers/Tile.js",
|
||||||
"OpenLayers/Feature.js",
|
"OpenLayers/Feature.js",
|
||||||
@@ -77,6 +78,7 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
|
|||||||
"OpenLayers/Layer/WFS.js",
|
"OpenLayers/Layer/WFS.js",
|
||||||
"OpenLayers/Layer/WMS/Untiled.js",
|
"OpenLayers/Layer/WMS/Untiled.js",
|
||||||
"OpenLayers/Layer/GeoRSS.js",
|
"OpenLayers/Layer/GeoRSS.js",
|
||||||
|
"OpenLayers/Layer/Boxes.js",
|
||||||
"OpenLayers/Popup/Anchored.js",
|
"OpenLayers/Popup/Anchored.js",
|
||||||
"OpenLayers/Popup/AnchoredBubble.js",
|
"OpenLayers/Popup/AnchoredBubble.js",
|
||||||
"OpenLayers/Control.js",
|
"OpenLayers/Control.js",
|
||||||
@@ -87,7 +89,8 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
|
|||||||
"OpenLayers/Control/PanZoomBar.js",
|
"OpenLayers/Control/PanZoomBar.js",
|
||||||
"OpenLayers/Control/Permalink.js",
|
"OpenLayers/Control/Permalink.js",
|
||||||
"OpenLayers/Control/Scale.js",
|
"OpenLayers/Control/Scale.js",
|
||||||
"OpenLayers/Control/LayerSwitcher.js"
|
"OpenLayers/Control/LayerSwitcher.js",
|
||||||
|
"OpenLayers/Control/LayerTabs.js"
|
||||||
); // etc.
|
); // etc.
|
||||||
|
|
||||||
var allScriptTags = "";
|
var allScriptTags = "";
|
||||||
|
|||||||
@@ -1,225 +1,396 @@
|
|||||||
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
||||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||||
* text of the license. */
|
* text of the license. */
|
||||||
|
|
||||||
// @require: OpenLayers/Control.js
|
// @require: OpenLayers/Control.js
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
OpenLayers.Control.LayerSwitcher = Class.create();
|
OpenLayers.Control.LayerSwitcher = Class.create();
|
||||||
|
|
||||||
/** color used in the UI to show a layer is active/displayed
|
|
||||||
*
|
|
||||||
* @final
|
|
||||||
* @type String
|
|
||||||
*/
|
|
||||||
OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR = "darkblue";
|
|
||||||
|
|
||||||
/** color used in the UI to show a layer is deactivated/hidden
|
|
||||||
*
|
|
||||||
* @final
|
|
||||||
* @type String
|
|
||||||
*/
|
|
||||||
OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR = "lightblue";
|
|
||||||
|
|
||||||
|
|
||||||
OpenLayers.Control.LayerSwitcher.prototype =
|
OpenLayers.Control.LayerSwitcher.prototype =
|
||||||
Object.extend( new OpenLayers.Control(), {
|
Object.extend( new OpenLayers.Control(), {
|
||||||
|
|
||||||
/** @type String */
|
/** @type String */
|
||||||
activeColor: "",
|
activeColor: "darkblue",
|
||||||
|
|
||||||
/** @type String */
|
|
||||||
nonActiveColor: "",
|
|
||||||
|
|
||||||
/** @type String */
|
// DOM Elements
|
||||||
mode: "checkbox",
|
|
||||||
|
/** @type DOMElement */
|
||||||
|
layersDiv: null,
|
||||||
|
|
||||||
|
/** @type DOMElement */
|
||||||
|
baseLayersDiv: null,
|
||||||
|
|
||||||
|
/** @type Array */
|
||||||
|
baseLayerInputs: null,
|
||||||
|
|
||||||
|
/** @type DOMElement */
|
||||||
|
dataLayersDiv: null,
|
||||||
|
|
||||||
|
/** @type Array */
|
||||||
|
dataLayerInputs: null,
|
||||||
|
|
||||||
|
|
||||||
|
/** @type DOMElement */
|
||||||
|
minimizeDiv: null,
|
||||||
|
|
||||||
|
/** @type DOMElement */
|
||||||
|
maximizeDiv: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.activeColor = OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR;
|
|
||||||
this.nonActiveColor = OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR;
|
|
||||||
this.backdrops = [];
|
|
||||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {OpenLayers.Map} map
|
||||||
|
*/
|
||||||
|
setMap: function(map) {
|
||||||
|
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||||
|
|
||||||
|
this.map.events.register("addlayer", this, this.redraw);
|
||||||
|
this.map.events.register("changelayer", this, this.redraw);
|
||||||
|
this.map.events.register("removelayer", this, this.redraw);
|
||||||
|
this.map.events.register("changebaselayer", this, this.redraw);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns A reference to the DIV DOMElement containing the switcher tabs
|
* @returns A reference to the DIV DOMElement containing the switcher tabs
|
||||||
* @type DOMElement
|
* @type DOMElement
|
||||||
*/
|
*/
|
||||||
draw: function() {
|
draw: function() {
|
||||||
// initialize our internal div
|
|
||||||
OpenLayers.Control.prototype.draw.apply(this);
|
OpenLayers.Control.prototype.draw.apply(this);
|
||||||
|
|
||||||
this.div.style.position = "absolute";
|
// create layout divs
|
||||||
this.div.style.top = "10px";
|
this.loadContents();
|
||||||
this.div.style.right = "0px";
|
|
||||||
this.div.style.left = "";
|
|
||||||
this.div.style.fontFamily = "sans-serif";
|
|
||||||
this.div.style.color = "white";
|
|
||||||
this.div.style.fontWeight = "bold";
|
|
||||||
this.div.style.marginTop = "3px";
|
|
||||||
this.div.style.marginLeft = "3px";
|
|
||||||
this.div.style.marginBottom = "3px";
|
|
||||||
this.div.style.fontSize="smaller";
|
|
||||||
this.div.style.width = "10em";
|
|
||||||
|
|
||||||
this.map.events.register("addlayer", this, this.redraw);
|
// set mode to minimize
|
||||||
this.map.events.register("removelayer", this, this.redraw);
|
this.minimizeControl();
|
||||||
this.map.events.register("changelayer", this, this.redraw);
|
|
||||||
return this.redraw();
|
// populate div with current info
|
||||||
|
this.redraw();
|
||||||
|
|
||||||
|
return this.div;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/** Goes through and takes the current state of the Map and rebuilds the
|
||||||
* @returns A reference to the DIV DOMElement containing the switcher tabs
|
* control to display that state. Groups base layers into a radio-button
|
||||||
|
* group and lists each data layer with a checkbox.
|
||||||
|
*
|
||||||
|
* @returns A reference to the DIV DOMElement containing the control
|
||||||
* @type DOMElement
|
* @type DOMElement
|
||||||
*/
|
*/
|
||||||
redraw: function() {
|
redraw: function() {
|
||||||
|
|
||||||
//clear out previous incarnation of LayerSwitcher tabs
|
//clear out previous layers
|
||||||
this.div.innerHTML = "";
|
this.baseLayersDiv.innerHTML = "";
|
||||||
var visible = false;
|
this.baseLayerInputs = new Array();
|
||||||
|
|
||||||
|
this.dataLayersDiv.innerHTML = "";
|
||||||
|
this.dataLayerInputs = new Array();
|
||||||
|
|
||||||
for( var i = 0; i < this.map.layers.length; i++) {
|
for( var i = 0; i < this.map.layers.length; i++) {
|
||||||
if (visible && this.mode == "radio") {
|
var layer = this.map.layers[i];
|
||||||
this.map.layers[i].setVisibility(false);
|
var baseLayer = layer.isBaseLayer;
|
||||||
} else {
|
|
||||||
visible = this.map.layers[i].getVisibility();
|
// only check a baselayer if it is *the* baselayer, check data
|
||||||
}
|
// layers if they are visible
|
||||||
this.addTab(this.map.layers[i]);
|
var checked = (baseLayer) ? (layer == this.map.baseLayer)
|
||||||
|
: layer.getVisibility();
|
||||||
|
|
||||||
|
// create input element
|
||||||
|
var inputElem = document.createElement("input");
|
||||||
|
inputElem.id = "input_" + layer.name;
|
||||||
|
inputElem.name = (baseLayer) ? "baseLayers" : layer.name;
|
||||||
|
inputElem.type = (baseLayer) ? "radio" : "checkbox";
|
||||||
|
inputElem.value = layer.name;
|
||||||
|
inputElem.checked = checked;
|
||||||
|
inputElem.layer = layer;
|
||||||
|
|
||||||
|
// create span
|
||||||
|
var labelSpan = document.createElement("span");
|
||||||
|
labelSpan.innerHTML = layer.name;
|
||||||
|
labelSpan.style.verticalAlign = (baseLayer) ? "bottom" : "auto";
|
||||||
|
Event.observe(labelSpan,
|
||||||
|
"click",
|
||||||
|
this.onLabelClick.bindAsEventListener(inputElem));
|
||||||
|
|
||||||
|
// create line break
|
||||||
|
var br = document.createElement("br");
|
||||||
|
|
||||||
|
|
||||||
|
var groupArray = (baseLayer) ? this.baseLayerInputs
|
||||||
|
: this.dataLayerInputs;
|
||||||
|
groupArray.push(inputElem);
|
||||||
|
|
||||||
|
|
||||||
|
var groupDiv = (baseLayer) ? this.baseLayersDiv
|
||||||
|
: this.dataLayersDiv;
|
||||||
|
groupDiv.appendChild(inputElem);
|
||||||
|
groupDiv.appendChild(labelSpan);
|
||||||
|
groupDiv.appendChild(br);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.div;
|
return this.div;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/** A label has been clicked, check or uncheck its corresponding input
|
||||||
* @param {event} evt
|
*
|
||||||
|
* @private
|
||||||
|
*
|
||||||
|
* @param {Event} e
|
||||||
*/
|
*/
|
||||||
singleClick: function(evt) {
|
onLabelClick: function(e) {
|
||||||
var div = Event.element(evt);
|
this.checked = !this.checked;
|
||||||
|
},
|
||||||
|
|
||||||
// See comment about OL #57 fix below.
|
/** Need to update the map accordingly whenever user clicks in either of
|
||||||
// If the click occurred on the corner spans we need
|
* the layers.
|
||||||
// to make sure we act on the actual label tab instead.
|
*
|
||||||
div = div.labelElement || div;
|
* @private
|
||||||
|
*
|
||||||
|
* @param {Event} e
|
||||||
|
*/
|
||||||
|
onLayerClick: function(e) {
|
||||||
|
this.updateMap();
|
||||||
|
},
|
||||||
|
|
||||||
var layer = div.layer;
|
|
||||||
if (this.mode == "radio") {
|
/** Cycles through the loaded data and base layer input arrays and makes
|
||||||
for(var i=0; i < this.backdrops.length; i++) {
|
* the necessary calls to the Map object such that that the map's
|
||||||
this.setTabActivation(this.backdrops[i], false);
|
* visual state corresponds to what the user has selected in the control
|
||||||
this.backdrops[i].layer.setVisibility(false);
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
updateMap: function() {
|
||||||
|
|
||||||
|
// set the newly selected base layer
|
||||||
|
for(var i=0; i < this.baseLayerInputs.length; i++) {
|
||||||
|
var input = this.baseLayerInputs[i];
|
||||||
|
if (input.checked) {
|
||||||
|
this.map.setBaseLayer(input.layer, true);
|
||||||
}
|
}
|
||||||
this.setTabActivation(div, true);
|
|
||||||
layer.setVisibility(true);
|
|
||||||
} else {
|
|
||||||
var visible = layer.getVisibility();
|
|
||||||
|
|
||||||
this.setTabActivation(div, !visible);
|
|
||||||
layer.setVisibility(!visible);
|
|
||||||
}
|
}
|
||||||
Event.stop(evt);
|
|
||||||
|
// set the correct visibilities for the overlays
|
||||||
|
for(var i=0; i < this.dataLayerInputs.length; i++) {
|
||||||
|
var input = this.dataLayerInputs[i];
|
||||||
|
input.layer.setVisibility(input.checked, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Set up the labels and divs for the control
|
||||||
|
*
|
||||||
|
* @param {Event} e
|
||||||
|
*/
|
||||||
|
maximizeControl: function(e) {
|
||||||
|
|
||||||
|
//HACK HACK HACK - find a way to auto-size this layerswitcher
|
||||||
|
this.div.style.width = "20em";
|
||||||
|
this.div.style.height = "";
|
||||||
|
|
||||||
|
this.showControls(false);
|
||||||
|
|
||||||
|
if (e != null) {
|
||||||
|
Event.stop(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Hide all the contents of the control, shrink the size,
|
||||||
|
* add the maximize icon
|
||||||
|
*
|
||||||
|
* @param {Event} e
|
||||||
|
*/
|
||||||
|
minimizeControl: function(e) {
|
||||||
|
|
||||||
|
this.div.style.width = "0px";
|
||||||
|
this.div.style.height = "0px";
|
||||||
|
|
||||||
|
// this.div.style.backgroundColor = "transparent";
|
||||||
|
|
||||||
|
this.showControls(true);
|
||||||
|
|
||||||
|
if (e != null) {
|
||||||
|
Event.stop(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Hide/Show all LayerSwitcher controls depending on whether we are
|
||||||
|
* minimized or not
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*
|
||||||
|
* @param {Boolean} minimize
|
||||||
|
*/
|
||||||
|
showControls: function(minimize) {
|
||||||
|
|
||||||
|
this.maximizeDiv.style.display = minimize ? "" : "none";
|
||||||
|
this.minimizeDiv.style.display = minimize ? "none" : "";
|
||||||
|
|
||||||
|
this.layersDiv.style.display = minimize ? "none" : "";
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Set up the labels and divs for the control
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
loadContents: function() {
|
||||||
|
|
||||||
|
//configure main div
|
||||||
|
this.div.style.position = "absolute";
|
||||||
|
this.div.style.top = "10px";
|
||||||
|
this.div.style.right = "0px";
|
||||||
|
this.div.style.left = "";
|
||||||
|
this.div.style.fontFamily = "sans-serif";
|
||||||
|
this.div.style.fontWeight = "bold";
|
||||||
|
this.div.style.marginTop = "3px";
|
||||||
|
this.div.style.marginLeft = "3px";
|
||||||
|
this.div.style.marginBottom = "3px";
|
||||||
|
this.div.style.fontSize = "smaller";
|
||||||
|
this.div.style.color = "white";
|
||||||
|
this.div.style.backgroundColor = "transparent";
|
||||||
|
|
||||||
|
Event.observe(this.div, "mouseup",
|
||||||
|
this.mouseUp.bindAsEventListener(this));
|
||||||
|
Event.observe(this.div, "mousedown",
|
||||||
|
this.mouseDown.bindAsEventListener(this));
|
||||||
|
Event.observe(this.div, "dblclick", this.ignoreEvent);
|
||||||
|
|
||||||
|
|
||||||
|
// layers list div
|
||||||
|
this.layersDiv = document.createElement("div");
|
||||||
|
this.layersDiv.id = "layersDiv";
|
||||||
|
this.layersDiv.style.paddingTop = "5px";
|
||||||
|
this.layersDiv.style.paddingLeft = "10px";
|
||||||
|
this.layersDiv.style.paddingBottom = "5px";
|
||||||
|
this.layersDiv.style.paddingRight = "75px";
|
||||||
|
this.layersDiv.style.backgroundColor = this.activeColor;
|
||||||
|
|
||||||
|
// had to set width/height to get transparency in IE to work.
|
||||||
|
// thanks -- http://jszen.blogspot.com/2005/04/ie6-opacity-filter-caveat.html
|
||||||
|
//
|
||||||
|
this.layersDiv.style.width = "100%";
|
||||||
|
this.layersDiv.style.height = "100%";
|
||||||
|
|
||||||
|
|
||||||
|
var baseLbl = document.createElement("div");
|
||||||
|
baseLbl.innerHTML = "<u>Base Layer</u>";
|
||||||
|
baseLbl.style.marginTop = "3px";
|
||||||
|
baseLbl.style.marginLeft = "3px";
|
||||||
|
baseLbl.style.marginBottom = "3px";
|
||||||
|
this.layersDiv.appendChild(baseLbl);
|
||||||
|
|
||||||
|
this.baseLayersDiv = document.createElement("div");
|
||||||
|
this.baseLayersDiv.style.paddingLeft = "10px";
|
||||||
|
Event.observe(this.baseLayersDiv, "click",
|
||||||
|
this.onLayerClick.bindAsEventListener(this));
|
||||||
|
this.layersDiv.appendChild(this.baseLayersDiv);
|
||||||
|
|
||||||
|
|
||||||
|
var dataLbl = document.createElement("div");
|
||||||
|
dataLbl.innerHTML = "<u>Overlays</u>";
|
||||||
|
dataLbl.style.marginTop = "3px";
|
||||||
|
dataLbl.style.marginLeft = "3px";
|
||||||
|
dataLbl.style.marginBottom = "3px";
|
||||||
|
this.layersDiv.appendChild(dataLbl);
|
||||||
|
|
||||||
|
this.dataLayersDiv = document.createElement("div");
|
||||||
|
this.dataLayersDiv.style.paddingLeft = "10px";
|
||||||
|
Event.observe(this.dataLayersDiv, "click",
|
||||||
|
this.onLayerClick.bindAsEventListener(this));
|
||||||
|
this.layersDiv.appendChild(this.dataLayersDiv);
|
||||||
|
|
||||||
|
this.div.appendChild(this.layersDiv);
|
||||||
|
|
||||||
|
Rico.Corner.round(this.div, {corners: "tl bl",
|
||||||
|
bgColor: "transparent",
|
||||||
|
color: this.activeColor,
|
||||||
|
blend: false});
|
||||||
|
|
||||||
|
Rico.Corner.changeOpacity(this.layersDiv, 0.75);
|
||||||
|
|
||||||
|
var imgLocation = OpenLayers.Util.getImagesLocation();
|
||||||
|
var sz = new OpenLayers.Size(18,18);
|
||||||
|
|
||||||
|
// maximize button div
|
||||||
|
var img = imgLocation + 'layer-switcher-maximize.png';
|
||||||
|
this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(
|
||||||
|
"OpenLayers_Control_ResizeDiv",
|
||||||
|
null,
|
||||||
|
sz,
|
||||||
|
img,
|
||||||
|
"absolute");
|
||||||
|
this.maximizeDiv.style.top = "5px";
|
||||||
|
this.maximizeDiv.style.right = "0px";
|
||||||
|
this.maximizeDiv.style.left = "";
|
||||||
|
this.maximizeDiv.style.display = "none";
|
||||||
|
Event.observe(this.maximizeDiv,
|
||||||
|
"click",
|
||||||
|
this.maximizeControl.bindAsEventListener(this));
|
||||||
|
|
||||||
|
this.div.appendChild(this.maximizeDiv);
|
||||||
|
|
||||||
|
// minimize button div
|
||||||
|
var img = imgLocation + 'layer-switcher-minimize.png';
|
||||||
|
var sz = new OpenLayers.Size(18,18);
|
||||||
|
this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(
|
||||||
|
"OpenLayers_Control_ResizeDiv",
|
||||||
|
null,
|
||||||
|
sz,
|
||||||
|
img,
|
||||||
|
"absolute");
|
||||||
|
this.minimizeDiv.style.top = "5px";
|
||||||
|
this.minimizeDiv.style.right = "0px";
|
||||||
|
this.minimizeDiv.style.left = "";
|
||||||
|
this.minimizeDiv.style.display = "none";
|
||||||
|
Event.observe(this.minimizeDiv,
|
||||||
|
"click",
|
||||||
|
this.minimizeControl.bindAsEventListener(this));
|
||||||
|
|
||||||
|
this.div.appendChild(this.minimizeDiv);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*
|
*
|
||||||
* @param {event} evt
|
* @param {Event} evt
|
||||||
*/
|
*/
|
||||||
ignoreEvent: function(evt) {
|
ignoreEvent: function(evt) {
|
||||||
Event.stop(evt);
|
Event.stop(evt);
|
||||||
return false;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/** Register a local 'mouseDown' flag so that we'll know whether or not
|
||||||
|
* to ignore a mouseUp event
|
||||||
|
*
|
||||||
* @private
|
* @private
|
||||||
*
|
*
|
||||||
* @param {OpenLayers.Layer} layer
|
* @param {Event} evt
|
||||||
*/
|
*/
|
||||||
addTab: function(layer) {
|
mouseDown: function(evt) {
|
||||||
|
this.mouseDown = true;
|
||||||
// Outer DIV - for Rico Corners
|
this.ignoreEvent(evt);
|
||||||
//
|
|
||||||
var backdropLabelOuter = document.createElement('div');
|
|
||||||
backdropLabelOuter.id = "LayerSwitcher_" + layer.name + "_Tab";
|
|
||||||
backdropLabelOuter.style.marginTop = "4px";
|
|
||||||
backdropLabelOuter.style.marginBottom = "4px";
|
|
||||||
|
|
||||||
this._setEventHandlers(backdropLabelOuter);
|
|
||||||
|
|
||||||
// Inner Label - for Rico Corners
|
|
||||||
//
|
|
||||||
var backdropLabel = document.createElement('p');
|
|
||||||
backdropLabel.innerHTML = layer.name;
|
|
||||||
backdropLabel.style.marginTop = "0px";
|
|
||||||
backdropLabel.style.marginBottom = "0px";
|
|
||||||
backdropLabel.style.paddingLeft = "10px";
|
|
||||||
backdropLabel.style.paddingRight = "10px";
|
|
||||||
|
|
||||||
// add reference to layer onto the div for use in event handlers
|
|
||||||
backdropLabel.layer = layer;
|
|
||||||
|
|
||||||
// set event handlers
|
|
||||||
this._setEventHandlers(backdropLabel);
|
|
||||||
|
|
||||||
// add label to div
|
|
||||||
backdropLabelOuter.appendChild(backdropLabel);
|
|
||||||
|
|
||||||
this.backdrops.append(backdropLabel);
|
|
||||||
|
|
||||||
// add div to main LayerSwitcher Div
|
|
||||||
this.div.appendChild(backdropLabelOuter);
|
|
||||||
|
|
||||||
Rico.Corner.round(backdropLabelOuter, {corners: "tl bl",
|
|
||||||
bgColor: "transparent",
|
|
||||||
color: "white",
|
|
||||||
blend: false});
|
|
||||||
|
|
||||||
// extend the event handlers to operate on the
|
|
||||||
// rounded corners as well. (Fixes OL #57.)
|
|
||||||
var spanElements=backdropLabel.parentNode.getElementsByTagName("span");
|
|
||||||
|
|
||||||
for (var currIdx = 0; currIdx < spanElements.length; currIdx++) {
|
|
||||||
this._setEventHandlers(spanElements[currIdx], backdropLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setTabActivation(backdropLabel, layer.getVisibility());
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/** If the 'mouseDown' flag has been set, that means that the drag was
|
||||||
@private
|
* started from within the LayerSwitcher control, and thus we can
|
||||||
|
* ignore the mouseup. Otherwise, let the Event continue.
|
||||||
@param {DOMElement} div
|
*
|
||||||
@param {Boolean} activate
|
|
||||||
*/
|
|
||||||
_setEventHandlers : function(element, labelDiv) {
|
|
||||||
|
|
||||||
// We only want to respond to a mousedown event.
|
|
||||||
element.onclick = this.singleClick.bindAsEventListener(this);
|
|
||||||
element.ondblclick = this.singleClick.bindAsEventListener(this);
|
|
||||||
element.onmouseup = this.ignoreEvent.bindAsEventListener(this);
|
|
||||||
element.onmousedown = this.ignoreEvent.bindAsEventListener(this);
|
|
||||||
|
|
||||||
// If we are operating on a corner span we need to store a
|
|
||||||
// reference to the actual tab. (See comment about OL #57 fix above.)
|
|
||||||
if (labelDiv) {
|
|
||||||
element.labelElement = labelDiv;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
* @private
|
||||||
*
|
*
|
||||||
* @param {DOMElement} div
|
* @param {Event} evt
|
||||||
* @param {Boolean} activate
|
|
||||||
*/
|
*/
|
||||||
setTabActivation:function(div, activate) {
|
mouseUp: function(evt) {
|
||||||
var color = (activate) ? this.activeColor : this.nonActiveColor;
|
if (this.mouseDown) {
|
||||||
Rico.Corner.changeColor(div, color);
|
this.mouseDown = false;
|
||||||
|
this.ignoreEvent(evt);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @final @type String */
|
/** @final @type String */
|
||||||
CLASS_NAME: "OpenLayers.Control.LayerSwitcher"
|
CLASS_NAME: "OpenLayers.Control.LayerSwitcher"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
224
lib/OpenLayers/Control/LayerTabs.js
Normal file
224
lib/OpenLayers/Control/LayerTabs.js
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
||||||
|
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||||
|
* text of the license. */
|
||||||
|
// @require: OpenLayers/Control.js
|
||||||
|
/**
|
||||||
|
* @class
|
||||||
|
*/
|
||||||
|
OpenLayers.Control.LayerTabs = Class.create();
|
||||||
|
|
||||||
|
/** color used in the UI to show a layer is active/displayed
|
||||||
|
*
|
||||||
|
* @final
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
|
OpenLayers.Control.LayerTabs.ACTIVE_COLOR = "darkblue";
|
||||||
|
|
||||||
|
/** color used in the UI to show a layer is deactivated/hidden
|
||||||
|
*
|
||||||
|
* @final
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
|
OpenLayers.Control.LayerTabs.NONACTIVE_COLOR = "lightblue";
|
||||||
|
|
||||||
|
|
||||||
|
OpenLayers.Control.LayerTabs.prototype =
|
||||||
|
Object.extend( new OpenLayers.Control(), {
|
||||||
|
|
||||||
|
/** @type String */
|
||||||
|
activeColor: "",
|
||||||
|
|
||||||
|
/** @type String */
|
||||||
|
nonActiveColor: "",
|
||||||
|
|
||||||
|
/** @type String */
|
||||||
|
mode: "checkbox",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
initialize: function(options) {
|
||||||
|
this.activeColor = OpenLayers.Control.LayerTabs.ACTIVE_COLOR;
|
||||||
|
this.nonActiveColor = OpenLayers.Control.LayerTabs.NONACTIVE_COLOR;
|
||||||
|
this.backdrops = [];
|
||||||
|
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns A reference to the DIV DOMElement containing the switcher tabs
|
||||||
|
* @type DOMElement
|
||||||
|
*/
|
||||||
|
draw: function() {
|
||||||
|
// initialize our internal div
|
||||||
|
OpenLayers.Control.prototype.draw.apply(this);
|
||||||
|
|
||||||
|
this.div.style.position = "absolute";
|
||||||
|
this.div.style.top = "10px";
|
||||||
|
this.div.style.right = "0px";
|
||||||
|
this.div.style.left = "";
|
||||||
|
this.div.style.fontFamily = "sans-serif";
|
||||||
|
this.div.style.color = "white";
|
||||||
|
this.div.style.fontWeight = "bold";
|
||||||
|
this.div.style.marginTop = "3px";
|
||||||
|
this.div.style.marginLeft = "3px";
|
||||||
|
this.div.style.marginBottom = "3px";
|
||||||
|
this.div.style.fontSize="smaller";
|
||||||
|
this.div.style.width = "10em";
|
||||||
|
|
||||||
|
this.map.events.register("addlayer", this, this.redraw);
|
||||||
|
this.map.events.register("removelayer", this, this.redraw);
|
||||||
|
return this.redraw();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns A reference to the DIV DOMElement containing the switcher tabs
|
||||||
|
* @type DOMElement
|
||||||
|
*/
|
||||||
|
redraw: function() {
|
||||||
|
|
||||||
|
//clear out previous incarnation of LayerTabs tabs
|
||||||
|
this.div.innerHTML = "";
|
||||||
|
var visible = false;
|
||||||
|
for( var i = 0; i < this.map.layers.length; i++) {
|
||||||
|
if (visible && this.mode == "radio") {
|
||||||
|
this.map.layers[i].setVisibility(false);
|
||||||
|
} else {
|
||||||
|
visible = this.map.layers[i].getVisibility();
|
||||||
|
}
|
||||||
|
this.addTab(this.map.layers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.div;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {event} evt
|
||||||
|
*/
|
||||||
|
singleClick: function(evt) {
|
||||||
|
var div = Event.element(evt);
|
||||||
|
|
||||||
|
// See comment about OL #57 fix below.
|
||||||
|
// If the click occurred on the corner spans we need
|
||||||
|
// to make sure we act on the actual label tab instead.
|
||||||
|
div = div.labelElement || div;
|
||||||
|
|
||||||
|
var layer = div.layer;
|
||||||
|
if (this.mode == "radio") {
|
||||||
|
for(var i=0; i < this.backdrops.length; i++) {
|
||||||
|
this.setTabActivation(this.backdrops[i], false);
|
||||||
|
this.backdrops[i].layer.setVisibility(false);
|
||||||
|
}
|
||||||
|
this.setTabActivation(div, true);
|
||||||
|
layer.setVisibility(true);
|
||||||
|
} else {
|
||||||
|
var visible = layer.getVisibility();
|
||||||
|
|
||||||
|
this.setTabActivation(div, !visible);
|
||||||
|
layer.setVisibility(!visible);
|
||||||
|
}
|
||||||
|
Event.stop(evt);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*
|
||||||
|
* @param {event} evt
|
||||||
|
*/
|
||||||
|
ignoreEvent: function(evt) {
|
||||||
|
Event.stop(evt);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*
|
||||||
|
* @param {OpenLayers.Layer} layer
|
||||||
|
*/
|
||||||
|
addTab: function(layer) {
|
||||||
|
|
||||||
|
// Outer DIV - for Rico Corners
|
||||||
|
//
|
||||||
|
var backdropLabelOuter = document.createElement('div');
|
||||||
|
backdropLabelOuter.id = "LayerTabs_" + layer.name + "_Tab";
|
||||||
|
backdropLabelOuter.style.marginTop = "4px";
|
||||||
|
backdropLabelOuter.style.marginBottom = "4px";
|
||||||
|
|
||||||
|
this._setEventHandlers(backdropLabelOuter);
|
||||||
|
|
||||||
|
// Inner Label - for Rico Corners
|
||||||
|
//
|
||||||
|
var backdropLabel = document.createElement('p');
|
||||||
|
backdropLabel.innerHTML = layer.name;
|
||||||
|
backdropLabel.style.marginTop = "0px";
|
||||||
|
backdropLabel.style.marginBottom = "0px";
|
||||||
|
backdropLabel.style.paddingLeft = "10px";
|
||||||
|
backdropLabel.style.paddingRight = "10px";
|
||||||
|
|
||||||
|
// add reference to layer onto the div for use in event handlers
|
||||||
|
backdropLabel.layer = layer;
|
||||||
|
|
||||||
|
// set event handlers
|
||||||
|
this._setEventHandlers(backdropLabel);
|
||||||
|
|
||||||
|
// add label to div
|
||||||
|
backdropLabelOuter.appendChild(backdropLabel);
|
||||||
|
|
||||||
|
this.backdrops.append(backdropLabel);
|
||||||
|
|
||||||
|
// add div to main LayerTabs Div
|
||||||
|
this.div.appendChild(backdropLabelOuter);
|
||||||
|
|
||||||
|
Rico.Corner.round(backdropLabelOuter, {corners: "tl bl",
|
||||||
|
bgColor: "transparent",
|
||||||
|
color: "white",
|
||||||
|
blend: false});
|
||||||
|
|
||||||
|
// extend the event handlers to operate on the
|
||||||
|
// rounded corners as well. (Fixes OL #57.)
|
||||||
|
var spanElements=backdropLabel.parentNode.getElementsByTagName("span");
|
||||||
|
|
||||||
|
for (var currIdx = 0; currIdx < spanElements.length; currIdx++) {
|
||||||
|
this._setEventHandlers(spanElements[currIdx], backdropLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setTabActivation(backdropLabel, layer.getVisibility());
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
@private
|
||||||
|
|
||||||
|
@param {DOMElement} div
|
||||||
|
@param {Boolean} activate
|
||||||
|
*/
|
||||||
|
_setEventHandlers : function(element, labelDiv) {
|
||||||
|
|
||||||
|
// We only want to respond to a mousedown event.
|
||||||
|
element.onclick = this.singleClick.bindAsEventListener(this);
|
||||||
|
element.ondblclick = this.singleClick.bindAsEventListener(this);
|
||||||
|
element.onmouseup = this.ignoreEvent.bindAsEventListener(this);
|
||||||
|
element.onmousedown = this.ignoreEvent.bindAsEventListener(this);
|
||||||
|
|
||||||
|
// If we are operating on a corner span we need to store a
|
||||||
|
// reference to the actual tab. (See comment about OL #57 fix above.)
|
||||||
|
if (labelDiv) {
|
||||||
|
element.labelElement = labelDiv;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*
|
||||||
|
* @param {DOMElement} div
|
||||||
|
* @param {Boolean} activate
|
||||||
|
*/
|
||||||
|
setTabActivation:function(div, activate) {
|
||||||
|
var color = (activate) ? this.activeColor : this.nonActiveColor;
|
||||||
|
Rico.Corner.changeColor(div, color);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** @final @type String */
|
||||||
|
CLASS_NAME: "OpenLayers.Control.LayerTabs"
|
||||||
|
});
|
||||||
|
|
||||||
@@ -85,6 +85,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
|||||||
*/
|
*/
|
||||||
defaultDblClick: function (evt) {
|
defaultDblClick: function (evt) {
|
||||||
this.switchModeTo("pan");
|
this.switchModeTo("pan");
|
||||||
|
this.performedDrag = false;
|
||||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||||
this.map.setCenter(newCenter, this.map.zoom + 2);
|
this.map.setCenter(newCenter, this.map.zoom + 2);
|
||||||
},
|
},
|
||||||
@@ -95,6 +96,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
|||||||
defaultMouseDown: function (evt) {
|
defaultMouseDown: function (evt) {
|
||||||
if (!Event.isLeftClick(evt)) return;
|
if (!Event.isLeftClick(evt)) return;
|
||||||
this.mouseDragStart = evt.xy.clone();
|
this.mouseDragStart = evt.xy.clone();
|
||||||
|
this.performedDrag = false;
|
||||||
if (evt.shiftKey && this.mode !="zoombox") {
|
if (evt.shiftKey && this.mode !="zoombox") {
|
||||||
this.switchModeTo("zoombox");
|
this.switchModeTo("zoombox");
|
||||||
} else if (evt.altKey && this.mode !="measure") {
|
} else if (evt.altKey && this.mode !="measure") {
|
||||||
@@ -217,6 +219,7 @@ OpenLayers.Control.MouseToolbar.prototype =
|
|||||||
this.map.setCenter(newCenter, null, true);
|
this.map.setCenter(newCenter, null, true);
|
||||||
this.mouseDragStart = evt.xy.clone();
|
this.mouseDragStart = evt.xy.clone();
|
||||||
}
|
}
|
||||||
|
this.performedDrag = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -244,8 +247,9 @@ OpenLayers.Control.MouseToolbar.prototype =
|
|||||||
this.leaveMode();
|
this.leaveMode();
|
||||||
break;
|
break;
|
||||||
case "pan":
|
case "pan":
|
||||||
|
if (this.performedDrag) {
|
||||||
this.map.setCenter(this.map.center);
|
this.map.setCenter(this.map.center);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
document.onselectstart = null;
|
document.onselectstart = null;
|
||||||
this.mouseDragStart = null;
|
this.mouseDragStart = null;
|
||||||
|
|||||||
@@ -95,13 +95,26 @@ OpenLayers.Icon.prototype = {
|
|||||||
this.px = px;
|
this.px = px;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((this.px != null) && (this.imageDiv != null)) {
|
if (this.imageDiv != null) {
|
||||||
|
if (this.px == null) {
|
||||||
|
this.display(false);
|
||||||
|
} else {
|
||||||
if (this.calculateOffset) {
|
if (this.calculateOffset) {
|
||||||
this.offset = this.calculateOffset(this.size);
|
this.offset = this.calculateOffset(this.size);
|
||||||
}
|
}
|
||||||
var offsetPx = this.px.offset(this.offset);
|
var offsetPx = this.px.offset(this.offset);
|
||||||
OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, offsetPx);
|
OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, offsetPx);
|
||||||
|
this.display(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Hide or show the icon
|
||||||
|
*
|
||||||
|
* @param {Boolean} display
|
||||||
|
*/
|
||||||
|
display: function(display) {
|
||||||
|
this.imageDiv.style.display = (display) ? "" : "none";
|
||||||
},
|
},
|
||||||
|
|
||||||
/** @final @type String */
|
/** @final @type String */
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ OpenLayers.Layer.prototype = {
|
|||||||
* @type OpenLayers.Map */
|
* @type OpenLayers.Map */
|
||||||
map: null,
|
map: null,
|
||||||
|
|
||||||
|
/** Whether or not the layer is a base layer. This should be set
|
||||||
|
* individually by all subclasses.
|
||||||
|
* Default is false
|
||||||
|
*
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: false,
|
||||||
|
|
||||||
// OPTIONS
|
// OPTIONS
|
||||||
|
|
||||||
@@ -136,6 +143,12 @@ OpenLayers.Layer.prototype = {
|
|||||||
//this function can be implemented by subclasses.
|
//this function can be implemented by subclasses.
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
reproject:function() {
|
||||||
|
//this function can be implemented by subclasses.
|
||||||
|
},
|
||||||
|
|
||||||
/** Set the map property for the layer. This is done through an accessor
|
/** Set the map property for the layer. This is done through an accessor
|
||||||
* so that subclasses can override this and take special action once
|
* so that subclasses can override this and take special action once
|
||||||
* they have their map variable set.
|
* they have their map variable set.
|
||||||
@@ -146,16 +159,6 @@ OpenLayers.Layer.prototype = {
|
|||||||
this.map = map;
|
this.map = map;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns Whether or not the layer is a base layer. This should be
|
|
||||||
* determined individually by all subclasses. Default is false
|
|
||||||
* @type Boolean
|
|
||||||
*/
|
|
||||||
isBaseLayer: function() {
|
|
||||||
//this function should be implemented by all subclasses.
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns Whether or not the layer is visible
|
* @returns Whether or not the layer is visible
|
||||||
* @type Boolean
|
* @type Boolean
|
||||||
@@ -165,18 +168,20 @@ OpenLayers.Layer.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {bool} visible
|
* @param {Boolean} visible
|
||||||
|
* @param {Boolean} noEvent
|
||||||
*/
|
*/
|
||||||
setVisibility: function(visible) {
|
setVisibility: function(visible, noEvent) {
|
||||||
if (visible != this.getVisibility()) {
|
if (visible != this.getVisibility()) {
|
||||||
this.div.style.display = (visible) ? "block" : "none";
|
this.div.style.display = (visible) ? "block" : "none";
|
||||||
if (this.map != null) {
|
if ((visible) && (this.map != null)) {
|
||||||
if (visible) {
|
|
||||||
var extent = this.map.getExtent();
|
var extent = this.map.getExtent();
|
||||||
if (extent != null) {
|
if (extent != null) {
|
||||||
this.moveTo(this.map.getExtent());
|
this.moveTo(this.map.getExtent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((this.map != null) &&
|
||||||
|
((noEvent == null) || (noEvent == false))) {
|
||||||
this.map.events.triggerEvent("changelayer");
|
this.map.events.triggerEvent("changelayer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
45
lib/OpenLayers/Layer/Boxes.js
Normal file
45
lib/OpenLayers/Layer/Boxes.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
||||||
|
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||||
|
* text of the license. */
|
||||||
|
// @require: OpenLayers/Layer.js
|
||||||
|
// @require: OpenLayers/Layer/Markers.js
|
||||||
|
/**
|
||||||
|
* @class
|
||||||
|
*/
|
||||||
|
OpenLayers.Layer.Boxes = Class.create();
|
||||||
|
OpenLayers.Layer.Boxes.prototype =
|
||||||
|
Object.extend( new OpenLayers.Layer.Markers(), {
|
||||||
|
|
||||||
|
initialize: function () {
|
||||||
|
OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Calculate the pixel location for the marker, create it, and
|
||||||
|
* add it to the layer's div
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*
|
||||||
|
* @param {OpenLayers.Marker.Box} marker
|
||||||
|
*/
|
||||||
|
drawMarker: function(marker) {
|
||||||
|
var bounds = marker.bounds;
|
||||||
|
var topleft = this.map.getLayerPxFromLonLat(
|
||||||
|
new OpenLayers.LonLat(bounds.left, bounds.top));
|
||||||
|
var botright = this.map.getLayerPxFromLonLat(
|
||||||
|
new OpenLayers.LonLat(bounds.right, bounds.bottom));
|
||||||
|
if (botright == null || topleft == null) {
|
||||||
|
marker.display(false);
|
||||||
|
} else {
|
||||||
|
var sz = new OpenLayers.Size(
|
||||||
|
botright.x - topleft.x, botright.y - topleft.y);
|
||||||
|
var markerDiv = marker.draw(topleft, sz);
|
||||||
|
if (!marker.drawn) {
|
||||||
|
this.div.appendChild(markerDiv);
|
||||||
|
marker.drawn = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** @final @type String */
|
||||||
|
CLASS_NAME: "OpenLayers.Layer.Boxes"
|
||||||
|
});
|
||||||
@@ -10,6 +10,11 @@ OpenLayers.Layer.GeoRSS = Class.create();
|
|||||||
OpenLayers.Layer.GeoRSS.prototype =
|
OpenLayers.Layer.GeoRSS.prototype =
|
||||||
Object.extend( new OpenLayers.Layer.Markers(), {
|
Object.extend( new OpenLayers.Layer.Markers(), {
|
||||||
|
|
||||||
|
/** GeoRSS layer is never a base layer.
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: false,
|
||||||
|
|
||||||
/** store url of text file
|
/** store url of text file
|
||||||
* @type str */
|
* @type str */
|
||||||
location:null,
|
location:null,
|
||||||
@@ -42,14 +47,6 @@ OpenLayers.Layer.GeoRSS.prototype =
|
|||||||
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
|
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
/** WFS layer is never a base class.
|
|
||||||
* @type Boolean
|
|
||||||
*/
|
|
||||||
isBaseLayer: function() {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?} ajaxRequest
|
* @param {?} ajaxRequest
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -37,15 +37,28 @@ if (typeof GMap2 != "undefined") {
|
|||||||
OpenLayers.Layer.Google = Class.create();
|
OpenLayers.Layer.Google = Class.create();
|
||||||
OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||||
|
|
||||||
|
|
||||||
|
/** Google layer is always base layer
|
||||||
|
*
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: true,
|
||||||
|
|
||||||
/** @type Boolean */
|
/** @type Boolean */
|
||||||
isFixed: true,
|
isFixed: true,
|
||||||
|
|
||||||
/** @type GMap2 gmap stores the Google Map element */
|
/** @type GMap2 gmap stores the Google Map element */
|
||||||
gmap:null,
|
gmap:null,
|
||||||
|
|
||||||
|
/** @type GMapType */
|
||||||
|
type: null,
|
||||||
|
|
||||||
/** @type Boolean */
|
/** @type Boolean */
|
||||||
dragging:false,
|
dragging:false,
|
||||||
|
|
||||||
|
/** @type Boolean */
|
||||||
|
dontListen:false,
|
||||||
|
|
||||||
// OPTIONS
|
// OPTIONS
|
||||||
|
|
||||||
/** @type int */
|
/** @type int */
|
||||||
@@ -82,19 +95,13 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
|||||||
setMap:function(map) {
|
setMap:function(map) {
|
||||||
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
||||||
|
|
||||||
// once our layer has been added to the map, we can create the vemap
|
// once our layer has been added to the map, we can load it
|
||||||
this.map.events.register("addlayer", this, this.loadGMap);
|
this.loadGMap();
|
||||||
},
|
},
|
||||||
|
|
||||||
/** Google layer is a base class if the GMap loaded correctly.
|
/** Assuming we are not dragging (in which case GMaps is moving itself,
|
||||||
* @type Boolean
|
* and the dragging flag is set) we need to move the gmap to the
|
||||||
*/
|
* new center/zoom
|
||||||
isBaseLayer: function() {
|
|
||||||
return (this.gmap != null);
|
|
||||||
},
|
|
||||||
|
|
||||||
/** Assuming we are not dragging (in which case GMaps moving itself)
|
|
||||||
* we need to move the gmap to the new center/zoom
|
|
||||||
*
|
*
|
||||||
* @param {OpenLayers.Bounds} bounds
|
* @param {OpenLayers.Bounds} bounds
|
||||||
* @param {Boolean} zoomChanged
|
* @param {Boolean} zoomChanged
|
||||||
@@ -117,9 +124,16 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
|||||||
if ( (!newCenter.equals(currentCenter)) ||
|
if ( (!newCenter.equals(currentCenter)) ||
|
||||||
(newZoom != currentZoom) ) {
|
(newZoom != currentZoom) ) {
|
||||||
|
|
||||||
|
this.dontListen = true;
|
||||||
this.gmap.setCenter(this.getGLatLngFromOLLonLat(newCenter),
|
this.gmap.setCenter(this.getGLatLngFromOLLonLat(newCenter),
|
||||||
this.getGZoomFromOLZoom(newZoom));
|
this.getGZoomFromOLZoom(newZoom));
|
||||||
|
|
||||||
|
if (this.type != null) {
|
||||||
|
this.gmap.setMapType(this.type);
|
||||||
|
this.type = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dontListen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,6 +155,7 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
|||||||
// this causes the GMap to set itself to Map's center/zoom
|
// this causes the GMap to set itself to Map's center/zoom
|
||||||
this.moveTo();
|
this.moveTo();
|
||||||
|
|
||||||
|
|
||||||
// catch pans and zooms from GMap
|
// catch pans and zooms from GMap
|
||||||
GEvent.addListener(this.gmap,
|
GEvent.addListener(this.gmap,
|
||||||
"moveend",
|
"moveend",
|
||||||
@@ -241,13 +256,16 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
|||||||
*/
|
*/
|
||||||
catchPanZoom: function(e) {
|
catchPanZoom: function(e) {
|
||||||
|
|
||||||
|
if (!this.dontListen) {
|
||||||
|
|
||||||
var gCenter = this.gmap.getCenter();
|
var gCenter = this.gmap.getCenter();
|
||||||
var gZoom = this.gmap.getZoom();
|
var gZoom = this.gmap.getZoom();
|
||||||
|
|
||||||
var olCenter = this.getOLLonLatFromGLatLng(gCenter);
|
var olCenter = this.getOLLonLatFromGLatLng(gCenter);
|
||||||
var olZoom = this.getOLZoomFromGZoom(gZoom);
|
var olZoom = this.getOLZoomFromGZoom(gZoom);
|
||||||
|
|
||||||
this.map.setCenter(olCenter, olZoom);
|
this.map.setCenter(olCenter, olZoom, this.dragging);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@@ -338,7 +356,7 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
|||||||
getOLZoomFromGZoom: function(gZoom) {
|
getOLZoomFromGZoom: function(gZoom) {
|
||||||
var zoom = null;
|
var zoom = null;
|
||||||
if (gZoom != null) {
|
if (gZoom != null) {
|
||||||
zoom = gZoom - 1;
|
zoom = gZoom;
|
||||||
}
|
}
|
||||||
return zoom;
|
return zoom;
|
||||||
},
|
},
|
||||||
@@ -353,7 +371,7 @@ OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
|
|||||||
getGZoomFromOLZoom: function(olZoom) {
|
getGZoomFromOLZoom: function(olZoom) {
|
||||||
var zoom = null;
|
var zoom = null;
|
||||||
if (olZoom != null) {
|
if (olZoom != null) {
|
||||||
zoom = olZoom + 1;
|
zoom = olZoom;
|
||||||
}
|
}
|
||||||
return zoom;
|
return zoom;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ OpenLayers.Layer.Grid.prototype =
|
|||||||
*/
|
*/
|
||||||
moveTo:function(bounds, zoomChanged, minor) {
|
moveTo:function(bounds, zoomChanged, minor) {
|
||||||
if (bounds == null) {
|
if (bounds == null) {
|
||||||
bounds = this.map.getBounds();
|
bounds = this.map.getExtent();
|
||||||
}
|
}
|
||||||
if (bounds != null) {
|
if (bounds != null) {
|
||||||
if (!this.getVisibility()) {
|
if (!this.getVisibility()) {
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ OpenLayers.Layer.KaMap = Class.create();
|
|||||||
OpenLayers.Layer.KaMap.prototype =
|
OpenLayers.Layer.KaMap.prototype =
|
||||||
Object.extend( new OpenLayers.Layer.Grid(), {
|
Object.extend( new OpenLayers.Layer.Grid(), {
|
||||||
|
|
||||||
|
/** KaMap Layer is always a base layer
|
||||||
|
*
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: true,
|
||||||
|
|
||||||
units: 'degrees',
|
units: 'degrees',
|
||||||
scales: {inches: 1, feet: 12, miles: 63360.0, meters: 39.3701, kilometers: 39370.1, degrees: 4374754},
|
scales: {inches: 1, feet: 12, miles: 63360.0, meters: 39.3701, kilometers: 39370.1, degrees: 4374754},
|
||||||
|
|
||||||
@@ -118,9 +124,7 @@ OpenLayers.Layer.KaMap.prototype =
|
|||||||
} while(tileoffsetlat > bounds.bottom - tilelat)
|
} while(tileoffsetlat > bounds.bottom - tilelat)
|
||||||
|
|
||||||
},
|
},
|
||||||
isBaseLayer: function() {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
/** @final @type String */
|
/** @final @type String */
|
||||||
CLASS_NAME: "OpenLayers.Layer.KaMap"
|
CLASS_NAME: "OpenLayers.Layer.KaMap"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ OpenLayers.Layer.Markers = Class.create();
|
|||||||
OpenLayers.Layer.Markers.prototype =
|
OpenLayers.Layer.Markers.prototype =
|
||||||
Object.extend( new OpenLayers.Layer(), {
|
Object.extend( new OpenLayers.Layer(), {
|
||||||
|
|
||||||
|
/** Markers layer is never a base layer.
|
||||||
|
*
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: false,
|
||||||
|
|
||||||
/** internal marker list
|
/** internal marker list
|
||||||
* @type Array(OpenLayers.Marker) */
|
* @type Array(OpenLayers.Marker) */
|
||||||
markers: null,
|
markers: null,
|
||||||
@@ -45,13 +51,14 @@ OpenLayers.Layer.Markers.prototype =
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/** WFS layer is never a base class.
|
|
||||||
* @type Boolean
|
/**
|
||||||
*/
|
*/
|
||||||
isBaseLayer: function() {
|
reproject:function() {
|
||||||
return false;
|
this.redraw();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {OpenLayers.Marker} marker
|
* @param {OpenLayers.Marker} marker
|
||||||
*/
|
*/
|
||||||
@@ -103,7 +110,9 @@ OpenLayers.Layer.Markers.prototype =
|
|||||||
*/
|
*/
|
||||||
drawMarker: function(marker) {
|
drawMarker: function(marker) {
|
||||||
var px = this.map.getLayerPxFromLonLat(marker.lonlat);
|
var px = this.map.getLayerPxFromLonLat(marker.lonlat);
|
||||||
if (px != null) {
|
if (px == null) {
|
||||||
|
marker.display(false);
|
||||||
|
} else {
|
||||||
var markerImg = marker.draw(px);
|
var markerImg = marker.draw(px);
|
||||||
if (!marker.drawn) {
|
if (!marker.drawn) {
|
||||||
this.div.appendChild(markerImg);
|
this.div.appendChild(markerImg);
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ OpenLayers.Layer.Text = Class.create();
|
|||||||
OpenLayers.Layer.Text.prototype =
|
OpenLayers.Layer.Text.prototype =
|
||||||
Object.extend( new OpenLayers.Layer.Markers(), {
|
Object.extend( new OpenLayers.Layer.Markers(), {
|
||||||
|
|
||||||
|
/** Text layer is never a base layer.
|
||||||
|
*
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: false,
|
||||||
|
|
||||||
/** store url of text file - this should be specified in the "options" hash
|
/** store url of text file - this should be specified in the "options" hash
|
||||||
* @type str */
|
* @type str */
|
||||||
location:null,
|
location:null,
|
||||||
@@ -44,13 +50,6 @@ OpenLayers.Layer.Text.prototype =
|
|||||||
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
|
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
/** Text layer is never a base class.
|
|
||||||
* @type Boolean
|
|
||||||
*/
|
|
||||||
isBaseLayer: function() {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?} ajaxRequest
|
* @param {?} ajaxRequest
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ OpenLayers.Layer.VirtualEarth = Class.create();
|
|||||||
OpenLayers.Layer.VirtualEarth.prototype =
|
OpenLayers.Layer.VirtualEarth.prototype =
|
||||||
Object.extend( new OpenLayers.Layer(), {
|
Object.extend( new OpenLayers.Layer(), {
|
||||||
|
|
||||||
|
/** Virtual Earth layer is always a base layer.
|
||||||
|
*
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: true,
|
||||||
|
|
||||||
/** @type Boolean */
|
/** @type Boolean */
|
||||||
isFixed: true,
|
isFixed: true,
|
||||||
|
|
||||||
@@ -32,15 +38,8 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
|||||||
setMap:function(map) {
|
setMap:function(map) {
|
||||||
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
|
||||||
|
|
||||||
// once our layer has been added to the map, we can create the vemap
|
// once our layer has been added to the map, we can load the vemap
|
||||||
this.map.events.register("addlayer", this, this.loadVEMap);
|
this.loadVEMap();
|
||||||
},
|
|
||||||
|
|
||||||
/** Virtual Earth layer is always a base class.
|
|
||||||
* @type Boolean
|
|
||||||
*/
|
|
||||||
isBaseLayer: function() {
|
|
||||||
return true;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -257,7 +256,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
|||||||
getOLZoomFromVEZoom: function(veZoom) {
|
getOLZoomFromVEZoom: function(veZoom) {
|
||||||
var zoom = null;
|
var zoom = null;
|
||||||
if (veZoom != null) {
|
if (veZoom != null) {
|
||||||
zoom = veZoom - 1;
|
zoom = veZoom;
|
||||||
}
|
}
|
||||||
return zoom;
|
return zoom;
|
||||||
},
|
},
|
||||||
@@ -272,7 +271,7 @@ OpenLayers.Layer.VirtualEarth.prototype =
|
|||||||
getVEZoomFromOLZoom: function(olZoom) {
|
getVEZoomFromOLZoom: function(olZoom) {
|
||||||
var zoom = null;
|
var zoom = null;
|
||||||
if (olZoom != null) {
|
if (olZoom != null) {
|
||||||
zoom = olZoom + 1;
|
zoom = olZoom;
|
||||||
}
|
}
|
||||||
return zoom;
|
return zoom;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ OpenLayers.Layer.WFS.prototype =
|
|||||||
Object.extend(new OpenLayers.Layer.Grid(),
|
Object.extend(new OpenLayers.Layer.Grid(),
|
||||||
Object.extend(new OpenLayers.Layer.Markers(), {
|
Object.extend(new OpenLayers.Layer.Markers(), {
|
||||||
|
|
||||||
|
/** WFS layer is never a base layer.
|
||||||
|
*
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: false,
|
||||||
|
|
||||||
/** Allow the user to specify special classes for features and tiles.
|
/** Allow the user to specify special classes for features and tiles.
|
||||||
*
|
*
|
||||||
* This allows for easy-definition of behaviour. The defaults are
|
* This allows for easy-definition of behaviour. The defaults are
|
||||||
@@ -47,6 +53,12 @@ OpenLayers.Layer.WFS.prototype =
|
|||||||
newArguments.push(name, url, params, options);
|
newArguments.push(name, url, params, options);
|
||||||
}
|
}
|
||||||
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||||
|
|
||||||
|
var newArguments = new Array();
|
||||||
|
if (arguments.length > 0) {
|
||||||
|
//uppercase params
|
||||||
|
newArguments.push(name, options);
|
||||||
|
}
|
||||||
OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments);
|
OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments);
|
||||||
|
|
||||||
if (arguments.length > 0) {
|
if (arguments.length > 0) {
|
||||||
@@ -84,13 +96,6 @@ OpenLayers.Layer.WFS.prototype =
|
|||||||
OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments);
|
OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
/** WFS layer is never a base class.
|
|
||||||
* @type Boolean
|
|
||||||
*/
|
|
||||||
isBaseLayer: function() {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} obj
|
* @param {Object} obj
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -18,6 +18,14 @@ OpenLayers.Layer.WMS.prototype =
|
|||||||
format: "image/jpeg"
|
format: "image/jpeg"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** WMS layer by default is a base layer.
|
||||||
|
* If the user wishes to use a WMS as a datalayer, s/he needs only
|
||||||
|
* set this property to false.
|
||||||
|
*
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
*
|
*
|
||||||
@@ -75,14 +83,6 @@ OpenLayers.Layer.WMS.prototype =
|
|||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/** WMS layer is never a base class.
|
|
||||||
* @type Boolean
|
|
||||||
*/
|
|
||||||
isBaseLayer: function() {
|
|
||||||
return (this.params.TRANSPARENT != 'true');
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addTile creates a tile, initializes it, and
|
* addTile creates a tile, initializes it, and
|
||||||
* adds it to the layer div.
|
* adds it to the layer div.
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
|||||||
format: "image/jpeg"
|
format: "image/jpeg"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/** WMS.Untiled layer is never a base layer.
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: false,
|
||||||
|
|
||||||
/** @type DOMElement */
|
/** @type DOMElement */
|
||||||
imgDiv: null,
|
imgDiv: null,
|
||||||
|
|
||||||
@@ -81,14 +87,6 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/** WFS layer is never a base class.
|
|
||||||
* @type Boolean
|
|
||||||
*/
|
|
||||||
isBaseLayer: function() {
|
|
||||||
return false; //(this.params.TRANSPARENT != true);
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
/** Once HTTPRequest has set the map, we can load the image div
|
/** Once HTTPRequest has set the map, we can load the image div
|
||||||
*
|
*
|
||||||
* @param {OpenLayers.Map} map
|
* @param {OpenLayers.Map} map
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ OpenLayers.Layer.WorldWind.prototype =
|
|||||||
DEFAULT_PARAMS: {
|
DEFAULT_PARAMS: {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** WorldWind layer is always a base layer
|
||||||
|
*
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: true,
|
||||||
|
|
||||||
// LevelZeroTileSizeDegrees
|
// LevelZeroTileSizeDegrees
|
||||||
lzd: null,
|
lzd: null,
|
||||||
|
|
||||||
@@ -55,9 +61,7 @@ OpenLayers.Layer.WorldWind.prototype =
|
|||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isBaseLayer: function() {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
/** @final @type String */
|
/** @final @type String */
|
||||||
CLASS_NAME: "OpenLayers.Layer.WorldWind"
|
CLASS_NAME: "OpenLayers.Layer.WorldWind"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ document.write("<script src='http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzu
|
|||||||
OpenLayers.Layer.Yahoo = Class.create();
|
OpenLayers.Layer.Yahoo = Class.create();
|
||||||
OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {
|
OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {
|
||||||
|
|
||||||
|
/** Yahoo layer is always a base layer.
|
||||||
|
*
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: true,
|
||||||
|
|
||||||
/** @type Boolean */
|
/** @type Boolean */
|
||||||
isFixed: true,
|
isFixed: true,
|
||||||
|
|
||||||
@@ -40,13 +46,6 @@ OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {
|
|||||||
this.map.events.register("addlayer", this, this.loadYMap);
|
this.map.events.register("addlayer", this, this.loadYMap);
|
||||||
},
|
},
|
||||||
|
|
||||||
/** Yahoo layer is always a base class.
|
|
||||||
* @type Boolean
|
|
||||||
*/
|
|
||||||
isBaseLayer: function() {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {OpenLayers.Bounds} bounds
|
* @param {OpenLayers.Bounds} bounds
|
||||||
* @param {Boolean} zoomChanged
|
* @param {Boolean} zoomChanged
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ OpenLayers.Map.prototype = {
|
|||||||
* @type Array */
|
* @type Array */
|
||||||
EVENT_TYPES: [
|
EVENT_TYPES: [
|
||||||
"addlayer", "removelayer", "changelayer", "movestart", "move",
|
"addlayer", "removelayer", "changelayer", "movestart", "move",
|
||||||
"moveend", "zoomend", "layerchanged", "popupopen", "popupclose",
|
"moveend", "zoomend", "popupopen", "popupclose",
|
||||||
"addmarker", "removemarker", "clearmarkers", "mouseover",
|
"addmarker", "removemarker", "clearmarkers", "mouseover",
|
||||||
"mouseout", "mousemove", "dragstart", "drag", "dragend",
|
"mouseout", "mousemove", "dragstart", "drag", "dragend",
|
||||||
"changebaselayer"],
|
"changebaselayer"],
|
||||||
@@ -258,7 +258,6 @@ OpenLayers.Map.prototype = {
|
|||||||
* @param {OpenLayers.Layer} layer
|
* @param {OpenLayers.Layer} layer
|
||||||
*/
|
*/
|
||||||
addLayer: function (layer) {
|
addLayer: function (layer) {
|
||||||
layer.setMap(this);
|
|
||||||
layer.div.style.overflow = "";
|
layer.div.style.overflow = "";
|
||||||
layer.div.style.zIndex = this.Z_INDEX_BASE['Layer'] + this.layers.length;
|
layer.div.style.zIndex = this.Z_INDEX_BASE['Layer'] + this.layers.length;
|
||||||
|
|
||||||
@@ -268,6 +267,7 @@ OpenLayers.Map.prototype = {
|
|||||||
this.layerContainerDiv.appendChild(layer.div);
|
this.layerContainerDiv.appendChild(layer.div);
|
||||||
}
|
}
|
||||||
this.layers.push(layer);
|
this.layers.push(layer);
|
||||||
|
layer.setMap(this);
|
||||||
|
|
||||||
this.events.triggerEvent("addlayer");
|
this.events.triggerEvent("addlayer");
|
||||||
|
|
||||||
@@ -277,15 +277,14 @@ OpenLayers.Map.prototype = {
|
|||||||
layer.moveTo(bounds, true);
|
layer.moveTo(bounds, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// hack hack hack - until we add a more robust layer switcher,
|
if (layer.isBaseLayer) {
|
||||||
// which is able to determine which layers are base layers and
|
// set the first baselaye we add as the baselayer
|
||||||
// which are not (and put baselayers in a radiobutton group and
|
if (this.baseLayer == null) {
|
||||||
// other layers in checkboxes) this seems to be the most straight-
|
this.setBaseLayer(layer);
|
||||||
// forward way of dealing with this.
|
|
||||||
//
|
|
||||||
if ( (this.baseLayer == null) && (layer.isBaseLayer()) ) {
|
|
||||||
this.baseLayer = layer;
|
|
||||||
this.events.triggerEvent("changebaselayer");
|
this.events.triggerEvent("changebaselayer");
|
||||||
|
} else {
|
||||||
|
layer.setVisibility(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -329,20 +328,61 @@ OpenLayers.Map.prototype = {
|
|||||||
} else {
|
} else {
|
||||||
this.layerContainerDiv.removeChild(layer.div);
|
this.layerContainerDiv.removeChild(layer.div);
|
||||||
}
|
}
|
||||||
|
layer.map = null;
|
||||||
this.layers.remove(layer);
|
this.layers.remove(layer);
|
||||||
|
|
||||||
|
// if we removed the base layer, need to set a new one
|
||||||
if (this.baseLayer == layer) {
|
if (this.baseLayer == layer) {
|
||||||
this.baseLayer = null;
|
this.baseLayer = null;
|
||||||
for(i=0; i < this.layers.length; i++) {
|
for(i=0; i < this.layers.length; i++) {
|
||||||
if ( (this.baseLayer == null) && (this.layers[i].isBaseLayer()) ) {
|
var iLayer = this.layers[i];
|
||||||
this.baseLayer = this.layers[i];
|
if (iLayer.isBaseLayer) {
|
||||||
continue;
|
this.setBaseLayer(iLayer);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
layer.map = null;
|
|
||||||
this.events.triggerEvent("removelayer");
|
this.events.triggerEvent("removelayer");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Allows user to specify one of the currently-loaded layers as the Map's
|
||||||
|
* new base layer.
|
||||||
|
*
|
||||||
|
* @param {OpenLayers.Layer} newBaseLayer
|
||||||
|
* @param {Boolean} noEvent
|
||||||
|
*/
|
||||||
|
setBaseLayer: function(newBaseLayer, noEvent) {
|
||||||
|
|
||||||
|
if (newBaseLayer != this.baseLayer) {
|
||||||
|
|
||||||
|
// is newBaseLayer an already loaded layer?
|
||||||
|
var foundLayer = (this.layers.indexOf(newBaseLayer) != -1);
|
||||||
|
|
||||||
|
if (foundLayer) {
|
||||||
|
|
||||||
|
// make the old base layer invisible
|
||||||
|
if (this.baseLayer != null) {
|
||||||
|
this.baseLayer.setVisibility(false, noEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set new baselayer
|
||||||
|
this.baseLayer = newBaseLayer;
|
||||||
|
|
||||||
|
// make the new one visible
|
||||||
|
this.baseLayer.setVisibility(true, noEvent);
|
||||||
|
|
||||||
|
// now go back and reproject
|
||||||
|
for(var i=0; i < this.layers.length; i++) {
|
||||||
|
this.layers[i].reproject();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((noEvent == null) || (noEvent == false)) {
|
||||||
|
this.events.triggerEvent("changebaselayer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {OpenLayers.Control} control
|
* @param {OpenLayers.Control} control
|
||||||
* @param {OpenLayers.Pixel} px
|
* @param {OpenLayers.Pixel} px
|
||||||
@@ -912,8 +952,13 @@ OpenLayers.Map.prototype = {
|
|||||||
* @type OpenLayers.Pixel
|
* @type OpenLayers.Pixel
|
||||||
*/
|
*/
|
||||||
getViewPortPxFromLayerPx:function(layerPx) {
|
getViewPortPxFromLayerPx:function(layerPx) {
|
||||||
return layerPx.add(parseInt(this.layerContainerDiv.style.left),
|
var viewPortPx = null;
|
||||||
parseInt(this.layerContainerDiv.style.top) );
|
if (layerPx != null) {
|
||||||
|
var dX = parseInt(this.layerContainerDiv.style.left);
|
||||||
|
var dY = parseInt(this.layerContainerDiv.style.top);
|
||||||
|
viewPortPx = layerPx.add(dX, dY);
|
||||||
|
}
|
||||||
|
return viewPortPx;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -925,8 +970,13 @@ OpenLayers.Map.prototype = {
|
|||||||
* @type OpenLayers.Pixel
|
* @type OpenLayers.Pixel
|
||||||
*/
|
*/
|
||||||
getLayerPxFromViewPortPx:function(viewPortPx) {
|
getLayerPxFromViewPortPx:function(viewPortPx) {
|
||||||
return viewPortPx.add(-parseInt(this.layerContainerDiv.style.left),
|
var layerPx = null;
|
||||||
-parseInt(this.layerContainerDiv.style.top));
|
if (viewPortPx != null) {
|
||||||
|
var dX = -parseInt(this.layerContainerDiv.style.left);
|
||||||
|
var dY = -parseInt(this.layerContainerDiv.style.top);
|
||||||
|
layerPx = viewPortPx.add(dX, dY);
|
||||||
|
}
|
||||||
|
return layerPx;
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -27,10 +27,11 @@ OpenLayers.Marker.prototype = {
|
|||||||
* @param {OpenLayers.LonLat lonlat
|
* @param {OpenLayers.LonLat lonlat
|
||||||
*/
|
*/
|
||||||
initialize: function(lonlat, icon) {
|
initialize: function(lonlat, icon) {
|
||||||
|
if (arguments.length > 0) {
|
||||||
this.lonlat = lonlat;
|
this.lonlat = lonlat;
|
||||||
this.icon = (icon) ? icon : OpenLayers.Marker.defaultIcon();
|
this.icon = (icon) ? icon : OpenLayers.Marker.defaultIcon();
|
||||||
|
|
||||||
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
|
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
@@ -87,6 +88,14 @@ OpenLayers.Marker.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** Hide or show the icon
|
||||||
|
*
|
||||||
|
* @param {Boolean} display
|
||||||
|
*/
|
||||||
|
display: function(display) {
|
||||||
|
this.icon.display(display);
|
||||||
|
},
|
||||||
|
|
||||||
/** @final @type String */
|
/** @final @type String */
|
||||||
CLASS_NAME: "OpenLayers.Marker"
|
CLASS_NAME: "OpenLayers.Marker"
|
||||||
};
|
};
|
||||||
|
|||||||
72
lib/OpenLayers/Marker/Box.js
Normal file
72
lib/OpenLayers/Marker/Box.js
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
|
||||||
|
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||||
|
* text of the license. */
|
||||||
|
// @require: OpenLayers/Marker.js
|
||||||
|
/**
|
||||||
|
* @class
|
||||||
|
*/
|
||||||
|
OpenLayers.Marker.Box = Class.create();
|
||||||
|
OpenLayers.Marker.Box.prototype = Object.extend( new OpenLayers.Marker(), {
|
||||||
|
/** @type OpenLayers.LonLat */
|
||||||
|
bounds: null,
|
||||||
|
|
||||||
|
div: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*
|
||||||
|
* @param {OpenLayers.Icon} icon
|
||||||
|
* @param {OpenLayers.LonLat lonlat
|
||||||
|
*/
|
||||||
|
initialize: function(bounds, borderColor, borderWidth) {
|
||||||
|
if (arguments.length > 0) {
|
||||||
|
this.bounds = bounds;
|
||||||
|
this.div = OpenLayers.Util.createDiv();
|
||||||
|
this.events = new OpenLayers.Events(this, this.div, null);
|
||||||
|
this.setBorder(borderColor, borderWidth);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setBorder: function (color, width) {
|
||||||
|
if (!color) color = "red";
|
||||||
|
if (!width) width = 2;
|
||||||
|
this.div.style.border = width + "px solid " + color;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {OpenLayers.Pixel} px
|
||||||
|
*
|
||||||
|
* @return A new DOM Image with this marker<65>s icon set at the
|
||||||
|
* location passed-in
|
||||||
|
* @type DOMElement
|
||||||
|
*/
|
||||||
|
draw: function(px, sz) {
|
||||||
|
OpenLayers.Util.modifyDOMElement(this.div, null, px, sz);
|
||||||
|
return this.div;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns Whether or not the marker is currently visible on screen.
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
onScreen:function() {
|
||||||
|
var onScreen = false;
|
||||||
|
if (this.map) {
|
||||||
|
var screenBounds = this.map.getExtent();
|
||||||
|
onScreen = screenBounds.containsBounds(this.bounds, true, true);
|
||||||
|
}
|
||||||
|
return onScreen;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Hide or show the icon
|
||||||
|
*
|
||||||
|
* @param {Boolean} display
|
||||||
|
*/
|
||||||
|
display: function(display) {
|
||||||
|
this.div.style.display = (display) ? "" : "none";
|
||||||
|
},
|
||||||
|
|
||||||
|
/** @final @type String */
|
||||||
|
CLASS_NAME: "OpenLayers.Marker.Box"
|
||||||
|
});
|
||||||
|
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
<li>test_Tile.html</li>
|
<li>test_Tile.html</li>
|
||||||
<li>test_Tile_Image.html</li>
|
<li>test_Tile_Image.html</li>
|
||||||
<li>test_Control.html</li>
|
<li>test_Control.html</li>
|
||||||
|
<li>test_Control_LayerSwitcher.html</li>
|
||||||
<li>test_Control_PanZoom.html</li>
|
<li>test_Control_PanZoom.html</li>
|
||||||
<li>test_Control_PanZoomBar.html</li>
|
<li>test_Control_PanZoomBar.html</li>
|
||||||
<li>test_Control_Permalink.html</li>
|
<li>test_Control_Permalink.html</li>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ body { height: 98%; font: normal normal 10pt sans-serif }
|
|||||||
#col1 { float: left; width: 27em; margin: 0 0 0 1em; overflow: visible; }
|
#col1 { float: left; width: 27em; margin: 0 0 0 1em; overflow: visible; }
|
||||||
#col2 { position: relative; height: 98%; margin: 0 0.5em 0 27em; }
|
#col2 { position: relative; height: 98%; margin: 0 0.5em 0 27em; }
|
||||||
#col1_header { margin-top: 0.5em; }
|
#col1_header { margin-top: 0.5em; }
|
||||||
|
#scroller { height: 550px; overflow: auto;}
|
||||||
#testtable { margin: 0 0 2em 0; width: 97%; }
|
#testtable { margin: 0 0 2em 0; width: 97%; }
|
||||||
#run_buttons { margin-bottom: 4em; }
|
#run_buttons { margin-bottom: 4em; }
|
||||||
|
|
||||||
@@ -2286,8 +2287,10 @@ onload=function()
|
|||||||
|
|
||||||
<div id="col1">
|
<div id="col1">
|
||||||
<div id="col1_header">Test pages:</div>
|
<div id="col1_header">Test pages:</div>
|
||||||
|
<div id="scroller">
|
||||||
<table id="testtable">
|
<table id="testtable">
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
<div id="run_buttons">
|
<div id="run_buttons">
|
||||||
<input type="button" value=" clear " id="clear_btn" />
|
<input type="button" value=" clear " id="clear_btn" />
|
||||||
<input type="button" value=" run all " id="run_all" />
|
<input type="button" value=" run all " id="run_all" />
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<script type="text/javascript"><!--
|
<script type="text/javascript"><!--
|
||||||
var bounds;
|
var bounds;
|
||||||
function test_01_Bounds_constructor (t) {
|
function test_01_Bounds_constructor (t) {
|
||||||
t.plan( 14 );
|
t.plan( 12 );
|
||||||
bounds = new OpenLayers.Bounds(0,2,10,4);
|
bounds = new OpenLayers.Bounds(0,2,10,4);
|
||||||
t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" );
|
t.ok( bounds instanceof OpenLayers.Bounds, "new OpenLayers.Bounds returns Bounds object" );
|
||||||
t.eq( bounds.CLASS_NAME, "OpenLayers.Bounds", "bounds.CLASS_NAME is set correctly" );
|
t.eq( bounds.CLASS_NAME, "OpenLayers.Bounds", "bounds.CLASS_NAME is set correctly" );
|
||||||
@@ -19,14 +19,13 @@
|
|||||||
t.eq( sz.w, 10, "bounds.getSize() has correct width value" );
|
t.eq( sz.w, 10, "bounds.getSize() has correct width value" );
|
||||||
t.eq( sz.h, 2, "bounds.getSize() has correct height value" );
|
t.eq( sz.h, 2, "bounds.getSize() has correct height value" );
|
||||||
|
|
||||||
var center = bounds.getCenterPixel();
|
var center = new OpenLayers.Pixel(5,3);
|
||||||
t.eq( center.x, 5, "bounds.getCenterPixel() has correct x value" );
|
var boundsCenter = bounds.getCenterPixel();
|
||||||
t.eq( center.y, 3, "bounds.getCenterPixel() has correct y value" );
|
t.ok( boundsCenter.equals(center), "bounds.getCenterLonLat() has correct value" );
|
||||||
|
|
||||||
var center = bounds.getCenterLonLat();
|
|
||||||
t.eq( center.lon, 5, "bounds.getCenterLonLat() has correct lon value" );
|
|
||||||
t.eq( center.lat, 3, "bounds.getCenterLonLat() has correct lat value" );
|
|
||||||
|
|
||||||
|
var center = new OpenLayers.LonLat(5,3);
|
||||||
|
var boundsCenter = bounds.getCenterLonLat();
|
||||||
|
t.ok( boundsCenter.equals(center), "bounds.getCenterLonLat() has correct value" );
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_02_Bounds_toBBOX(t) {
|
function test_02_Bounds_toBBOX(t) {
|
||||||
|
|||||||
92
tests/test_Control_LayerSwitcher.html
Normal file
92
tests/test_Control_LayerSwitcher.html
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
|
<script type="text/javascript"><!--
|
||||||
|
var map;
|
||||||
|
|
||||||
|
function test_01_Control_LayerSwitcher_constructor (t) {
|
||||||
|
t.plan( 1 );
|
||||||
|
|
||||||
|
control = new OpenLayers.Control.LayerSwitcher();
|
||||||
|
t.ok( control instanceof OpenLayers.Control.LayerSwitcher, "new OpenLayers.Control.LayerSwitcher returns object" );
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_02_Control_LayerSwitcher_draw (t) {
|
||||||
|
t.plan( 2 );
|
||||||
|
|
||||||
|
map = new OpenLayers.Map('map');
|
||||||
|
control = new OpenLayers.Control.LayerSwitcher();
|
||||||
|
map.addControl(control);
|
||||||
|
|
||||||
|
var div = control.draw();
|
||||||
|
t.ok( control.div != null, "draw makes a div" );
|
||||||
|
t.ok( div != null, "draw returns its div" );
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_03_Control_LayerSwitcher_loadContents(t) {
|
||||||
|
|
||||||
|
t.plan( 5 );
|
||||||
|
|
||||||
|
map = new OpenLayers.Map('map');
|
||||||
|
var layer = new OpenLayers.Layer.WMS("WMS",
|
||||||
|
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||||
|
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||||
|
map.addLayer(layer);
|
||||||
|
|
||||||
|
markers = new OpenLayers.Layer.Markers("markers");
|
||||||
|
map.addLayer(markers);
|
||||||
|
|
||||||
|
control = new OpenLayers.Control.LayerSwitcher();
|
||||||
|
map.addControl(control);
|
||||||
|
|
||||||
|
t.ok(control.layersDiv != null, "correctly makes layers div");
|
||||||
|
t.ok(control.baseLayersDiv != null, "correctly makes layers div");
|
||||||
|
t.ok(control.dataLayersDiv != null, "correctly makes layers div");
|
||||||
|
|
||||||
|
t.ok(control.maximizeDiv != null, "correctly makes resize div");
|
||||||
|
t.ok(control.minimizeDiv != null, "correctly makes resize div");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function test_04_Control_LayerSwitcher_redraw (t) {
|
||||||
|
|
||||||
|
t.plan( 8 );
|
||||||
|
|
||||||
|
map = new OpenLayers.Map('map');
|
||||||
|
var layer = new OpenLayers.Layer.WMS("WMS",
|
||||||
|
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||||
|
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||||
|
map.addLayer(layer);
|
||||||
|
|
||||||
|
markers = new OpenLayers.Layer.Markers("markers");
|
||||||
|
map.addLayer(markers);
|
||||||
|
|
||||||
|
control = new OpenLayers.Control.LayerSwitcher();
|
||||||
|
map.addControl(control);
|
||||||
|
|
||||||
|
|
||||||
|
var wmsInput = $("input_" + layer.name);
|
||||||
|
t.ok(wmsInput != null, "correctly makes an input for wms layer");
|
||||||
|
t.eq(wmsInput.type, "radio", "wms correctly made a radio button");
|
||||||
|
t.eq(wmsInput.name, "baseLayers", "wms correctly named");
|
||||||
|
t.eq(wmsInput.value, layer.name, "wms correctly valued");
|
||||||
|
|
||||||
|
var markersInput = $("input_" + markers.name);
|
||||||
|
t.ok(markersInput != null, "correctly makes an input for markers layer");
|
||||||
|
t.eq(markersInput.type, "checkbox", "wms correctly made a radio button");
|
||||||
|
t.eq(markersInput.name, markers.name, "wms correctly named");
|
||||||
|
t.eq(markersInput.value, markers.name, "wms correctly valued");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -->
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="map" style="width: 1024px; height: 512px;"/>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
t.eq( layer.options["chicken"], 151 , "layer.options correctly made fresh copy" );
|
t.eq( layer.options["chicken"], 151 , "layer.options correctly made fresh copy" );
|
||||||
|
|
||||||
t.eq( layer.isBaseLayer(), false, "Default layer is not base layer" );
|
t.eq( layer.isBaseLayer, false, "Default layer is not base layer" );
|
||||||
|
|
||||||
layer = new OpenLayers.Layer('Test Layer');
|
layer = new OpenLayers.Layer('Test Layer');
|
||||||
t.ok( layer instanceof OpenLayers.Layer, "new OpenLayers.Layer returns object" );
|
t.ok( layer instanceof OpenLayers.Layer, "new OpenLayers.Layer returns object" );
|
||||||
|
|||||||
@@ -23,17 +23,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_02_Layer_Google_isBaseLayer (t) {
|
function test_02_Layer_Google_isBaseLayer (t) {
|
||||||
t.plan(2);
|
t.plan(1);
|
||||||
|
|
||||||
var map = new OpenLayers.Map('map');
|
|
||||||
var layer = new OpenLayers.Layer.Google('Goog Layer');
|
var layer = new OpenLayers.Layer.Google('Goog Layer');
|
||||||
map.addLayer(layer);
|
|
||||||
|
|
||||||
t.ok(layer.isBaseLayer(), "a default load of google layer responds as a base layer");
|
t.ok(layer.isBaseLayer, "a default load of google layer responds as a base layer");
|
||||||
|
|
||||||
layer.gmap = null;
|
|
||||||
|
|
||||||
t.ok(!layer.isBaseLayer(), "a bad load of google layer does not respond as a base layer");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_03_Layer_Google_Translation_zoom (t) {
|
function test_03_Layer_Google_Translation_zoom (t) {
|
||||||
@@ -48,7 +42,7 @@
|
|||||||
// the code afterwards works by itself to test that translation
|
// the code afterwards works by itself to test that translation
|
||||||
// works correctly both ways.
|
// works correctly both ways.
|
||||||
var gZoom = 5;
|
var gZoom = 5;
|
||||||
var correspondingOLZoom = 4;
|
var correspondingOLZoom = 5;
|
||||||
|
|
||||||
|
|
||||||
olZoom = layer.getOLZoomFromGZoom(gZoom);
|
olZoom = layer.getOLZoomFromGZoom(gZoom);
|
||||||
|
|||||||
@@ -49,10 +49,6 @@
|
|||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(0,0));
|
map.setCenter(new OpenLayers.LonLat(0,0));
|
||||||
|
|
||||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
|
||||||
map.addLayer(layer);
|
|
||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
|
||||||
|
|
||||||
//grab a reference to one of the tiles
|
//grab a reference to one of the tiles
|
||||||
var tile = layer.grid[0][0];
|
var tile = layer.grid[0][0];
|
||||||
|
|||||||
@@ -43,11 +43,6 @@
|
|||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(0,0));
|
map.setCenter(new OpenLayers.LonLat(0,0));
|
||||||
|
|
||||||
layer = new OpenLayers.Layer.KaMap(name, url, params, units);
|
|
||||||
map.addLayer(layer);
|
|
||||||
|
|
||||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
|
||||||
|
|
||||||
//grab a reference to one of the tiles
|
//grab a reference to one of the tiles
|
||||||
var tile = layer.grid[0][0];
|
var tile = layer.grid[0][0];
|
||||||
|
|
||||||
|
|||||||
@@ -99,16 +99,12 @@
|
|||||||
|
|
||||||
function test_05_Layer_WMS_isBaseLayer(t) {
|
function test_05_Layer_WMS_isBaseLayer(t) {
|
||||||
|
|
||||||
t.plan(2);
|
t.plan(1);
|
||||||
|
|
||||||
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||||
|
|
||||||
t.ok( layer.isBaseLayer(), "baselayer is true when no transparent set");
|
t.ok( layer.isBaseLayer, "baselayer is true by default");
|
||||||
|
|
||||||
layer.params.TRANSPARENT = "true";
|
|
||||||
|
|
||||||
t.ok( !layer.isBaseLayer(), "baselayer is false when transparent set");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_06_Layer_WMS_mergeNewParams (t) {
|
function test_06_Layer_WMS_mergeNewParams (t) {
|
||||||
|
|||||||
@@ -223,6 +223,37 @@
|
|||||||
t.ok( gotLayer == null, "getLayer correctly returns null when layer not found");
|
t.ok( gotLayer == null, "getLayer correctly returns null when layer not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_10_Map_setBaseLayer(t) {
|
||||||
|
t.plan( 4 );
|
||||||
|
|
||||||
|
map = new OpenLayers.Map($('map'));
|
||||||
|
|
||||||
|
var wmslayer = new OpenLayers.Layer.WMS('Test Layer',
|
||||||
|
"http://octo.metacarta.com/cgi-bin/mapserv",
|
||||||
|
{map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'},
|
||||||
|
{maxExtent: new OpenLayers.Bounds(33861, 717605, 330846, 1019656), maxResolution: 296985/1024, projection:"EPSG:2805" } );
|
||||||
|
|
||||||
|
var wmslayer2 = new OpenLayers.Layer.WMS('Test Layer2',
|
||||||
|
"http://octo.metacarta.com/cgi-bin/mapserv",
|
||||||
|
{map: '/mapdata/vmap_wms.map', layers: 'basic', format: 'image/jpeg'},
|
||||||
|
{maxExtent: new OpenLayers.Bounds(33861, 717605, 330846, 1019656), maxResolution: 296985/1024, projection:"EPSG:2805" } );
|
||||||
|
|
||||||
|
map.addLayers([wmslayer, wmslayer2]);
|
||||||
|
|
||||||
|
t.ok(map.baseLayer == wmslayer, "default base layer is first one added");
|
||||||
|
|
||||||
|
map.setBaseLayer(null);
|
||||||
|
t.ok(map.baseLayer == wmslayer, "setBaseLayer on null object does nothing (and does not break)");
|
||||||
|
|
||||||
|
map.setBaseLayer("chicken");
|
||||||
|
t.ok(map.baseLayer == wmslayer, "setBaseLayer on non-layer object does nothing (and does not break)");
|
||||||
|
|
||||||
|
map.setBaseLayer(wmslayer2);
|
||||||
|
t.ok(map.baseLayer == wmslayer2, "setbaselayer correctly sets 'baseLayer' property");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function test_99_Map_destroy (t) {
|
function test_99_Map_destroy (t) {
|
||||||
t.plan( 2 );
|
t.plan( 2 );
|
||||||
map = new OpenLayers.Map($('map'));
|
map = new OpenLayers.Map($('map'));
|
||||||
|
|||||||
Reference in New Issue
Block a user