|
POST
|
aspect.after(measurement, "setTool", function(toolName){
if(measurement.activeTool){
console.log(toolName + " tool opened.");
}else{
console.log(toolName + " tool closed.");
}
}, true);
Note: this is mostly for identifying when a tool is opened. However, there is an issue when using the 'Location' tool with this snippet. This event will fire, even though the tool has clearly not changed (it is resetting certain widget properties using setTool() internally). This is a behind the scenes issue which I would like to fix. You can work around this issue with the following (it removes the rogue setTool() call in the widget's _measureLocationClickHandler private function) :
aspect.after(measurement, "setTool", function(toolName){
if(measurement.activeTool){
console.log(toolName + " tool opened.");
}else{
console.log(toolName + " tool closed.");
}
}, true);
aspect.before(measurement, "_measureLocationClickHandler", function(args1){
measurement.locationToggleButton = null;
measurement.locationToggleButton = function(){
measurement.clearResult();
};
}, true);
aspect.after(measurement, "_measureLocationClickHandler", function(args1){
measurement.locationToggleButton = function(){
measurement.clearResult();
measurement.setTool("location");
};
}, true);
... View more
07-30-2014
01:29 PM
|
1
|
0
|
965
|
|
POST
|
Hi Adrian, Great point. This was an underlying change that should have been highlighted in the release notes. There are still many more widget changes coming so thanks for the feedback. As you noted, the 'measure-end' event now fires when a successful shape is drawn (3+ nodes). This allows a user to immediately access the geometry of the freshly drawn polyline. To know when the shape is truly done being drawn, you need to check the geometry.type property in the callback.
on(measurement, "measure-end", function(evt){
if(evt.geometry.type === "polygon"){
console.log("Really done.");
}
});
Hope this helps.Let me know if you have any more questions. Again, all feedback is appreciated, especially concerning current widget functionality and potential enhancements.
... View more
07-30-2014
10:38 AM
|
1
|
8
|
2650
|
|
POST
|
Not officially, but I can look into getting that implemented for the next release. You can create one for yourself in the meantime if you'd like with the following snippet:
aspect.after(measurement, "_outputLocationResult", function(args1, args2, args3){
var values = measurement._calculateValueToDisplay(args1, args2, args3);
console.log("values: ", values, args3);
}, true);
aspect.before(measurement, "_switchLocationUnit", function(){
if(measurement.mouseMoveMapHandler){
measurement.mouseMoveMapHandler.remove();
}
}, true),
The first aspect acts as your event listener. It fires when the mouse coordinates are updated in the widget's interface. The second aspect fixes a bug introduced by implementing the first aspect (basically, the mouse handler never gets disconnected). Full 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">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Move</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css">
<style>
html,body {
height:100%;
width:100%;
margin:0;
}
body {
background-color:#FFF;
overflow:hidden;
font-family:"Trebuchet MS";
}
#titlePane{
width:240px;
}
.claro .dijitTitlePaneTitle {
background: #808775;
font-weight:600;
border:solid 1px #29201A;
}
.claro .dijitTitlePaneTitleHover {
background:#808775;
}
.claro .dijitTitlePaneTitleActive {
background:#808775;
}
.claro .dijitTitlePaneContentOuter {
border-right: solid 2px #808775 !important;
border-bottom: solid 2px #808775 !important;
border-left: solid 2px #808775 !important;
}
</style>
<script src="http://js.arcgis.com/3.10/"></script>
<script>
var map;
require([
"dojo/aspect",
"dojo/ready",
"esri/map",
"dojo/parser",
"dojo/dom",
"esri/dijit/Measurement",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dijit/TitlePane"
], function(
aspect,
ready,
Map,
parser,
dom,
Measurement,
BorderContainer,
ContentPane,
TitlePane
) {
ready(function(){
parser.parse();
map = new Map("map", {
basemap: "satellite",
center: [-85.743, 38.256],
zoom: 17
});
measurement = new Measurement({
map: map,
}, "measurementDiv");
measurement.startup();
aspect.before(measurement, "_switchLocationUnit", function(){
if(measurement.mouseMoveMapHandler){
measurement.mouseMoveMapHandler.remove();
}
}, true),
aspect.after(measurement, "_outputLocationResult", function(args1, args2, args3){
var values = measurement._calculateValueToDisplay(args1, args2, args3);
console.log("values: ", values, args3);
}, true);
});
});
</script>
</head>
<body class="claro">
<div id="mainWindow" data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline',gutters:false" style="width:100%; height:100%;">
<div id="map" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'">
<div style="position:absolute; right:20px; top:10px; z-Index:999;">
<div id="titlePane" data-dojo-type="dijit.TitlePane" data-dojo-props="title:'Measurement', closable:'false', open:'false'">
<div id="measurementDiv"></div>
<span style="font-size:smaller;padding:5px 5px;">Press <b>CTRL</b> to enable snapping.</span>
</div>
</div>
</div>
</div>
</body>
</html>
... View more
07-29-2014
10:24 AM
|
1
|
3
|
965
|
|
POST
|
The fix may not have made the patch notes, but it should be in. I can check on this further when I return from the UC. Are you still having issues?
... View more
07-17-2014
08:51 AM
|
0
|
1
|
1154
|
|
POST
|
Steven, thanks for your reply If you go directly to your GeometryService and look under "Supported Operations", do you see toGeocoordinateString and fromGeocoordinateString? For example, looking at the GeometryService used in the sample, we can see that these operations do not exist: Geometry (GeometryServer)
... View more
07-17-2014
08:50 AM
|
0
|
6
|
1533
|
|
POST
|
What version of the geometry service are you using? Your geometry service must be 10.2 or newer. The sandbox sample of the Measurement widget is using an older version of the GeometryService (10.04). http://tasks.arcgisonline.com/ArcGIS/rest/services
... View more
07-16-2014
08:43 AM
|
1
|
15
|
1533
|
|
POST
|
What version of DOJO is the application using and which hosted version of DOJO are you targeting?
... View more
07-10-2014
02:28 PM
|
0
|
1
|
2294
|
|
POST
|
This was confusing at first... there's a lot of jumping around in this code. showResults(); and displayResults() are vague names and should probably be changed to be more specific. showResults() is the callback function for the locator. showResults() looks to take one result (due to return false), create a graphic and put it on the map. showResults() passes the single result to findBoundary() which runs a query that returns a graphic based on:
queryBounds.outFields = [grade];
findBoundary() then passes an attribute from a graphic object (feature) based on feature.attributes[grade] to getSchools() It looks like you expect the results object in your schools query task to contain multiple results but it will always be one result because of this line:
querySchools.where = "Res_num = " + boundNum;
With this in mind, you execute your query task and generate a new 'results' object.
schoolsQt.execute(querySchools, function(results) {
//alert('query should have fired');
displayResults(results);
});
The 'results' object here will only contain one feature, based on the logical application workflow so far. The results object here is different than the one you are using in showResults(); Because of this, your results object is not actually a typical array which means your loop in displayResults() doesn't work:
arrayUtils.forEach(results, function(result, index) {
...
... View more
07-10-2014
02:22 PM
|
1
|
1
|
1474
|
|
POST
|
The Measurement widget provides tools for calculating the current location (Get Location) and measuring distance (Measure Distance) and area (Measure Area). If the map's coordinate system is not Web Mercator or geographic or if complex polygons are drawn the measure widget will need to use the geometry service to project or simplify geometries. Use esri.config.defaults to specify the geometry service for your application.
It is recommended that you create a geometry service for use within your applications. View the Geometry Services help topic in the Server Resource Center for details on creating and publishing a geometry service. ESRI hosts a geometry service on sampleserver3 to support samples published in the Resource Center. You are welcome to use this service for development and testing purposes. ESRI also hosts a geometry service on tasks.arcgisonline.com; this service can be used for production applications however, we do not guarantee that the service will be available 24/7.
From: measurement | API Reference | ArcGIS API for JavaScript
Is there any formula to calculate measurement without firing request to geometry service?
It depends on what unit of measurement you are using and what the coordinate system of your map is.
... View more
07-10-2014
11:13 AM
|
1
|
0
|
3121
|
|
POST
|
Great question! The distance tool is using the GeodesicUtils module ("esri/geometry/geodesicUtils"). For distance (polylines), it uses the following method: geodesicUtils.geodesicLengths(); For area, (polygons), it uses the following method: geodesicUtils.geodesicAreas(); esri | API Reference | geodesicUtils | ArcGIS API for JavaScript esri | API Reference | geodesicUtils.geodesicLengths | ArcGIS API for JavaScript It will only use an external GeometryService if the map's spatial reference is something other than webmercator (102100) or geographic (4326).
... View more
07-10-2014
09:58 AM
|
1
|
2
|
3121
|
|
POST
|
Glad to help! Forget what I said about using a label layer... it is much easier to stick with Text Symbols. 1) Use a task to measure the line (distance) "esri/tasks/DistanceParameters" distanceparameters-amd | API Reference | ArcGIS API for JavaScript 2) Create a text symbol to show that distance "esri/symbol/TextSymbol" Tutorial: Use geometry service to measure distances | ArcGIS API for JavaScript Example: Measure Distances NOTEs - The above sample is very similar to what you want to accomplish. - The above sample does not use the draw toolbar, but can easily be fitted to do so - The above sample is in legacy DOJO syntax (non-AMD)
... View more
07-09-2014
02:05 PM
|
1
|
5
|
3121
|
|
POST
|
The Measurement widget is designed to clear the previous measurement when a tool is selected to make a new measurement. However, we can work around this by doing the following: 1) Listen to 'measure-end' event from the Measurement widget 2) Get and store the geometry from the event object 3) Create a graphic from the event geometry 4) Add that graphic to a separate graphics layer Showing distance on each edge of the line drawn on the map is a bit trickier. Instead of using the Measurement widget, I think it would be easier to use the Draw widget. Under the hood, the Measurement widget functions similarly to the Draw widget. In short, using events, you'd want to take the geometry of a particular line, use a task to measure it, then update your label layer with the result. draw-amd | API Reference | ArcGIS API for JavaScript Add graphics to a map | ArcGIS API for JavaScript
... View more
07-09-2014
01:43 PM
|
1
|
7
|
3121
|
|
POST
|
Great question! You may simply have to change the z-index of the .esriPopupWrapper CSS class. Check out the structure of the popup using your browser's webdev toolbar to confirm. If this doesn't work, you can access the infoWindow's domNode directly via the Map object. map = new Map("map", { center: [-93.00, 35.768], zoom: 4, basemap: "streets" }); //map.infoWinfow.domNode; Using this sample: Show an info window | ArcGIS API for JavaScript
... View more
07-09-2014
12:31 PM
|
0
|
2
|
1097
|
|
POST
|
Just to be clear, are you looking to create a specific widget that handles map navigation using mouse clicks? If so, this would be really easy for you to create Users can already navigate the map using the arrow keys on the keyboard. It would be the same event hookup, listening for a location-sensitive mouse-click instead of a specific key click event.
... View more
07-09-2014
11:01 AM
|
0
|
0
|
509
|
|
POST
|
Hi Jamie, A few quick notes: 1) You have an extra div closing tag. 2) You are calling parser twice. Remove parseOnLoad: true from the following line: var djConfig = {parseOnLoad: true, packages: [{"name": "agsjs","location": "http://gmaps-utility-gis.googlecode.com/svn/tags/agsjs/latest/build/agsjs" }] }; 3) You are using the map's layers-add-result event incorrectly. It will not fire when adding one layer directly to the map using: map.addLayer(rssBeer); or map.addLayers([rssBeer]); You have two options: - Add each layer individually (map.addLayer(rssBeer); ) and handle each unique case in a single layer-add-result event callback. - Add both layers at the same time (map.addLayers([rssBeer, dynaLayer1]); ) and handle each case using a loop in your layers-add-result event callback. There are pros and cons to both and deciding between the two really depends on the rest of your application. Pseudo-Code: 1) map.on("layer-add-result", function (evt) { if("beer layer pseudo code"){ toc = new TOC({ map: map, layerInfos: [{ layer: evt.layer, title: "Beer", collapsed: true, slider: false }] }, "tocDiv1"); toc.startup(); }else if("dyna layer psuedo code"){ toc2 = new TOC({ map: map, layerInfos: [{ layer: evt.layer, title: "Dyna", collapsed: true, slider: false }] }, "tocDiv2"); toc2.startup(); } }); 2) map.addLayers([dynaLayer1, rssBeer]); map.on("layers-add-result", function (evt) { // Loop through the Layers array.forEach(evt.layers, function(layer, index){ var toc = new TOC({ map: map, layerInfos: [{ layer: layer.layer, title: layer.layer.id, collapsed: true, slider: false }] }, layer.layer.id); toc.startup(); }); });
... View more
07-09-2014
10:43 AM
|
0
|
1
|
833
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-26-2014 09:56 AM | |
| 1 | 09-18-2014 11:50 AM | |
| 1 | 09-19-2014 11:28 AM | |
| 1 | 07-09-2014 01:43 PM | |
| 1 | 07-09-2014 02:05 PM |
| Online Status |
Offline
|
| Date Last Visited |
08-14-2024
05:31 PM
|