|
POST
|
Robert, correct me if I am wrong. Based of what I am reading to have a right click menu, you have to bind the graphic to the menu. I tried doing in different ways (when you mouse over or when you create graphic) but nothing works. For example, the code I posted in a previous post is quite simple, so I don't know why the bind is not working. Thank you.
... View more
07-22-2015
10:34 AM
|
0
|
4
|
1702
|
|
POST
|
That was my first thought to follow the same logic as I set the infowindow after the graphic was created. However, I run into problems. I could not bind the context menu to the graphic that is in the GL. When I read the On binding dijit/Menu to a graphic I knew that it would not be as simple as it seems. That's why I am using the move out to bind the graphic.
... View more
07-21-2015
04:44 PM
|
0
|
6
|
1702
|
|
POST
|
This is a part of the code.... I first call the createGraphicsMenu, as listed on: Display context menu | ArcGIS API for JavaScript except the myGraphicsLayer2.on("mouse-over",function (event), to create the context menu. because I incorporated in the existing call. So, if the graphics is Begin or End, the infowindow are displayed. If I right click on the Project graphic, the map "jerks" (pans for half inch) and there is no display of context menu What am I doing wrong? Thank you. .......... createGraphicsMenu(); myGraphicsLayer2.on("mouse-over",function (event) { map.graphics.clear(); //use the maps graphics layer as the highlight layer var graphic = event.graphic; if (graphic.attributes.name === "Begin"){ 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)); } if (graphic.attributes.name === "End"){ map.infoWindow.setContent(myGraphicMarker2.getContent()); map.infoWindow.setTitle(myGraphicMarker2.getTitle()); var highlightGraphic = new Graphic(myGraphicMarker2.geometry, pointSymbol); map.graphics.add(highlightGraphic); map.infoWindow.show(event.screenPoint, map.getInfoWindowAnchor(event.screenPoint)); } if (graphic.attributes.name === "Project"){ ctxMenuForGraphics.bindDomNode(graphic.getDojoShape().getNode()); } map.infoWindow.resize(120, 70); map.graphics.on("mouse-out", function () { map.graphics.clear(); map.infoWindow.hide(); if (graphic.attributes.name === "Project"){ ctxMenuForGraphics.unBindDomNode(graphic.getDojoShape().getNode()); } }); });
... View more
07-21-2015
10:01 AM
|
0
|
8
|
3274
|
|
POST
|
Thanks Robert. That's what I was thinking as I mentioned on my response to Tim.
... View more
07-21-2015
08:56 AM
|
1
|
0
|
3274
|
|
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
|
3274
|
|
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
|
3274
|
|
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
|
9076
|
|
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
|
1572
|
|
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
|
4440
|
|
POST
|
Thanks. I modified it so I can use the GraphicsLayer.
... View more
07-10-2015
12:09 PM
|
0
|
0
|
1329
|
|
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
|
3986
|
|
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
|
3245
|
|
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
|
957
|
|
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
|
957
|
|
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
|
2822
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-09-2026 12:44 PM | |
| 1 | 06-08-2026 12:12 PM | |
| 1 | 06-19-2025 10:13 PM | |
| 3 | 02-06-2026 10:44 AM | |
| 1 | 01-08-2026 12:50 PM |
| Online Status |
Offline
|
| Date Last Visited |
3 weeks ago
|