<span class="HcCDpe">Hello,<br><br>I need help! I can not understand why I can not see a line in openlayers.<br>If I don't use projections, I can see it, but then the line is not properly drawn in Firefox (but yes in Explorer). <br>
I know that problem is a projection problem (I have read a lot in Internet), <br>I know Google use Mercator, but I don't know how to solve it.<br><br>Please help !! There is something I can not find.<br>Here is the entire HTML page from what I think is the best approximation (but it doesn't draw the line):<br>
<br>----------------------------------------------------------------------------------------------------------------------<br><html><br><head><br> <title>prueba</title><br><br> <!-- this google key is fo <a href="HTTP://LOCALHOST">HTTP://LOCALHOST</a>, so it should go in your PC --><br>
<script src="<a href="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAAdktgbP3W_jzENycyyxYmhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQAmpwRv0-s77497-2GnWVaa_ulwA">http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAAdktgbP3W_jzENycyyxYmhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQAmpwRv0-s77497-2GnWVaa_ulwA</a>" type="text/javascript"></script><br>
<script src="<a href="http://openlayers.org/dev/OpenLayers.js">http://openlayers.org/dev/OpenLayers.js</a>"></script><br><br> <script type="text/javascript"><br> var lat=42.508;<br>
var lon=1.118;<br> var map; //complex object of type OpenLayers.Map<br><br> function init() {<br><br> //Initialise the 'map' object<br> map = new OpenLayers.Map ("map", {<br>
controls:[<br> new OpenLayers.Control.Navigation(),<br> new OpenLayers.Control.PanZoomBar(),<br> new OpenLayers.Control.Attribution()],<br> maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),<br>
maxResolution: 156543.0399,<br> units: 'm',<br> projection: new OpenLayers.Projection("EPSG:900913")<br> } );<br> var layergoogle = new OpenLayers.Layer.Google("Google Normal",<br>
{ type: G_NORMAL_MAP }, <br> { <br> 'sphericalMercator': true, <br> 'projection': new OpenLayers.Projection("EPSG:900913")<br> }<br>
);<br> var vectores = new OpenLayers.Layer.Vector ("Vector Features",<br> { 'projection': new OpenLayers.Projection("EPSG:4326"),<br> 'displayProjection': new OpenLayers.Projection("EPSG:900913")<br>
}<br> );<br> map.addLayer(layergoogle);<br> map.addLayer(vectores); <br><br> //line near Barcelona, spain, for example<br> var p1 = new OpenLayers.Geometry.Point(2, 41);<br>
var p2 = new OpenLayers.Geometry.Point(41, 2);<br> var points = [p1,p2];<br> var lineString = new OpenLayers.Geometry.LineString(points);<br> var lineFeature = new OpenLayers.Feature.Vector(lineString, null, null); <br>
features = [lineFeature];<br> vectores.addFeatures( [features] ); <br><br> var lonLat = new OpenLayers.LonLat(2, 41)<br> map.setCenter(lonLat, 7);<br> }<br> </script><br>
</head><br><body onload="init();"><br> <div style="width:500px; height:300px" id="map"></div><br></body><br></html><br></span><span class="HcCDpe">----------------------------------------------------------------------------------------------------------------------<br>
</span><br><span class="HcCDpe"><br></span>