3

I have the following script for drawing a circle and I want to limit the user to a predefined radius:

$('#circle').click(function () {
       clearPreviousSearch();
       map.disableMapNavigation();
       $('#run').fadeOut();
       buttonclickvalue = 'circle';
       drawToolbar.activate(esri.toolbars.Draw.CIRCLE);
         });    

Where should I specify that I want to define the specific radius using the ArcGIS API script?:

var symbol = new SimpleFillSymbol().setColor(null).outline.setColor("blue");
       var gl = new GraphicsLayer({ id: "circles" });
       var geodesic = dom.byId("geodesic");
       map.addLayer(gl);
       map.on("click", function(e) {
         var radius = map.extent.getWidth() / 100;
         var circle = new Circle({
           center: e.mapPoint,
           geodesic: domAttr.get(geodesic, "checked"),
           radius: radius
           });
1
  • Are you getting an error, unexpected behavior, etc? Jan 30, 2015 at 14:27

1 Answer 1

2

You will want to require the Units module "esri/units" and pass the units to the circle this way

var circle = new Circle({
       center: e.mapPoint,
       geodesic: domAttr.get(geodesic, "checked"),
       radius: 100, 
       radiusUnit:units.MILES
});

More info on units here

3
  • 2
    Everything in esri/units maps to a string, so instead of the extra code, you could use the string directly. For miles, it's "esriMiles". The rest are: i.imgur.com/wCM71id.png Jan 31, 2015 at 0:55
  • Sorry but how do I use the string directly? Feb 2, 2015 at 13:53
  • instead of units.MILES you put in "esriMiles" Feb 2, 2015 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.