Select to view content in your preferred language

Need Help.. Buffering a point using javascript

696
3
07-19-2012 03:03 AM
Zhong_DaSeah
Emerging Contributor
Hi, currently I am working on my school project, and I need to buffer a point when I select a point from the map. I am currently trying to use this sample http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm to try and buffer a point. However, when i try to change the map server to the one needed for my project, they requested me to include a proxy url. So I did, and have added the following line to the proxy.config file "<serverUrl url="http://www.onemap.sg/arcgis/rest/services/" matchAll="true"></serverUrl>" and also added these on the javascript codes " esriConfig.defaults.io.proxyUrl = "http://localhost:8893/proxy.ashx";   esriConfig.defaults.io.alwaysUseProxy = false;". The results that was return to me was an error code, it is error code 400 with no message and saying that the error is 'inSR' parameter is invalid,'outSR' parameter is invalid. I am currently stuck as to what to do with it, any help would be appreciated..
0 Kudos
3 Replies
StephenLead
Honored Contributor
can you post more of your code, or (better) a link to your live website?
0 Kudos
Zhong_DaSeah
Emerging Contributor
Here's My code:
And, since I am doing this as my school project, I don't really have any live website... Only on localhost

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" />
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples
      on iOS devices-->
   <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
  <title>Buffer</title>

  <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.0/js/dojo/dijit/themes/claro/claro.css"/>
  <script type='text/JavaScript' src='http://www.onemap.sg/API/JS?accessKEY=xkg8VRu6Ol+gMH+SUamkRIEB7fKzhwMvfMo/2U8UJcFhdvR4yN1GutmUIA3A6r...'></script>
 
  <script type="text/javascript">
     
      dojo.require("esri.map");
      dojo.require("esri.tasks.geometry");

      var map = null;
      var gsvc = null;
      esriConfig.defaults.io.proxyUrl = "http://localhost:8893/proxy.ashx";
      esriConfig.defaults.io.alwaysUseProxy = false;
      function initialize() {
          map = new esri.Map("map");
          var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://www.onemap.sg/ArcGIS/rest/services/basemap/MapServer");
          map.addLayer(basemap);

          gsvc = new esri.tasks.GeometryService("http://www.onemap.sg/arcgis/rest/services/Geometry/GeometryServer");
          dojo.connect(map, "onClick", doBuffer);
      }

      function doBuffer(evt) {
          map.graphics.clear();
          alert("in Do Buffer");
          var params = new esri.tasks.BufferParameters();
          params.geometries = [evt.mapPoint];

          //buffer in linear units such as meters, km, miles etc.
          params.distances = [5, 10];
          params.unit = esri.tasks.GeometryService.UNIT_KILOMETER;
          params.outSpatialReference = map.spatialReference;

          gsvc.buffer(params, showBuffer);
      }

      function showBuffer(geometries) {
          alert("in Show Buffer");
          var symbol = new esri.symbol.SimpleFillSymbol(
        esri.symbol.SimpleFillSymbol.STYLE_SOLID,
        new esri.symbol.SimpleLineSymbol(
          esri.symbol.SimpleLineSymbol.STYLE_SOLID,
          new dojo.Color([0, 0, 255, 0.65]), 2
        ),
        new dojo.Color([0, 0, 255, 0.35])
      );

          dojo.forEach(geometries, function (geometry) {
              var graphic = new esri.Graphic(geometry, symbol);
              map.graphics.add(graphic);
          });
      }

      dojo.addOnLoad(initialize);
  </script>

</head>

<body class="claro">
  <b>Click a location on the map to buffer. Click again on another location to buffer again.</b>
  <div id="map" style="width:600px; height:400px; border:1px solid #000;"></div>
</body>

</html>
0 Kudos
Zhong_DaSeah
Emerging Contributor
And this is what is returned via firebug:

http://localhost:8893/proxy.ashx?http://www.onem...gis/rest/services/Geometry/GeometryServer/buffer 200 OK 6.75s
The Response is:
{"error":{"code":400,"message":"","details":["'inSR' parameter is invalid","'outSR' parameter is invalid"]}}
0 Kudos