allow for setting opacity of alpha image divs. also give both Icon and Marker setOpacity() functions. added tests and modified examples/markers.html to show how to do it.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1541 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-10-03 17:36:03 +00:00
parent 634588abf0
commit 348b0b388d
7 changed files with 90 additions and 10 deletions

View File

@@ -24,6 +24,18 @@
t.eq( cloned.url, "b", "cloned.url does change when edited" );
}
function test_02_Marker_setOpacity(t) {
t.plan( 2 );
icon = new OpenLayers.Icon("a",new OpenLayers.Size(5,6));
t.ok(!icon.imageDiv.style.opacity, "default icon has no opacity");
icon.setOpacity(0.5);
t.eq(icon.imageDiv.style.opacity + "", "0.5", "icon.setOpacity() works");
}
// -->
</script>
</head>

View File

@@ -45,6 +45,32 @@
}
function test_02_Marker_setOpacity(t) {
t.plan( 2 );
var map = new OpenLayers.Map("map");
var url = "http://octo.metacarta.com/cgi-bin/mapserv";
layer = new OpenLayers.Layer.WMS(name, url);
map.addLayer(layer);
mlayer = new OpenLayers.Layer.Markers('Test Layer');
map.addLayer(mlayer);
map.zoomToExtent(new OpenLayers.Bounds(-50,-50,50,50));
//onscreen marker
var ll = new OpenLayers.LonLat(0,0);
var marker = new OpenLayers.Marker(ll);
mlayer.addMarker(marker);
t.ok(!marker.icon.imageDiv.style.opacity, "default marker has no opacity");
marker.setOpacity(0.5);
t.eq(marker.icon.imageDiv.style.opacity + "", "0.5", "marker.setOpacity() works");
}
// -->
</script>

View File

@@ -279,7 +279,7 @@
}
function test_09_Util_modifyAlphaImageDiv(t) {
t.plan( 17 );
t.plan( 18 );
var imageDiv = OpenLayers.Util.createAlphaImageDiv();
@@ -290,8 +290,9 @@
var id = "boo";
var border = "1px solid";
var sizing = "crop";
var opacity = "0.5";
OpenLayers.Util.modifyAlphaImageDiv(imageDiv, id, xy, sz, img, position, border, sizing);
OpenLayers.Util.modifyAlphaImageDiv(imageDiv, id, xy, sz, img, position, border, sizing, opacity);
if (!isMozilla)
t.ok( true, "skipping element test outside of Mozilla");
@@ -305,7 +306,8 @@
t.eq( imageDiv.style.width, sz.w + "px", "image.style.width set correctly");
t.eq( imageDiv.style.height, sz.h + "px", "image.style.height set correctly");
t.eq( imageDiv.style.position, position, "image.style.positionset correctly");
t.eq( imageDiv.style.position, position, "image.style.position set correctly");
t.eq( imageDiv.style.opacity, opacity, "image.style.opacity set correctly");
image = imageDiv.firstChild;
@@ -328,7 +330,7 @@
var filter = "progid:DXImageTransform.Microsoft" +
".AlphaImageLoader(src='" + img + "', " +
"sizingMethod='" + sizing + "')";
"sizingMethod='" + sizing + "') alpha(opacity=" + opacity *100 + ")";
t.eq(imageDiv.style.filter, filter, "div filter value correctly set");
filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
@@ -340,7 +342,7 @@
t.ok(true, "image filter value not set (not in IE)");
}
var imageDiv = OpenLayers.Util.createAlphaImageDiv(id, xy, sz, img, position, border);
var imageDiv = OpenLayers.Util.createAlphaImageDiv(id, xy, sz, img, position, border, "scale", opacity);
if (OpenLayers.Util.alphaHack()) {
var filter = "progid:DXImageTransform.Microsoft" +
".AlphaImageLoader(src='" + img + "', " +