<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'>Thank you very much Pedro, I had to set the internal and external projection for the vector and its working perfect now.<br><br><br>----- Original Message -----<br>From: "Pedro Baracho" <pedropbaracho@gmail.com><br>To: "hekuran S. Doli" <hekuran.doli@logisticsplus-ks.com><br>Sent: Monday, November 16, 2009 5:58:12 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna<br>Subject: Re: [OpenLayers-Users] Help with OpenLayer + Google Maps<br><br>what are the projections of your point? I don't think they are on EPSG:900913 as your code states. They are most likely on EPSG:4326 (longitude and latitudes). So you should change your vector_layer projection to EPSG:4326.<br>
<br>I also suggest you to do this:<br>1- Add a displayProjection option to your map variable.<br><br>map = new OpenLayers.Map('map', {displayProjection: new OpenLayers.Projection("EPSG:4326")});<br><br>
2- Add a div for OpenLayers.Control.MousePosition at the bottom of your map:<br>
<br><div id="location"></div><br><br>3- Add OpenLayers.Control.MousePosition<br><br>map.addControl(new OpenLayers.Control.MousePosition({element: $('location')}));<br><br><br>This way you will actually see the coordinates where your mouse is pointing on the projection you want.<br>
<br>Another thing. OpenLayers only have built-in support to EPSG:4326 and 900913. So any other projections besides those, you will have to add Proj4JS too.<br><br>Cheers<br><br><div class="gmail_quote">On Mon, Nov 16, 2009 at 3:42 PM, hekuran S. Doli <span dir="ltr"><<a href="mailto:hekuran.doli@logisticsplus-ks.com" target="_blank">hekuran.doli@logisticsplus-ks.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div style="font-family: Times New Roman; font-size: 12pt; color: rgb(0, 0, 0);">Dear Pedro,<br>
<br>Thank you very very much. Now everything works fine but one the only thing is that the coordinates of the point are pointing elsewhere. Could this be because of projection type? Because the given coordinates should put the point somewhare in Ballkans (Kosovo more exact).<br>
<br>This is what we have so far:<div class="im"><br><br>var featurecollection = <br> {<br> "type":"Feature", <br> "id":"OpenLayers.Feature.Vector_173", <br>
"properties":{}, <br> "geometry":{"type":"Point", "coordinates":[21.159739, 42.656138]}<br> };<br> <br>
<br> <br></div><div class="im"> var geojson_format = new OpenLayers.Format.GeoJSON();<br></div> var vector_layer = new OpenLayers.Layer.Vector("title", {projection: new OpenLayers.Projection("EPSG:900913")});<div class="im">
<br> map.addLayer(vector_layer);<br> vector_layer.addFeatures(geojson_format.read(featurecollection));<br><br><br><br></div><div class="im">----- Original Message -----<br>From: "Pedro Baracho" <<a href="mailto:pedropbaracho@gmail.com" target="_blank">pedropbaracho@gmail.com</a>><br>
To: "hekuran S. Doli" <<a href="mailto:hekuran.doli@logisticsplus-ks.com" target="_blank">hekuran.doli@logisticsplus-ks.com</a>><br>Cc: <a href="mailto:users@openlayers.org" target="_blank">users@openlayers.org</a><br>
</div><div><div></div><div class="h5">Sent: Monday, November 16, 2009 5:14:12 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna<br>Subject: Re: [OpenLayers-Users] Help with OpenLayer + Google Maps<br><br>
I would also add these options to the map if I were you.<br><br>var options = {<br> maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),<br> numZoomLevels:18,<br>
maxResolution:156543.0339,<br> units:'m',<br> projection: "EPSG:900913",<br> displayProjection: new OpenLayers.Projection("EPSG:4326")<br>
};<br> <br> var map = new OpenLayers.Map("map", options);<br><br><div class="gmail_quote">On Mon, Nov 16, 2009 at 1:51 PM, Pedro Baracho <span dir="ltr"><<a href="mailto:pedropbaracho@gmail.com" target="_blank">pedropbaracho@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">var center = new OpenLayers.LonLat(21.159739, 42.656138);<br>map.setCenter(center.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")), 10)<div>
<div></div><div><br><br><div class="gmail_quote">
On Mon, Nov 16, 2009 at 1:45 PM, hekuran S. Doli <span dir="ltr"><<a href="mailto:hekuran.doli@logisticsplus-ks.com" target="_blank">hekuran.doli@logisticsplus-ks.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div style="font-family: Times New Roman; font-size: 12pt; color: rgb(0, 0, 0);">Dear Pedro,<br><br>Thanks a lot for your prompt reply. <br><br>I implemented your suggestion but now the map does not move and the same coordinates point elsewhere. I published the updated example at <a href="http://www.logisticsplus-ks.com/testmap/" target="_blank">http://www.logisticsplus-ks.com/testmap/</a><br>
<br>Regards,<br><font color="#888888">Hekuran</font><div><div></div><div><br><br><br>----- Original Message -----<br>From: "Pedro Baracho" <<a href="mailto:pedropbaracho@gmail.com" target="_blank">pedropbaracho@gmail.com</a>><br>
To: "hekuran S. Doli" <<a href="mailto:hekuran.doli@logisticsplus-ks.com" target="_blank">hekuran.doli@logisticsplus-ks.com</a>><br>Cc: <a href="mailto:users@openlayers.org" target="_blank">users@openlayers.org</a><br>
Sent: Monday, November 16, 2009 3:30:27 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna<br>Subject: Re: [OpenLayers-Users] Help with OpenLayer + Google Maps<br><br>I mispelled projection parameter.<br>
<br>it is lowerCase:<br><br>{projection: new OpenLayers.Projection("EPSG:4326")}<br><br><div class="gmail_quote">On Mon, Nov 16, 2009 at 12:28 PM, Pedro Baracho <span dir="ltr"><<a href="mailto:pedropbaracho@gmail.com" target="_blank">pedropbaracho@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>var gmap = new OpenLayers.Layer.Google(<br> "Google Streets", // the default<br>
</div> {"sphericalMercator": true ,numZoomLevels: 20}<br> );<br><br>var vector_layer = new OpenLayers.Layer.Vector("title", {Projection: new OpenLayers.Projection("EPSG:4326")});<br>
<br><div class="gmail_quote"><div><div></div><div>On Mon, Nov 16, 2009 at 1:20 PM, hekuran S. Doli <span dir="ltr"><<a href="mailto:hekuran.doli@logisticsplus-ks.com" target="_blank">hekuran.doli@logisticsplus-ks.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div>
<div><div style="font-family: Times New Roman; font-size: 12pt; color: rgb(0, 0, 0);">I'm using google map as layer in openlayer. I'm trying to add an point in the map as in example <a href="http://www.logisticsplus-ks.com/testmap/" target="_blank">http://www.logisticsplus-ks.com/testmap/</a>. I'm successfully adding the point in the map but when I move the map the point changes the position. So it does not stay at the coordinates that I give it. <br>
<br>By the way the functions works perfectly with openstreet map, but not with google maps.<br><br>In the following is the code that I'm using:<br><br><script type="text/javascript"><br> var map;<br>
<br><br><br> function init() {<br> map = new OpenLayers.Map('map');<br> map.addControl(new OpenLayers.Control.LayerSwitcher());<br> <br> var gmap = new OpenLayers.Layer.Google(<br>
"Google Streets", // the default<br> {numZoomLevels: 20}<br> );<br><br> map.addLayers([gmap]);<br><br> map.setCenter(new OpenLayers.LonLat(21.159739, 42.656138), 10);<br>
}<br>var featurecollection = {"type":"Feature", "id":"OpenLayers.Feature.Vector_173", "properties":{}, "geometry":{"type":"Point", "coordinates":[21.159739, 42.656138]}};<br>
function addGeoJson() {<br> var geojson_format = new OpenLayers.Format.GeoJSON();<br> var vector_layer = new OpenLayers.Layer.Vector();<br> map.addLayer(vector_layer);<br>
//vector_layer.addFeatures(geojson_format.read(featurecollection));<br> vector_layer.addFeatures(geojson_format.read(featurecollection));<br> } <br> </script><br><br>Any help would be appreciable.<br>
Thanks in advance,<br><font color="#888888">Hekuran<br><br><br></font></div></div><br></div></div>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a><br>
<a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
<br></blockquote></div><br>
</blockquote></div><br>
</div></div></div></div></blockquote></div><br>
</div></div></blockquote></div><br>
</div></div></div></div></blockquote></div><br>
</div></body></html>