|
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
|
3948
|
|
POST
|
Thanks. I modified it so I can use the GraphicsLayer.
... View more
07-10-2015
12:09 PM
|
0
|
0
|
803
|
|
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
|
3460
|
|
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
|
3025
|
|
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
|
631
|
|
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
|
631
|
|
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
|
1776
|
|
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
|
1776
|
|
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
|
1776
|
|
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
|
1776
|
|
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
|
5217
|
|
POST
|
I tested that. Unfortunately, after I copied the app folder, the app is not showing in the WAB developer listing of apps. I also tried to zip it and import it, but it says invalid app.
... View more
06-23-2015
11:41 AM
|
0
|
0
|
1892
|
|
POST
|
When I was coding in Flex, I was able to package the libraries and code (export flash builder project) in a single file (fxp) at work and import in at home's flash builder to continue working on my projects. Is there are any similar process with WAB? Can I install WAB at two locations and copy the app folder from one location to paste it at another location to continue working on my project? Thank you.
... View more
06-11-2015
04:24 PM
|
0
|
7
|
5877
|
|
POST
|
ok, I solved the mystery. I finally got the LocalLayer in the configs folder. The instructions that comes with the LocalLayer widget says to add the reference to the widget in: "open the client\stemapp\themes\TabTheme\layouts\default\config.json in a text editor...." However, Rebecca's "Web AppBuilder Developer Edition–Customization Resource List" correctly points out to add the reference in default AND layout1 folders. That made the difference. I guess I learnt two lessons. Do not add customized widgets unless you add one ESRI's widget first to initiate creation of the configs folder. Second, Read Rebecca's list. THANK YOU Robert and Rebecca for your time.
... View more
06-03-2015
01:23 PM
|
1
|
1
|
455
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | yesterday | |
| 1 | Monday | |
| 1 | a week ago | |
| 1 | 10-22-2025 03:33 PM | |
| 1 | 06-27-2025 11:29 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|