AnsweredAssumed Answered

Help me about pointBarriers

Question asked by patricknguyen178 on Sep 30, 2013
Latest reply on Oct 11, 2013 by patricknguyen178
I'm doing an example that when I click a location in a map, it will show me all markers of location that I can drive within 12 minutes car driving. I'm using ServiceAreaTask, SolveAreaResult and pointBarriers to do but it's not work. So anyone can help me please ? :( :( I'm a new beginner so your help will be my best motivation for improvement :) :) :)

 <!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;         require([               "dojo/_base/Color",                                   "esri/map",              "esri/graphic",               "esri/symbols/SimpleMarkerSymbol",              "esri/symbols/SimpleLineSymbol",              "esri/symbols/SimpleFillSymbol",               "esri/tasks/FeatureSet",              "esri/tasks/ServiceAreaSolveResult",              "esri/tasks/ServiceAreaParameters",              "esri/tasks/ServiceAreaTask",              "dojo/domReady!"         ],        function (Color, Map, Graphic, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, FeatureSet, ServiceAreaSolveResult, ServiceAreaParameters, ServiceAreaTask) {              esriConfig.defaults.io.proxyUrl = "/proxy";                         map = new esri.Map("map", {                basemap: "streets",                center: [-95.249, 38.954],                zoom: 14            });             map.on("click", mapClickHandler);              params = new ServiceAreaParameters();            params.defaultBreaks = [5];            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 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 serviceAreaSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT, new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25]));                    var dotSymbol = 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])                             );                                                             dojo.forEach(result.pointBarriers, function(serviceArea) {                        serviceArea.setSymbol(dotSymbol);                        map.graphics.add(serviceArea);                    });                });                }          });       </script> </head> <body class="claro">     <div id="map"></div> </body> </html> 

Outcomes