AnsweredAssumed Answered

[HELP] Convert from Legacy code to Modern code

Question asked by patricknguyen178 on Sep 24, 2013
Latest reply on Sep 25, 2013 by patricknguyen178
Hi everybody ! I'm practicing this example https://developers.arcgis.com/en/javascript/jssamples/routetask_basic_servicearea.html
and success. Now I'm converting those codes in this example into Modern code but I can't figure out where I'm wrong :( . So please help me to find that error

Here's 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 type="text/javascript">djConfig = { parseOnLoad:true };</script>      <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, clickpoint;         require(["esri/map", "esri/graphic", "esri/tasks/FeatureSet", "esri/tasks/ServiceAreaSolveResult", "esri/tasks/ServiceAreaParameters", "esri/tasks/ServiceAreaTask", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "esri/geometry/Point", "dojo/_base/Color"],              function (Map, Graphic, FeatureSet, ServiceAreaParameters, ServiceAreaTask, SimpleMarkersSymbol, SimpleLineSymbol, Point, SimpleFillSymbol, Color, ServiceAreaSolveResult) {              esriConfig.defaults.io.proxyUrl = "/proxy";             esriConfig.defaults.io.alwaysUseProxy = false;              map = new Map("map", {                 basemap: "streets",                 center: [-86.18, 32.22],                 zoom: 12             });              params = new ServiceAreaParameters();             params.defaultBreaks = [12];             params.outSpatialReference = map.SpatialReference;             params.returnFacilities = false;              serviceAreaTask = new ServiceAreaTask("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Service Area");              map.on("click", mapClicked);              function mapClicked(evt) {                 clickpoint = evt;                 map.graphics.clear();                 var markerSymbol = new SimpleMarkerSymbol(       SimpleMarkerSymbol.STYLE_CROSS, 22,       new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 128, 0]), 4));                  var point = new Point(evt.mapPoint.x, evt.mapPoint.y, map.spatialReference);                  var location = new Graphic(point, 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 polygonSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 2), new Color([255, 250, 0, 0.25]));                     dojo.forEach(solveResult.serviceAreaPolygons, function(serviceArea) {                         serviceAre.setSymbol(polygonSymbol);                         map.graphics.add(serviceArea);                     });                 });                    }         });                 </script> </head> <body class="claro">     <div id="map"></div> </body> </html>


Many thanks ^_^

Outcomes