[OpenLayers-Users] WGS84 data on Google layer

Craig Stanton c.stanton at niwa.co.nz
Sun Mar 22 18:50:39 EDT 2009


Ah ha, that's the ticket, thanks Jan.

I find it a bit strange that I still need to convert my (WGS84) coordinates for map.setCenter from EPSG:4326 into the map's coordinates when I thought I was telling the map to use 4326 with the options below. Perhaps I am missing a step, or redoing one twice.


***********************************************
 var options = {
                projection: new OpenLayers.Projection("EPSG:900913"),
                displayProjection: new OpenLayers.Projection("EPSG:4326"),

***************************************

    point.transform(displayProjection, map.getProjectionObject());	
    map.setCenter(new OpenLayers.LonLat(point.x, point.y), zoomlevel);
******************************


>>> "Jan H. van der Ven" 03/20/09 8:32 PM >>>
Hi,

I think you need sphericalMercator.
http://openlayers.org/dev/examples/spherical-mercator.html
And the doc page:
http://trac.openlayers.org/wiki/SphericalMercator

Kind regards,


Jan
Craig Stanton schreef:
> The bit that I am missing is the exact projection specification I need to get WGS84 data onto a Google layer.
> I think these are all the relevant bits of code
>
> *************
> var map = new OpenLayers.Map('map'); 
>
> var gphy = new OpenLayers.Layer.Google(
>             "Google Physical",
>             {type: G_PHYSICAL_MAP}
>         );
>
>     map.addLayer(gphy);
> *************
> othermarkers = new OpenLayers.Layer.Vector("Other sites",{strategies: [new OpenLayers.Strategy.Cluster()], 
> 											projection : new OpenLayers.Projection("EPSG:4326"),
> 											styleMap: myStyleMap	 } );
> map.addLayer(othermarkers);
> ********************
> (this is in a loop)
> 	    point = new OpenLayers.Geometry.Point(siteInfo.long, siteInfo.lat);
> 	    spot = new OpenLayers.Feature.Vector(point,siteInfo);
> 	    featureGroup.push(spot);
>
> ******************
> othermarkers.addFeatures(featureGroup);
> ****************
>
> I've tried setting the Vector layer to 900913 and without any projection but I can't see any difference, the features still get further away from their correct spots the further down the screen I move them. If I move the map up they get closer to where they should be.
>
> :-?
>
>
> ~Craig
>
>
>
>   
>>>> "Jan H. van der Ven"  03/20/09 9:05 AM >>>
>>>>         
> Dear Craig,
>
> I have started a projection doc page here: 
> http://trac.openlayers.org/wiki/Documentation/Dev/proj4js.
> If that does not help, please tell me what is missing.
>
> Kind regards,
>
> Jan
>
> Craig Stanton schreef:
>   
>> Hi All,
>>     I've sorted the clustering strategy that Ivan mentioned a few days ago but have come upon another problem I'd appreciate some advice on. My data is stored as WGS84 lat/longs and I want to use Google Terrain as the base layer, but the points drift off their locations as they get closer to the bottom of the map window. I know the problem is in the projections I'm using but I can't figure out the right combination of 900913, 4326, WGS84 etc etc. Could someone please explain what I should do to the vector layer on which my points are plotted and to the Google layer I am using as my base. 
>>
>> Cheers,
>>      Craig
>> NIWA is the trading name of the National Institute of Water & Atmospheric Research Ltd.
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>   
>> ------------------------------------------------------------------------
>>
>>
>> Geen virus gevonden in het binnenkomende-bericht.
>> Gecontroleerd door AVG - www.avg.com 
>> Versie: 8.0.238 / Virusdatabase: 270.11.19/2010 - datum van uitgifte: 03/18/09 20:27:00
>>
>>   
>>     
>
>
> NIWA is the trading name of the National Institute of Water & Atmospheric Research Ltd.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   
> ------------------------------------------------------------------------
>
>
> Geen virus gevonden in het binnenkomende-bericht.
> Gecontroleerd door AVG - www.avg.com 
> Versie: 8.0.238 / Virusdatabase: 270.11.19/2010 - datum van uitgifte: 03/18/09 20:27:00
>
>   


NIWA is the trading name of the National Institute of Water & Atmospheric Research Ltd.



More information about the Users mailing list