|
POST
|
Jason, You can add an event handler to the map that will listen for the click when you are measuring. Here is an example: var measurement = new Measurement({
map: map
}, dom.byId("measurementDiv"));
measurement.startup();
var measurementHandler;
measurement.on('measure-start', measureOn);
measurement.on('measure-end', measureOff);
function measureOn(e) {
measurementHandler = map.on('click', doStuff);
}
function measureOff(e) {
measurementHandler.remove();
}
function doStuff(e) {
// function to do additional click functions
} Regards, Tom
... View more
03-14-2016
03:56 PM
|
0
|
5
|
2946
|
|
POST
|
Evelyn, If your feature layer is in on demand mode, it will refresh when you pan or zoom. If you want to see your new feature immediately, you could put a featureLayer.refresh() in your successful add function. Glad you have things working! Best Regards, Tom
... View more
03-01-2016
08:16 AM
|
1
|
0
|
2400
|
|
POST
|
Evelyn, I am glad to hear that you got it working. I don't see anywhere in your code where you are adding a new graphic to the map graphics layer. Clicking on the map alone doesn't automatically add a new graphic for the added feature. You would have to add code to add the graphic or refresh the feature layer on your map. Best Regards, Tom
... View more
02-29-2016
02:48 PM
|
0
|
2
|
2400
|
|
POST
|
Richard, You are welcome. To calculate the radius you need the measured units in the same type as the base map you are using. If you want a the radius displayed in a different measure unit, you can convert the value or do a second geometryEngine.geodesicLength call. Regards, Tom
... View more
02-27-2016
10:09 AM
|
2
|
0
|
2609
|
|
POST
|
Evelyn, You are on the right track. You must use an array for your graphics, even if it is just one. It will look like this: var myAttributesGraphic = new Graphic(myGraphic.geometry, null, myAttributes);
myLayer.applyEdits([myGraphic], null, null, function(evt) {
console.log("Está agregando " + adds);
}, function error(err) {
console.log("Hay un error" + err);
}); Best Regards, Tom
... View more
02-26-2016
04:31 PM
|
2
|
0
|
2400
|
|
POST
|
Evelyn, Could you share more of your code? This would enable me to see where the geometry might be that you would want to use. Here is some sample code that I use to applyEdits to some feature layers containing points and lines. There are separate functions that handle the success or error when using the applyEdits. My personal preference, I think it is easier to read. function addNewLSP(evt) {
// update lines and points
pointFeatureLayer.applyEdits([graphicLive, graphicShop, graphicPlay], null, null, pointsUpdated, errorOnUpdate);
lineFeatureLayer.applyEdits([graLinePlay, graLineShop], null, null, linesUpdated, errorOnUpdate);
}
function pointsUpdated(evt) {
alert("Points added");
}
function linesUpdated(evt) {
alert("Lines added");
}
function errorOnUpdate(evt) {
alert("Error updating Live, Shop and Play");
} I hope this will help you! Best Regards, Tom
... View more
02-26-2016
04:00 PM
|
0
|
2
|
2400
|
|
POST
|
Richard, Here is a sample that draws the circle with a radius line and the measurement. It uses geometryEngine to calculate the size of the radius. If you are using a projected map, you would want to use a planarLength instead of a geodesicLength. <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
<title>Circle with Measure</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.15/esri/css/esri.css">
<style>
html,
body,
#map {
height: 100%;
margin: 0;
padding: 0;
}
</style>
<script src="https://js.arcgis.com/3.15/"></script>
<script>
var map;
require(["esri/map",
"esri/graphic",
"esri/geometry/Circle",
"esri/geometry/Polyline",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/TextSymbol",
"esri/symbols/Font",
"esri/Color",
"esri/geometry/geometryEngine",
"dojo/domReady!"],
function(Map,
Graphic,
Circle,
Polyline,
SimpleMarkerSymbol,
SimpleFillSymbol,
SimpleLineSymbol,
TextSymbol,
Font,
Color,
geometryEngine) {
map = new Map("map", {
basemap: "topo", //For full list of pre-defined basemaps, navigate to http://arcg.is/1JVo6Wd
center: [-120.537, 46.592], // longitude, latitude
zoom: 13
});
var centerPt = null;
var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
new Color([255,0,0]), 2),new Color([255,255,0,0.25])
);
var drawCircle = new Graphic(null, sfs, null, null);
var sls = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,0,0]), 2)
var radiusLine = new Graphic(null, sls, null, null);
var font = new Font("20px", Font.STYLE_NORMAL, Font.VARIANT_NORMAL, Font.WEIGHT_BOLDER);
var ts = new TextSymbol("");
ts.setFont(font);
ts.setColor(new Color([255,0,0]));
ts.setOffset(0,20);
var radiusText = new Graphic(null, ts, null, null);
//onDragStart, record the centerPt
map.on("mouse-drag-start", function(evt) {
map.graphics.add(drawCircle);
map.graphics.add(radiusLine);
map.graphics.add(radiusText);
centerPt = evt;
});
//onDrag, calculate distance between currentPoint and centerPt
map.on("mouse-drag", function(evt) {
var pl = new Polyline(map.spatialReference);
pl.addPath([centerPt.mapPoint, evt.mapPoint]);
var radius = geometryEngine.geodesicLength(pl, "meters");
var circle = new Circle({center: centerPt.mapPoint, radius: radius, geodesic: true, spatialReference: map.spatialReference});;
drawCircle.setGeometry(circle);
radiusLine.setGeometry(pl);
ts.setText(radius.toFixed(1) + " meters");
radiusText.setGeometry(centerPt.mapPoint);
console.log("radius is:" + radius);
});
});
</script>
</head>
<body>
<div id="map"></div>
</body>
</html> I have a working sample at: http://gis.yakimawa.gov/demo/circle.html It is a bit unusual. Clicking and dragging the map pans the map. This example also draws a circle. You can also right mouse click and not pan, but you will see a context menu when you finish the circle. Regards, Tom
... View more
02-26-2016
03:17 PM
|
4
|
2
|
2609
|
|
POST
|
Evelyn, Was it your intention to have no geometry for your added graphic? Your sample above sets the geometry to null, perhaps that is the problem? Regards, Tom
... View more
02-26-2016
09:53 AM
|
0
|
4
|
2400
|
|
DOC
|
Kevin, I am calculating an angle to place the text along the line. I am not sure that this would be considered a true bearing though. I can experiment with it and maybe have a sample for you to look at. How would you like the measurement and bearing presented? Regards, Tom
... View more
02-26-2016
08:59 AM
|
1
|
0
|
13308
|
|
POST
|
Greetings Lin, I took a look at your request and it looks like you have already solved your problem. Well done! Please let me know if I can be of any other assistance. Regards, Tom
... View more
02-26-2016
08:16 AM
|
0
|
1
|
1675
|
|
DOC
|
David, You are welcome! You could probably add some javascript to accomplish this too, but modifying the HTML is the simple way to do it. Best Regards, Tom
... View more
02-24-2016
10:02 AM
|
0
|
0
|
13308
|
|
DOC
|
David, To default to the summary totals being displayed you would modify line 35 of the Widget.html file to add a "checked" to the checkbox. It would change from: <input data-dojo-attach-point="showTotals" type="checkbox" /> to this: <input data-dojo-attach-point="showTotals" type="checkbox" checked /> Best Regards, Tom
... View more
02-24-2016
09:41 AM
|
1
|
0
|
9970
|
|
POST
|
David, You are most welcome! It was a fun project to work on. Thanks very much for the information the pricing and plans. We should never exceed that amount of usage. I have a couple of ideas of how to integrate a streetview infowindow to into some of my other apps, but the volume should never come close to that level. Thanks for the link to the older post too. Lots of interesting ways to use streetview. Best Regards, Tom
... View more
02-19-2016
08:28 AM
|
0
|
4
|
2754
|
|
POST
|
David, Thanks! Cheers to Naveen for his code too. I am not attending this years Dev Summit. I had a conflict in schedule that prevents me from attending this year. I am sure it will be a great time. Have fun! Best Regards, Tom
... View more
02-18-2016
02:36 PM
|
0
|
0
|
2754
|
|
DOC
|
Kevin, I can sure add it. Most measure tools have area and perimeter measurements. I can sure make them optional as you add measurements to the map. Regards, Tom
... View more
02-18-2016
02:09 PM
|
1
|
0
|
9970
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-24-2023 10:45 AM | |
| 1 | 05-19-2023 08:13 AM | |
| 1 | 02-22-2023 09:12 AM | |
| 1 | 05-15-2015 03:11 PM | |
| 1 | 02-10-2015 11:52 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-26-2024
04:50 PM
|