[OpenLayers-Users] Google Map Layer and vector problem : PLEASE HELP!!!!

Heidt, Christopher M. CHRISTOPHER.M.HEIDT at saic.com
Thu Apr 23 12:50:39 EDT 2009


http://faq.openlayers.org/vector-related-questions/why-dont-my-vector-fe
atures-work-over-google-yahoo-virtual-earth-etc/ 

-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
On Behalf Of bdtyah
Sent: Thursday, April 23, 2009 12:45 PM
To: users at openlayers.org
Subject: [OpenLayers-Users] Google Map Layer and vector problem : PLEASE
HELP!!!!


Hello,	
I try to draw markers and a linestring vector over a Google map layer .
The markers (yellow pins) are the linestring vertices.
Everything goes well for the markers but the vector (green line) is not
displayed correctly and it's location changes when I zoom or pan as you
can see on the image :


http://n2.nabble.com/file/n2684438/case.jpg 


Here is the code :

<script language="JavaScript" type="text/javascript">  var lineStyle = {
  strokeColor: "#00FF00",
  strokeOpacity: 1,
  strokeWidth: 6,
  pointerEvents: "visiblePainted"
 };
 var map;
 var s_icon;
 var markersLayer, vectorLayer;

 function init(){
  OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;   	
  bounds = new OpenLayers.Bounds(1.9,44,2.3,44.5);		  
  map = new OpenLayers.Map('map');
  var gmapNorm = new OpenLayers.Layer.Google( "Normal" , {type:
G_NORMAL_MAP, 'maxZoomLevel':18} );
  map.addLayers([gmapNorm]);
  map.addControl(new OpenLayers.Control.LayerSwitcher());
  map.zoomToExtent(bounds);
  // marker icon
  var size = new OpenLayers.Size(13,20);
  var offset = new OpenLayers.Pixel(-(size.w/2), -(size.h/2));
  s_icon = new OpenLayers.Icon('images/smallpin.gif',size,offset);
  // vector layer
  vectorLayer = new OpenLayers.Layer.Vector( "Vectors" );
  vectorLayer.style=lineStyle;
  map.addLayer(vectorLayer);           
  // markers layer
  markersLayer = new OpenLayers.Layer.Markers( "Markers" );
  map.addLayer(markersLayer);
  // draw vectors
  var wkt = "LINESTRING(2.036 44.048,2.137 44.047,2.238 44.050)";	
  var format = new OpenLayers.Format.WKT();
  var features = format.read(wkt);
  vectorLayer.addFeatures(features);
  // draw markers at the same points
  markersLayer.addMarker(new OpenLayers.Marker(new
OpenLayers.LonLat(2.036,44.048),s_icon.clone()));
  markersLayer.addMarker(new OpenLayers.Marker(new
OpenLayers.LonLat(2.137,44.047),s_icon.clone()));
  markersLayer.addMarker(new OpenLayers.Marker(new
OpenLayers.LonLat(2.238,44.050),s_icon.clone()));
 }
</script>


Thank you for your help.
PS: I have the same problem with Yahoo Maps and MS VirtualEarth but not
with my own maps i serve by Geoserver

--
View this message in context:
http://n2.nabble.com/Google-Map-Layer-and-vector-problem-%3A-PLEASE-HELP
%21%21%21%21-tp2684438p2684438.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.

_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users



More information about the Users mailing list