[OpenLayers-Users] Google Map Layer and vector problem : PLEASE
HELP!!!!
bdtyah
bdtyah at yahoo.fr
Thu Apr 23 12:45:11 EDT 2009
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.
More information about the Users
mailing list