|
POST
|
Thanks Tim. I am aware of it. But I am using the same graphics layer for my graphics for other reasons.
... View more
07-21-2015
08:55 AM
|
0
|
0
|
2862
|
|
POST
|
Thank you Tim. I think I need to be more specific. What if you have two identical calls, GraphicsLayer.on("mouse-over", function(evt)) As I mentioned, I already have one for the infotemplate and then I need another one for the context menu as described by the ESRI's example as stated in my previous post. The problem is that both calls are intended for different graphics. Perhaps, I could use only one call, and based on the graphics id the appropriate action is taken.
... View more
07-21-2015
07:53 AM
|
0
|
2
|
2862
|
|
POST
|
I need to create a right click context menu for one of my graphics. I am using the example found at: Display context menu | ArcGIS API for JavaScript as an example. In the code I am already using the GraphicsLayer.on("mouse-over", function(evt)) to set the infowindow for other graphics (not for the one that I need to set the context menu). Can the GraphicsLayer listen to multiple triggers? Or do they need to be combined under a single instance of GL.on? Thanks.
... View more
07-20-2015
08:22 PM
|
0
|
16
|
8403
|
|
POST
|
Thank you! Your suggestion for an attribute, turned a light bulb on. I didn't have any attributes since the graphics were just defined on the map and they were not the result of a query. So, I just set a new attribute "id".
... View more
07-18-2015
06:41 PM
|
1
|
0
|
1408
|
|
POST
|
I have several graphics but I want to display an info window only when the mouse hover one specific graphic point. So, I modified a code from a sample, to initiate the display only if the mouse location is the same as the point location (mypoint.lon,mypoint.lat). When I use accuracy to 3 decimals for the lat lon, it works but it displays the infowindow when the mouse is nearby the point. If I increase the accuracy to 4 decimals, then the infowindow never displays unless you hit the exact location which is difficult. Suggestions? Do you have another approach to show the info window only for selected graphics? Thank you. var mp = webMercatorUtils.webMercatorToGeographic(event.mapPoint); if ((mp.x.toFixed(3) === mypoint.lon.toFixed(3)) && (mp.y.toFixed(3) === mypoint.lat.toFixed(3))){ map.graphics.clear(); //use the maps graphics layer as the highlight layer // var graphic = event.graphic; map.infoWindow.setContent(myGraphicMarker.getContent()); map.infoWindow.setTitle(myGraphicMarker.getTitle()); var highlightGraphic = new Graphic(myGraphicMarker.geometry, pointSymbol); map.graphics.add(highlightGraphic); map.infoWindow.show(event.screenPoint, map.getInfoWindowAnchor(event.screenPoint)); }
... View more
07-18-2015
04:39 PM
|
0
|
2
|
4276
|
|
POST
|
Thanks. I modified it so I can use the GraphicsLayer.
... View more
07-10-2015
12:09 PM
|
0
|
0
|
1135
|
|
POST
|
I have this simple code but the polyline is not drawing. The answer, I suspect is simple...but not for a novice in js. Thanks. <!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></title> <link rel="stylesheet" href="https://community.esri.com//js.arcgis.com/3.7/js/esri/css/esri.css"> <style> html, body, #map { height: 100%; width: 100%; margin: 0; padding: 0; } </style> <script src="//js.arcgis.com/3.7/"></script> <script> var map; require([ "esri/map", "esri/geometry/Point", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/graphic", "esri/geometry/Polyline", "esri/SpatialReference", "esri/layers/GraphicsLayer", "dojo/domReady!" ], function( Map, Point, SimpleMarkerSymbol, SimpleLineSymbol, Graphic, Polyline, SpatialReference, GraphicsLayer ) { map = new Map("map", { basemap: "streets", center: [-122.16,37.7238], zoom: 10 }); map.on("load", function() { var gl = new GraphicsLayer(); var myspatialref = new SpatialReference({wkid:102100}); var p = new Point((-122.159, 37.724),new SpatialReference(102100)); var t = new Point((-122.169, 37.721),new SpatialReference(102100)); var coords=[]; coords.push([p,t]); var polyline = new Polyline(myspatialref); var polylineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, 0xFF3333,1,3); polyline.addPath(coords); var polylineGraphic = new Graphic(polyline, polylineSymbol); gl.add(polylineGraphic); map.addLayer(gl); }); }); </script> </head> <body> <div id="map"></div> </body> </html>
... View more
07-09-2015
05:49 PM
|
0
|
3
|
3792
|
|
POST
|
In Flex I was using the new WebMercatorMapPoint(lon,lat) to place correctly points on the map. In Javascript using new Point(lon,lat),new SpatialReference(102100) will have the same placement or should I use something else? Thank you.
... View more
07-08-2015
03:38 PM
|
0
|
1
|
3131
|
|
POST
|
Thanks. I downloaded and use webstorm. I followed instructions including uploading esrijs typescript library, but still didn't catch the case error of the script posted above.
... View more
07-01-2015
12:07 PM
|
0
|
0
|
825
|
|
POST
|
THANK YOU. I am so pissed at myself. This is why JS needs a good IDE to capture silly mistakes like this. Oh boy, do I miss my flash builder.....
... View more
07-01-2015
09:31 AM
|
0
|
2
|
825
|
|
POST
|
Here is: _County_selectedItem= "ALA"; _Route_selectedItem= 112; _PM1_selectedItem= 0.5; queryTask_odometerParams1.where= "County = '" + _County_selectedItem + "'" + " AND Route = " + _Route_selectedItem+ " AND PMc = '" + _PM1_selectedItem + "'" ; However, I think I am getting close. The root of the problem is the loop for (var attr in featureAttributes) If I remove the condition, for (var attr in featureAttributes) { //if (attr === "Odometer") //{ alert(attr + "1: " + featureAttributes[attr]); // } Then the alert shows only the first attribute which is not the Odometer. That explains, why I get no response. Why the loop does not iterate through the rest of the attributes and stops at the first one. The bizarre point is that in the good code, when I used attr = "Odometer", it displays the value just fine!!
... View more
07-01-2015
09:19 AM
|
0
|
4
|
2412
|
|
POST
|
Sure. Here is the "bad code". I already posted the good code in another response. I ensure you that the "where" and "url" lines are identical in both good and bad code since I copied and pasted. Thank you. <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>Shapes and Symbols</title> <link rel="stylesheet" href="http://js.arcgis.com/3.13/esri/css/esri.css"> <style> #info { top: 20px; color: #444; height: auto; font-family: arial; right: 20px; margin: 5px; padding: 10px; position: absolute; width: 115px; z-index: 40; border: solid 2px #666; border-radius: 4px; background-color: #fff; } html, body, #mapDiv { padding:0; margin:0; height:100%; } button { display: block; } </style> <script src="http://js.arcgis.com/3.13/"></script> <script> var map; require([ "esri/map", "esri/layers/DynamicMapServiceLayer", "esri/tasks/QueryTask", "esri/tasks/query", "esri/symbols/SimpleMarkerSymbol", "esri/tasks/FeatureSet", "esri/InfoTemplate", "dojo/_base/Color", "dojo/dom", "dojo/on", "dojo/domReady!" ], function( Map, DynamicMapServiceLayer, QueryTask, Query, SimpleMarkerSymbol, FeatureSet, InfoTemplate, Color, dom, on ) { map = new Map("mapDiv", { basemap: "streets", center: [-25.312, 34.307], zoom: 3 }); map.on("load", readurl); function readurl() { var queryTask_odometer1 = new QueryTask("<place you url>); var queryTask_odometerParams1 = new Query(); queryTask_odometerParams1.geometry = false; queryTask_odometerParams1.outfields=["Odometer"]; queryTask_odometerParams1.where= <place your condition> ; //if (map.loaded) { queryTask_odometer1.execute(queryTask_odometerParams1,queryTask_odometer1_executeCompleteHandler,onError); //} else { // map.on("load", function () { // queryTask_odometer1.execute(queryTask_odometerParams1,queryTask_odometer1_executeCompleteHandler,onError); // }); } function onError(error) { console.log(error); } function queryTask_odometer1_executeCompleteHandler(results) { if (results.features && results.features.length > 0) { alert("something found: " + results.features.length); resultCount=results.features.length; for (var i = 0; i < resultCount; i++) { var featureAttributes = results.features.attributes; for (var attr in featureAttributes) { if (attr === "Odometer") { alert(attr + "1: " + featureAttributes[attr]); } } } }else{ alert("nothing found"); } //alert(mydata); } }); </script> </head> <body> <div id="mapDiv"></div> </body> </html>
... View more
07-01-2015
09:00 AM
|
0
|
6
|
2412
|
|
POST
|
Thanks. I agree, however the issue persists even after the correction. The strange thing is that the Good code even though has the same incorrect evaluation (attr = "Odometer"), it does work by providing a response with the correct value.
... View more
07-01-2015
08:18 AM
|
0
|
8
|
2412
|
|
POST
|
Actually, no. I get a response with the correct value. Thanks. Here is the complete good code, modified from one of the samples in the esri's JS API website. <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>Query State Info without Map</title> <script src="http://js.arcgis.com/3.13/"></script> <script> require([ "dojo/dom", "dojo/on", "esri/tasks/query", "esri/tasks/QueryTask", "dojo/domReady!" ], function (dom, on, Query, QueryTask) { var queryTask = new QueryTask("<place you url>); var query = new Query(); query.returnGeometry = false; query.outFields = ["Odometer"]; on(dom.byId("execute"), "click", execute); function execute () { query.where = <place your condition> ; queryTask.execute(query, showResults); } function showResults (results) { var resultItems = []; var resultCount = results.features.length; alert (resultCount); for (var i = 0; i < resultCount; i++) { var featureAttributes = results.features.attributes; for (var attr in featureAttributes) { if (attr = "Odometer") { alert(attr + "1: " + featureAttributes[attr]); resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>"); } resultItems.push("<br>"); } } // dom.byId("info").innerHTML = resultItems.join(""); } }); </script> </head> <body> US state name : <input type="text" id="stateName" value="474"> <input id="execute" type="button" value="Get Details"> <br /> <br /> <div id="info" style="padding:5px; margin:5px; background-color:#eee;"> </div> </body> </html>
... View more
07-01-2015
08:14 AM
|
0
|
0
|
2412
|
|
POST
|
This function returns undefined variable. The first alert returns: something found:1 the second alert returns "Odometer 1: undefined. I have a very similar code shown below under GOOD CODE that it returns the expected value. Both code execute the same querytask. What's wrong in the first block code? Thanks. function queryTask_odometer1_executeCompleteHandler(results) { if (results.features && results.features.length > 0) { alert("something found: " + results.features.length); resultCount=results.features.length; for (var i = 0; i < resultCount; i++) { var featureAttributes = results.features.attributes; for (var attr in featureAttributes) { if (attr = "Odometer") { alert(attr + "1: " + featureAttributes[attr]); } } } }else{ alert("nothing found"); } //alert(mydata); } GOOD CODE function showResults (results) { var resultItems = []; var resultCount = results.features.length; alert (resultCount); for (var i = 0; i < resultCount; i++) { var featureAttributes = results.features.attributes; for (var attr in featureAttributes) { if (attr = "Odometer") { alert(attr + "1: " + featureAttributes[attr]); resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>"); } } } // dom.byId("info").innerHTML = resultI
... View more
06-30-2015
04:42 PM
|
0
|
12
|
6047
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-19-2025 10:13 PM | |
| 3 | 02-06-2026 10:44 AM | |
| 1 | 01-08-2026 12:50 PM | |
| 1 | 01-05-2026 01:35 PM | |
| 1 | 12-30-2025 10:18 AM |
| Online Status |
Offline
|
| Date Last Visited |
Wednesday
|