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
 });
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jan 30, 2015 at 11:05
1
  • Are you getting an error, unexpected behavior, etc? Commented 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

answered Jan 30, 2015 at 15:08
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 Commented Jan 31, 2015 at 0:55
  • Sorry but how do I use the string directly? Commented Feb 2, 2015 at 13:53
  • instead of units.MILES you put in "esriMiles" Commented Feb 2, 2015 at 16:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.