[OpenLayers-Users] changing attributes of elements in vector layer and IE issues

Andreas Hocevar andreas.hocevar at gmail.com
Wed Jan 16 11:02:55 EST 2008


O. Baum wrote:
> Hi again,
>
> 2008/1/16, Andreas Hocevar <andreas.hocevar at gmail.com>:
>   
>> Then I suspect some style setting that VML does not like. This can
>> happen with some well-known color names that work in HTML, but not in
>> VML.
>>     
>
> I haven't used anything special... see below for details!
> I just used strokeColor, strokeOpacity and strokeWidth.
>
>   
>> Can you post the snippet of your style hash that makes IE fail?
>>     
>
> I will send you the complete code of a test page which demonstrates the problem.
> The projection stuff is commented out because it is not supported in v2.5.
>
> Changing the script src from "/OpenLayers-2.5" to "/OpenLayers-trunk"
> makes my IE6 draw nothing at all.
> However, with v2.5 at first the mentioned non-desired polygon is drawn
> which switches to a polyline when clicking the button below the map.
>
> here we go:
>
> -----------8<---------------------------------------------------------------------------------
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:v="urn:schemas-microsoft-com:vml">
>   <head>
>     <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
>
>     <title>OpenLayers Test4</title>
>
> 	<style type="text/css">
> 	#map {
> 		width: 100%;
> 		height: 512px;
> 		border: 1px solid black;
> 		background-color: red;
> 	}
> 	</style>
>
> 	<!-- Localhost key -->
> 	<script	src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg'
> type="text/javascript"></script>
> 	<script src="/OpenLayers-2.5/OpenLayers.js" type="text/javascript"></script>
> 	
> 	<script type="text/javascript">
>         var map, vectors;
>
>         function init(){
>
>             var options = {
>               /*
>               projection: new OpenLayers.Projection( "EPSG:900913" ),
>               displayProjection: new OpenLayers.Projection( "EPSG:4326" ),
>               units: "m",
>               maxResolution: 156543.0339,
>               maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
>                                                 20037508.34, 20037508.34),
>               */
>               numZoomLevels: 18,
>               controls: [
>                 new OpenLayers.Control.MouseDefaults(),
>                 new OpenLayers.Control.MousePosition(),
>                 new OpenLayers.Control.PanZoomBar()
>               ]
>             };
>
>             map = new OpenLayers.Map( 'map' , options );
>
>             var hybrid = new OpenLayers.Layer.Google( "Google Hybrid Map",
>               { type: G_HYBRID_MAP,
>                 'maxZoomLevel':18 //,
>                 //'sphericalMercator': true
>               } );
>             map.addLayers( [hybrid] );
>
>             // create and add the vector layer
>             vectors = new OpenLayers.Layer.Vector( "Vector Layer" );
>             map.addLayer( vectors );
>
> 			// define points for a polyline
>             var pointList = [
>               new OpenLayers.Geometry.Point( 13.38134765625,
> 52.50953477032727 ), // Berlin
>               new OpenLayers.Geometry.Point( 2.35107421875,
> 48.850258199721495 ), // Paris
>               new OpenLayers.Geometry.Point( 12.54639, 41.83683 ) // Rome
>             ];
>
> 			// create a style for the polyline
>             var normalStyle = OpenLayers.Util.extend( {},
> OpenLayers.Feature.Vector.style["default"] );
>             normalStyle.strokeColor = "#00B000";
>             normalStyle.strokeOpacity = .7;
>             normalStyle.strokeWidth = 8;
>
>             // create a feature from the point list
>             var lineFeature = new OpenLayers.Feature.Vector( new
> OpenLayers.Geometry.LineString(pointList), null, normalStyle );
>
>             // this method has to be called for every feature that
> will be added to the layer!!
>             //lineFeature.geometry.transform( new
> OpenLayers.Projection("EPSG:4326"), new
> OpenLayers.Projection("EPSG:900913") );
>             vectors.addFeatures( [lineFeature] );
>
> 			// zoom to the extent of the polyline
>    			map.zoomToExtent( lineFeature.geometry.getBounds() );
>         }
>
>     </script>
> </head>
> <body onload="init()">
>   <h1>OpenLayers With Google Layer Example</h1>
>   <div id="map"></div>
>   <div id="buttons"><input type="button" onclick="vectors.redraw();"
> value="redraw" /></div>
> </body>
> </html>
> ----------->8---------------------------------------------------------------------------------
>
> Thanks for your help!
>
> Regards,
>
>    O. Baum
>   




More information about the Users mailing list