[OpenLayers-Users] KML Over Yahoo Map Background --- Projection Issues?

Jeff_Hobbs at sjwater.com Jeff_Hobbs at sjwater.com
Wed Aug 27 21:43:47 EDT 2008


Hi,

I'm new to OpenLayers and javascript and this is my first post to the
email list. I have a Yahoo Maps backdrop and am trying to overlay a KML
file. I can see the KML file, however when I pan the polygon is not
stationary and instead moves by a number of pixels as I pan around the
Yahoo Map. I think I've read that this is a projection issue. So, I read
Chris Schmidt's page here:
http://crschmidt.net/~crschmidt/spherical_mercator.html. I think I'm
applying the projection correctly both for the Yahoo basemap and for the
KML vector file. Here's my code:

        var lon =-121.9387914277782; //Just shows degrees		
	  var lat = 37.26906907330967; // Just shows degrees
        var zoom = 15;
        var map;
		var layer;
		var options = {
        projection: new OpenLayers.Projection("EPSG:900913"),
        displayProjection: new OpenLayers.Projection("EPSG:4326"),
        units: "m"
        };
 -- Additional code

stationKML = new OpenLayers.Layer.GML("Stations", "station_full.kml",
		       {
			    projection: new OpenLayers.Projection
("EPSG:4326"), 
				format: OpenLayers.Format.KML, 
				styleMap: stationStyles, 
				formatOptions: {
				   extractStyles: false, //Use the style
map above
				   extractAttributes: true
				}
			});
			
			 map.addLayer(stationKML);

When I have the projection set to 900913, then I don't see my KML file.
However as soon as I change the projection to something like 4326, my KML
file reappears but again the polygon locations "slip" as I pan.

I'm assuming the Yahoo projection is 900913 however I've not been able to
have that verified anywhere and wouldn't be surprised if it were actually
4326 since the KML file aligns well except for the "slip".

Any feedback here would be greatly appreciated.

Thanks in advance!

Jeff
 
 
--------------------------------
Jeff Hobbs
GIS Coordinator
San Jose Water Company (NYSE:SJW)
1265 South Bascom Avenue
San Jose, CA 95128
Voice - (408) 279-7833
Cell - (408) 314-6342
Fax - (408) 279-7889
jeff_hobbs at sjwater.com
http://www.sjwater.com



More information about the Users mailing list