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
});
asked Jan 30, 2015 at 11:05
-
Are you getting an error, unexpected behavior, etc?Chad Cooper– Chad Cooper2015年01月30日 14:27:15 +00:00Commented Jan 30, 2015 at 14:27
1 Answer 1
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
-
2Everything 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.pngDerek Swingley– Derek Swingley2015年01月31日 00:55:24 +00:00Commented Jan 31, 2015 at 0:55
-
Sorry but how do I use the string directly?user2932466– user29324662015年02月02日 13:53:43 +00:00Commented Feb 2, 2015 at 13:53
-
instead of units.MILES you put in "esriMiles"Aamir Suleman– Aamir Suleman2015年02月02日 16:11:32 +00:00Commented Feb 2, 2015 at 16:11
lang-js