AnsweredAssumed Answered

polyline not visibel

Question asked by lkoumis on Jul 9, 2015
Latest reply on Jul 10, 2015 by lkoumis

       I have this simple code but the polyline is not drawing. The answer, I suspect is simple...but not for a novice in js. Thanks.

 

<!DOCTYPE html>

<html>

  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">

    <title></title>

    <link rel="stylesheet" href="//js.arcgis.com/3.7/js/esri/css/esri.css">

    <style>

      html, body, #map {

        height: 100%; width: 100%; margin: 0; padding: 0;

      }

    </style>

 

 

    <script src="//js.arcgis.com/3.7/"></script>

    <script>

      var map;

   

      require([

        "esri/map",

        "esri/geometry/Point",

        "esri/symbols/SimpleMarkerSymbol",

  "esri/symbols/SimpleLineSymbol",

        "esri/graphic",

  "esri/geometry/Polyline",

  "esri/SpatialReference",

        "esri/layers/GraphicsLayer",

        "dojo/domReady!"

      ], function(

        Map, Point, SimpleMarkerSymbol, SimpleLineSymbol, Graphic, Polyline, SpatialReference, GraphicsLayer

      ) {

        map = new Map("map", {

          basemap: "streets",

          center: [-122.16,37.7238],

          zoom: 10

        });

        map.on("load", function() {

          var gl = new GraphicsLayer();

  var myspatialref = new SpatialReference({wkid:102100});

          var p = new Point((-122.159, 37.724),new SpatialReference(102100));

  var t = new Point((-122.169, 37.721),new SpatialReference(102100));

  var coords=[];

  coords.push([p,t]);

  var polyline = new Polyline(myspatialref);

  var polylineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, 0xFF3333,1,3);

  polyline.addPath(coords);

  var polylineGraphic = new Graphic(polyline, polylineSymbol);

          gl.add(polylineGraphic);

          map.addLayer(gl);

        });

      });

    </script>

  </head>

  <body>

    <div id="map"></div>

  </body>

</html>

     

 

  

  

  

    

Outcomes