hugolina36

Tryng to add layer to indicate all locations for driving time

Discussion created by hugolina36 on Oct 4, 2013
Latest reply on Oct 8, 2013 by manish_patel
Hello everybody,

I'm trying to do the example about serviceAreaTask to show the driving time in a locaion when I click on map. This is my code

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
  <link rel="stylesheet" href="http://js.arcgis.com/3.6/js/dojo/dijit/themes/claro/claro.css">
  <link rel="stylesheet" href="http://js.arcgis.com/3.6/js/esri/css/esri.css">

  <script src="http://js.arcgis.com/3.6/"></script>
    <title>Routing</title>
    <style>
        html, body, #map{
        height: 100%;
        margin: 0;
        padding: 0;
        }
    </style>

    <script>
        var map, serviceAreaTask, params, facilitiesFeatureLayer;
        require([

             "dojo/_base/Color",
             "esri/map",
             "esri/graphic",
             "esri/symbols/SimpleMarkerSymbol",
             "esri/symbols/SimpleLineSymbol",
             "esri/symbols/SimpleFillSymbol",
             "esri/InfoTemplate",
             "esri/layers/FeatureLayer",
             "esri/tasks/FeatureSet",
             "esri/tasks/ServiceAreaSolveResult",
             "esri/tasks/ServiceAreaParameters",
             "esri/tasks/ServiceAreaTask",
             "dojo/domReady!"
        ],
       function (Color, Map, Graphic, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, InfoTemplate, FeatureLayer,  FeatureSet, ServiceAreaSolveResult, ServiceAreaParameters, ServiceAreaTask) {

           esriConfig.defaults.io.proxyUrl = "/proxy";
           map = Map("map", {
               basemap: "streets",
               center: [-86.18, 32.22],
               zoom: 14
           });

           map.on("click", mapClickHandler);
           params = new ServiceAreaParameters();
           params.defaultBreaks = [12];
           params.outSpatialReference = map.SpatialReference;
           params.returnFacilities = true;
           params.returnPointBarriers = true;
           
           serviceAreaTask = new ServiceAreaTask("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Service Area");
           
           function mapClickHandler(evt) {
               map.graphics.clear();
               var symbol = new SimpleMarkerSymbol(
               SimpleMarkerSymbol.STYLE_CIRCLE,
               12,
               new SimpleLineSymbol(
                 SimpleLineSymbol.STYLE_NULL,
                 new Color([247, 34, 101, 0.9]),
                 1
               ),
               new Color([207, 34, 171, 0.5])
             );
               facilitiesFeatureLayer.setSelectionSymbol(symbol);
               map.addLayer(facilitiesFeatureLayer);
               var markerSymbol = new SimpleMarkerSymbol(
                    SimpleMarkerSymbol.STYLE_SQUARE,
                    20,
                    new SimpleLineSymbol(
                      SimpleLineSymbol.STYLE_SOLID,
                      new Color([89, 95, 35]), 2
                    ),
                    new Color([130, 159, 83, 0.40])
                  );
               var location = new Graphic(evt.mapPoint, markerSymbol);
               map.graphics.add(location);
               var features = [];
               features.push(location);
               var facilities = new FeatureSet();
               facilities.features = features;
               params.facilities = facilities;
           

               serviceAreaTask.solve(params, function (solveResult) {
                   var result = solveResult;
                   var polygonSymbol = new SimpleFillSymbol(
           SimpleFillSymbol.STYLE_SOLID,
           new SimpleLineSymbol(
               SimpleLineSymbol.STYLE_SOLID,
               new Color([232, 104, 80]),
               2
           ),
           new Color([232, 104, 80, 0.25])
       );
                  
                   dojo.forEach(solveResult.pointBarriers, function (serviceArea) {
                       serviceArea.setSymbol(polygonSymbol);
                       map.graphics.add(serviceArea);

                       facilitiesFeatureLayer = new FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/41", {
                          
                       });
                       var symbol = new SimpleMarkerSymbol();
                       symbol.style = SimpleMarkerSymbol.STYLE_SQUARE;
                       symbol.setSize(8);
                       symbol.setColor(new Color([255, 255, 0, 0.5]));

                       facilitiesFeatureLayer.setSelectionSymbol(symbol);
                       map.addLayer(facilitiesFeatureLayer);
                   });
               });
           }
       });
    </script>
</head>
<body class="claro">
    <div id="map"></div>
</body>
</html>


Now, I want to modify the serviceAreaTask that whenever I click on a map it will create a fill Polygon to show the driving time AND INSIDE THE FILL POLYGON, THE MAP WILL SHOW ME THE DETAILS LOCATION (A CIRCLE SYMBOL) THAT I CAN GO LIKE THE PICTURE I ATTACH.

[ATTACH=CONFIG]28062[/ATTACH]

PLEASE HELP ME OR GIVE ME A SUGGESTION

THANK YOU FOR YOUR READING TIME !!!!

Attachments

Outcomes