[OpenLayers-Users] draw 2 lines different

Tony Peña emperor.cu at gmail.com
Mon Sep 19 12:37:02 EDT 2011


how can i draw 2 lines with different color i have example but only work in
1 way.. green or red but can't see both lines
if i comment line_orig -> green i can see the line_dest -> red ... and
reverse.. but can't see the 2 lines
any idea?

<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/20110919/47367aeb/attachment.html


More information about the Users mailing list