[OpenLayers-Users] need draw 2 lines different color
Tony Peña
emperor.cu at gmail.com
Sat Sep 17 12:45:28 EDT 2011
hi i have this example.. but cant see the 2 lines with the 2 colores
if I comment the red part can see the green.. and reverse. commenting green
can see the red line.. BUT.. BOTH!! . nothing show
no red.. and no green either
<html><body>
<div id="mapdiv"></div>
<script src="./OpenLayers/OpenLayers.js"></script>
<script>
map = new OpenLayers.Map("mapdiv");
map.addLayer(new OpenLayers.Layer.OSM());
var lonLat = new OpenLayers.LonLat( -66.202700, 31.275800 )
.transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
);
var zoom = 6;
var player=new OpenLayers.Layer.Vector("Player",
{
styleMap: new OpenLayers.StyleMap({
"default": {
externalGraphic: "./images/airplane.gif",
graphicWidth: 28,
graphicHeight: 28,
graphicYOffset: 0,
rotation: "${angle}",
fillOpacity: "${opacity}"
}
})
});
var vectorLayer = new OpenLayers.Layer.Vector("Vector Layer");
var style_green =
{
strokeColor: "#00FF00",
strokeOpacity: 0.7,
strokeWidth: 2
};
var style_red =
{
strokeColor: "#FF0000",
strokeOpacity: 0.7,
strokeWidth: 2
};
var line_orig = [];
var point_orig = new OpenLayers.Geometry.Point(-3.560945, 40.472225);
var point_plane = new OpenLayers.Geometry.Point(-66.202700, 31.275800);
var line_dest = [];
var point_plane = new OpenLayers.Geometry.Point(-66.202700, 31.275800);
var point_dest = new OpenLayers.Geometry.Point(-82.409164, 22.988609);
line_orig.push(point_orig);
line_orig.push(point_plane);
var lineString_orig = new OpenLayers.Geometry.LineString(line_orig);
line_dest.push(point_plane);
line_dest.push(point_dest);
var lineString_dest = new OpenLayers.Geometry.LineString(line_dest);
lineString_orig.transform(new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject());
lineString_dest.transform(new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject());
var lineFeature_green = new OpenLayers.Feature.Vector(lineString_orig,
null, style_green);
var lineFeature_red = new OpenLayers.Feature.Vector(lineString_dest,
null, style_red);
vectorLayer.addFeatures([lineFeature_green, lineFeature_red]);
map.addLayer(vectorLayer);
var feature=new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point( lonLat.lon, lonLat.lat), {"angle": 242,
opacity: 100});
player.addFeatures([feature]);
map.addLayer(player);
map.setCenter (lonLat, zoom);
</script>
</body></html>
--
Antonio Peña
Secure email with PGP 0x8B021001 available at http://pgp.mit.edu
Fingerprint: 74E6 2974 B090 366D CE71 7BB2 6476 FA09 8B02 1001
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110917/513dfa9b/attachment.html
More information about the Users
mailing list