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

Eric Lemoine eric.c2c at gmail.com
Thu Aug 28 00:28:28 EDT 2008


Hi. Welcome to OpenLayers!

Do you pass the sphericalMercator:true option to the Yahoo layer?
Without it you cannot have a vector layer on a Yahoo layer.

Im case you don't already use it, i'd recommend using FireBug for
JavaScript debugging.

Eric

2008/8/28, Jeff_Hobbs at sjwater.com <Jeff_Hobbs at sjwater.com>:
> 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
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



More information about the Users mailing list