<div dir="ltr">Hi,<br><br>I'm a new user of OpenLayers. I'm trying to display a custom feature over a map, reading a wkt string. This is the code I used:<br><br><script type="text/javascript"><br> var lon = 24;<br>
var lat = 42;<br> var zoom = 5;<br> var map, layer, path;<br> <br> var result_style = OpenLayers.Util.applyDefaults({ <br> strokeWidth: 20, <br> strokeColor: "#ff0000", <br>
fillOpacity: 0 <br> }, OpenLayers.Feature.Vector.style['default']); <br><br> function init(){<br> map = new OpenLayers.Map( 'map', {<br> projection: "EPSG :4806",<br>
maxExtent: new OpenLayers.Bounds(10.9083333334, 42.5686666667, 11.3083333334, 42.9686666667)} );<br> layer = new OpenLayers.Layer.MapServer( "Navstreet Map", <br> "<a href="http://url">http://url</a>",<br>
{layers: 'GreenA Water Streets Autostrade1'}, <br> {gutter: 15});<br> path = new OpenLayers.Layer.Vector("Downtown data area", <br> {style: result_style});<br>
<br> map.addLayers([layer, path]);<br><br> <br> map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);<br> <br> parser = new OpenLayers.Format.WKT();<br> //var wkt = "LINESTRING(11.095 42.761, 11.123 42.767)";<br>
var wkt = "POINT(11.095 42.761)";<br> var geometry = parser.read(wkt); <br> var feature = new OpenLayers.Feature.Vector(geometry); <br> path.addFeatures([feature]);<br>
<br> map.addControl( new OpenLayers.Control.LayerSwitcher() );<br> map.addControl(new OpenLayers.Control.MousePosition());<br> <br> map.zoomToExtent(new OpenLayers.Bounds(10.9083333334, 42.5686666667, 11.3083333334, 42.9686666667), true);<br>
<br> }<br> <br> </script><br><br>If I add the "path" layer, the map displays in a strange way. Looking at firefox debug window, I get the following message:<br><br>"feature.geometry.getBounds() is not a function"<br>
<br>What I'm missing?<br><br>Thank you,<br><br>Damiano<br></div>