POST
|
I am seeing a very similar result. If I create a feature service with one feature class and one sde table I can see all of the feature classes attributes. However if I join the feature class to the table by one field I can only see the object ID of the feature class. Is this normal?
... View more
03-19-2014
10:58 AM
|
0
|
0
|
172
|
POST
|
Correct. I would like to have a dynamic service on by default and have a cached service containing aerials to be switched on with a button click. Thanks for your help. I think I have been staring at this for to long because I had a typo. After correcting that the visibility toggle works.
... View more
02-11-2014
11:27 AM
|
0
|
0
|
564
|
POST
|
Jake, I couldn't get that method to work outside the function where I am defining the layer. I have tried it several ways and it seems like a simple thing to do I just can't get the syntax. aerialsLayer.setVisibility(false); mapMain.aerialsLayer.setVisitility(false); Unhandled exception at line 102, column 19 in http://localhost:58255/myBaseMapButtonTest.html 0x800a138f - JavaScript runtime error: Unable to get property 'setVisitility' of undefined or null reference
... View more
02-11-2014
11:16 AM
|
0
|
0
|
564
|
POST
|
Hi, I am attempting to create a layer toggle that will turn a tiled service's visibility from true to false. So far I can't find an example where someone is setting a layers visibility to false. Is this possible with a statement similar to this: mapMain.layers.aerialsLayer.visible = false;?? Any suggestions are appreciated. <!doctype html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="translucent-black"> <title>Custom Basemap Switcher</title> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script src="http://js.arcgis.com/3.7/"></script> <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/overcast/jquery-ui.css" /> <link rel="stylesheet" href="http://js.arcgis.com/3.7/js/dojo/dijit/themes/nihilo/nihilo.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.7/js/esri/css/esri.css"> <style> html, body{ height: 100%; width: 99.9%; margin: 0; padding: 0; overflow:hidden; } #map{ width: 100%; height: 100%; position: fixed; padding: 0; } #BasemapToggle { position: absolute; top: 20px; right: 20px; z-index: 50; } </style> <script> var mapMain, currentBaseMap; //Create an empty array to store a reference to the currently selected basemap layer //var currentBasemap = []; require([ "esri/map", "esri/geometry/Extent", "esri/layers/ArcGISTiledMapServiceLayer", "esri/layers/ArcGISDynamicMapServiceLayer", "dojo/ready", "dojo/parser", "dojo/on", "dojo/dom", "dojo/_base/array", "dijit/layout/BorderContainer", "dijit/layout/ContentPane"], function ( Map, Extent, ArcGISTiledMapServiceLayer, ArcGISDynamicMapServiceLayer, ready, parser, on, dom, array, BorderContainer, ContentPane ) { ready(function () { // Create the map mapMain = new Map("map") aerialsLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://gisaprd/ArcGIS/rest/services/Aerials_4inch_12inch_Cached/MapServer", { "id": "Aerials", "visible":false}); //If I uncomment these two lines both layers draw over the top of each other as expected. mapMain.addLayer(aerialsLayer); streetsLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gisaprd/ArcGIS/rest/services/SRSLandbase/MapServer", { "id": "Streets" }); mapMain.addLayer(streetsLayer); currentBaseMap = "Streets"; baseMapSwitchButton = dom.byId("baseMapSwitch"); on(baseMapSwitchButton, "click", ChangeBaseMap); }); function errBack(results) { alert(results); } function ChangeBaseMap() { if (currentBaseMap == "Streets") { currentBaseMap = "Aerials"; //========================================================================================== //This is where I would like to have the layer visibility toggle on/off // mapMain.aerialsLayer.visible = true; // mapMain.layers.aerialsLayer.visible = true; } else if (currentBaseMap == "Aerials") { currentBaseMap = "Streets"; // mapMain.layers.aerialsLayer.visible = false; } //========================================================================================== }; }); </script> </head> <body> <div id="map"></div> <div id="basemapDialog" title="Choose a Basemap"> <div id="BasemapToggle"> <button data-dojo-type="dijit.form.Button" id="baseMapSwitch">Aerials</button><br> </div> </div> </body> </html>
... View more
02-11-2014
10:33 AM
|
0
|
4
|
1628
|
POST
|
Jake, Awesome suggestion. I was assuming I would have to search the values by explicitly saying what graphics layer to get to its graphics features. EX: mapMain.graphicsLayer.graphics I can throw a break point into the for loop and watch it iterate through whether the graphic is in the extent or not but the web page hangs up and never finishes the function. I am trying to trouble shoot that now.
... View more
02-07-2014
06:08 AM
|
0
|
0
|
1293
|
POST
|
Jake, Thanks for the reply. I am still curious how to select graphics within a graphics layer because I know I will possibly be adding multiple points features from different sources that I would like to control from a legend or toggle menu to turn the layers off and on. Ex: Items that need inspected this year, next year, etc. I also need to select the individual layers to assign work and complete work. I will be getting all of my data from an Oracle table without a spatial component so I won't be able to return any geometry because there isn't any. I will have x/y fields to let me plot the point. Coming from a silverlight background I know I had to create multiple graphics layers, one for each layer. Is there a way to select individual graphics within the graphics layer? Thanks!
... View more
02-07-2014
04:50 AM
|
0
|
0
|
1293
|
POST
|
I've added a click event to a GraphicsLayer that has graphics from X/Y locations unrelated to Feature Layers. However, I've noticed that it's only showing a single graphic at a time. I basically need to select multiple graphics within an extent. The QueryTask forces me to point to a URL of a Feature Layer. But I don't have a Feature Layer; I only have Graphics. What gives? How can I select multiple graphics from a single Graphicslayer when the user clicks on a map? Feel like I'm missing something simple here. Take a look at this one too: https://developers.arcgis.com/javascript/jssamples/graphics_multiple_layers.html
... View more
02-06-2014
11:14 AM
|
0
|
0
|
354
|
POST
|
I am trying to select specific graphics point features that I am adding through code. I can't seem to figure out how to grab the individual graphics withing the graphics layer. Any help is appreciated. /// <reference path="index.html" /> var mapMain, selectionLayer, graphicsLayer, selectionToolbar, graphic, defaultSymbol, highlightSymbol, simpleMarkerSymbol, resultTemplate; require([ "esri/map", "esri/geometry/Extent", "esri/layers/ArcGISTiledMapServiceLayer", "esri/layers/FeatureLayer", "esri/tasks/GeometryService", "esri/tasks/query", "esri/tasks/QueryTask", "esri/tasks/FeatureSet", "esri/graphic", "esri/toolbars/draw", "esri/config", "dojo/ready", "dojo/parser", "dojo/on", "dojo/_base/array", "dijit/layout/BorderContainer", "dijit/layout/ContentPane"], function ( Map, Extent, ArcGISTiledMapServiceLayer, FeatureLayer, GeometryService, Query, QueryTask, FeatureSet, graphic, draw, config, ready, parser, on, array, BorderContainer, ContentPane ) { ready(function () { // Create the map mapMain = new Map("cpCenter") var layerURL = "http://gisaprd/ArcGIS/rest/services/BaseMap_ArcReader_Cached/MapServer"; myLayer = new esri.layers.ArcGISTiledMapServiceLayer(layerURL, { "opacity": 0.5 }); mapMain.addLayer(myLayer); dojo.connect(mapMain, "onLoad", initSelectToolbar); //dojo.connect(mapMain, "onLoad", function () { // selectionLayer = new esri.layers.GraphicsLayer(); // mapMain.addLayer(selectionLayer); //}); var queryTask = new QueryTask("http://gisaprd/ArcGIS/rest/services/SRSOutageTest/MapServer/3"); var query = new Query(); query.returnGeometry = false; query.outFields = ["*"]; query.where = "GIS_X IS NOT NULL"; queryTask.execute(query, showResults, errBack); simpleMarkerSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([0,255,255])); defaultSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([0, 0, 255])); highlightSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([255, 0, 0])); }); //initialize drawing toolbar function initSelectToolbar(mapMain) { selectionToolbar = new esri.toolbars.Draw(mapMain); //find points in Extent when user completes drawing extent dojo.connect(selectionToolbar, "onDrawEnd", findPointsInExtent); } function showResults(results) { var len = results.features.length; var featureSet = new FeatureSet(); featureSet = results; graphicsLayer = new esri.layers.GraphicsLayer(); //graphicsLayer.setInfoTemplate(new esri.InfoTemplate("Attributes", "${*}")); dojo.forEach(featureSet.features, function (feature,index) { var spID = featureSet.features[index].attributes.SP_ID; var address = featureSet.features[index].attributes.ADDRESS; var callbackstatus = featureSet.features[index].attributes.CALLBACKSTATUS; var meterNumber = featureSet.features[index].attributes.METERNUMBER; feature.geometry = new esri.geometry.Point(featureSet.features[index].attributes.GIS_X, featureSet.features[index].attributes.GIS_Y, new esri.SpatialReference({ wkid: 4326 })); //graphic = new esri.Graphic(feature, simpleMarkerSymbol); feature.symbol = simpleMarkerSymbol; graphicsLayer.add(feature); }); mapMain.addLayer(graphicsLayer); } function findPointsInExtent(extent) { var graphics = mapMain.graphics.graphics; var results = []; //dojo.forEach(mapMain.graphics.graphics, function (graphic) { for (var i = 0, il = graphics.length; i < il; i++) { graphic = graphics; if (extent.contains(graphic.geometry)) { graphic.setSymbol(highlightSymbol); //selectionLayer.add(graphic); results.push(graphic.getContent()); //Grab Results here and push to slide out or form - look at Washington State city selection example //results.push(graphic.getContent()); } //else if point was previously highlighted, reset its symbology else if (graphic.symbol == highlightSymbol) { graphic.setSymbol(simpleMarkerSymbol); } }; selectionToolbar.deactivate(); } function errBack(results) { alert(results); } }); --------------------------------------------------- HTML PAGE --------------------------------------------------- <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>CP-Isolated Steel Services</title> <!-- Configure dojo for asynchronous module loading --> <script> var dojoConfig = { async: true }; </script> <!-- Reference libraries. The first CSS is a Dojo theme that gives dijits a consistent style. --> <link rel="stylesheet" href="http://js.arcgis.com/3.7/js/dojo/dijit/themes/nihilo/nihilo.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.7/js/esri/css/esri.css"> <link rel="stylesheet" href="css/workwiththemap.css"/> <script src="http://js.arcgis.com/3.7/"></script> <script src="JavaScript/CP_IsolatedSteelServices.js"></script> </head> <body class="nihilo"> <button data-dojo-type="dijit.form.Button" onClick="selectionToolbar.activate(esri.toolbars.Draw.EXTENT);">Select</button> <button data-dojo-type="dijit.form.Button" onClick="graphic.setSymbol(highlightSymbol);">Clear Selection</button><br> <div id="cpCenter" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'sidebar', liveSplitters:'true'" > </div> </body> </html>
... View more
02-06-2014
11:11 AM
|
0
|
4
|
9906
|
POST
|
Terry, Good advice and thanks again for the help. People like you make the GIS community.
... View more
12-11-2013
06:30 AM
|
0
|
0
|
447
|
POST
|
Do you have the outSpatialReference on the Query the QueryTask is executing set to match your map? That wy the results from the query task shouldn't need reprojected at all. e.g.
QueryTask qt = new QueryTask(uriQuery);
ESRI.ArcGIS.Client.Tasks.Query qry = new ESRI.ArcGIS.Client.Tasks.Query();
qry.ReturnGeometry = true;
qry.Where = strWhere;
qry.OutSpatialReference = MyMap.SpatialReference;
Re: the error on the null reference - my code sets a URL as an Application level resource, try replacing it with a hard coded URL to your geometry service. I am not returning any geometry with my querytask. Would that matter?
... View more
12-11-2013
05:49 AM
|
0
|
0
|
447
|
POST
|
Terry, You are a genius. I got it working, thanks for your help. For anyone else, here is my method call passing my graphics, the spatial reference, and the graphics layer: geometryService.ProjectAsync(graphicsLayer.Graphics, new ESRI.ArcGIS.Client.Geometry.SpatialReference(102697), graphicsLayer); And in my project completed event I have my graphics with the attributes: void geometryService_ProjectCompleted(object sender, GraphicsEventArgs e) { //update rss layer with graphics reprojected to match the map GraphicsLayer GLayer = MyMap.Layers[(e.UserState as Layer).ID] as GraphicsLayer; . . . . }
... View more
12-11-2013
05:47 AM
|
0
|
0
|
447
|
POST
|
Try using the method overload that allows you to pass in the 3rd 'user token' parameter & pass the graphics layer as that object. In the handler for your ProjectCompleted event cast that back to a layer and apply the projected geometry to the graphics. Code below isn't tested & off the top of my head, but might help -
.... some other code above sets MyMap, GLayer is a graphics layer on MyMap and gets the URL for a geometry service....
if (MyMap.SpatialReference.WKID != 4326)
{
GeometryService gserv = new GeometryService(Application.Current.Resources["GeometryURL"].ToString());
gserv.ProjectCompleted += gserv_ProjectCompleted;
gserv.ProjectAsync(GLayer.Graphics, MyMap.SpatialReference, GLayer);
}
}
void gserv_ProjectCompleted(object sender, GraphicsEventArgs e)
{
//update rss layer with graphics reprojected to match the map
GraphicsLayer GLayer = MyMap.Layers[(e.UserState as Layer).ID] as GraphicsLayer;
for (int i = 0; i < GLayer.Graphics.Count(); i++)
{
GLayer.Graphics.Geometry = e.Results.Geometry;
}
}
Might want to test and make sure the order is maintained by checking an attribute that would easily identify if it's the correct graphic (e.g. name = 'New York' is not showing up in Texas...) Hey Terry, Thanks for the reply. I am not 100% following your suggestion. Maybe if I provide more info and a couple code snippets it will help. I have a queryTask that hits a view and grabs the most current position of a truck (Lat/Lon), the machine name, and user name. Because my data is in a State Plane coordinates I need to reproject the graphics. private void QueryTask_ExecuteCompletedTruckGPS(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; GraphicsLayer graphicsLayer = MyMap.Layers["TruckGPS"] as GraphicsLayer; graphicsLayer.ClearGraphics(); if (featureSet != null && featureSet.Features.Count > 0) { foreach (ESRI.ArcGIS.Client.Graphic feature in featureSet.Features) { if ((feature.Attributes["LONGITUDE"] != null) && (feature.Attributes["LATITUDE"] != null)) { var Machine_Name = feature.Attributes["MACHINE_NAME"].ToString(); var User_Name = feature.Attributes["USER_NAME"].ToString(); double lon = Convert.ToDouble(feature.Attributes["LONGITUDE"]); double lat = Convert.ToDouble(feature.Attributes["LATITUDE"]); feature.Geometry = new MapPoint(lon, lat, new SpatialReference(4326)); feature.Symbol = LayoutRoot.Resources["TRUCK"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(feature); } } { (MyMap.Layers["TruckGPS"] as GraphicsLayer).Refresh(); }; } // Call the Asynchronous Geometry.ProjectAsync Method. It will generate Graphics in the WKIS 102697 SpatialReference. geometryService.ProjectAsync(graphicsLayer, new ESRI.ArcGIS.Client.Geometry.SpatialReference(102697)); } void geometryService_ProjectCompleted(object sender, GraphicsEventArgs e) { // Executes when the GeometryService.ProjectAsync has completed. The e.Results parameters has the new Graphics // Projected in the WKID 102697 SpatialReference. // Create a new GraphicsLayer for display in the WKID 102697 Spatial Reference. ESRI.ArcGIS.Client.GraphicsLayer TruckGraphicsLayer_WKID_102697 = new ESRI.ArcGIS.Client.GraphicsLayer(); TruckGraphicsLayer_WKID_102697.ID = "TruckGraphicsLayer"; // Loop through each Graphic that was returned. foreach (ESRI.ArcGIS.Client.Graphic myGraphic in e.Results) { // Create a new MapPoint. ESRI.ArcGIS.Client.Geometry.MapPoint myMapPoint_WKID_102697 = (ESRI.ArcGIS.Client.Geometry.MapPoint)myGraphic.Geometry; // Create a new Graphic, set its Geometry and Symbol and add it to the GraphicsLayer. ESRI.ArcGIS.Client.Graphic myGraphic_WKID_102697 = new ESRI.ArcGIS.Client.Graphic(); myGraphic_WKID_102697.Geometry = myMapPoint_WKID_102697; myGraphic_WKID_102697.Symbol = LayoutRoot.Resources["TRUCK"] as ESRI.ArcGIS.Client.Symbols.Symbol; TruckGraphicsLayer_WKID_102697.Graphics.Add(myGraphic_WKID_102697); // Add the GraphicsLayer to the Map Control MyMap.Layers.Add(TruckGraphicsLayer_WKID_102697); } } This code is working to create a new graphics layer and create the new map points. But I don't want to re-create the graphics I want to update the existing truck graphicsLayer coordinates. When I plugged in your code and did some testing I tried typing in my url but I was getting null reference exceptions on this line: GeometryService gserv = new GeometryService(Application.Current.Resources["GeometryURL"].ToString()); I understand the suggestion you gave just not the execution. Thanks for your help.
... View more
12-11-2013
05:08 AM
|
0
|
0
|
447
|
POST
|
Hi, I am trying to re-project a graphics layer and I want a map tip to pop up for the graphics. I am calling this asynchronous method: // Call the Asynchronous Geometry.ProjectAsync Method. It will generate Graphics in the WKIS 102697 SpatialReference. geometryService.ProjectAsync(graphicsLayer, new ESRI.ArcGIS.Client.Geometry.SpatialReference(102697)); The graphics I get back are missing the attributes I had before the method call. Is there a way to retain the original graphic's attributes for use with the new graphic's maptips?
... View more
12-10-2013
10:56 AM
|
0
|
7
|
2674
|
POST
|
TDenis, Thanks for the links to those examples. I have recreated the example in the API samples successfully. As I have been stepping through the sample code I notice this line of code: MapPoint inputMapPoint = new MapPoint(x, y, new SpatialReference( 4326)); Could I not just add my map points to the map specifying my spatial reference? Like this: feature.Geometry = new MapPoint(lat, lon, new SpatialReference (102697)); I found that I can call this method: geometryService.ProjectAsync(graphicsLayer, new ESRI.ArcGIS.Client.Geometry.SpatialReference(102697)); and then place the graphics correctly on my map. However I can't see the attributes that were with the graphicsLayer when I called the method. Is there a way to carry over the attributes for maptips, etc.? void geometryService_ProjectCompleted(object sender, GraphicsEventArgs e) { // Executes when the GeometryService.ProjectAsync has completed. The e.Results parameters has the new Graphics // Projected in the WKID 102697 SpatialReference. // Loop through each Graphic that was returned. foreach (ESRI.ArcGIS.Client.Graphic myGraphic in e.Results) { // Create a new GraphicsLayer for display in the WKID 4326 Spatial Reference. ESRI.ArcGIS.Client.GraphicsLayer TruckGraphicsLayer_WKID_102697 = new ESRI.ArcGIS.Client.GraphicsLayer(); TruckGraphicsLayer_WKID_102697.ID = "TruckGraphicsLayer"; // Create a new MapPoint. ESRI.ArcGIS.Client.Geometry.MapPoint myMapPoint_WKID_102697 = (ESRI.ArcGIS.Client.Geometry.MapPoint)myGraphic.Geometry; // Create a new Graphic, set its Geometry and Symbol and add it to the GraphicsLayer. ESRI.ArcGIS.Client.Graphic myGraphic_WKID_102697 = new ESRI.ArcGIS.Client.Graphic(); myGraphic_WKID_102697.Geometry = myMapPoint_WKID_102697; myGraphic_WKID_102697.Symbol = LayoutRoot.Resources["TRUCK"] as ESRI.ArcGIS.Client.Symbols.Symbol; TruckGraphicsLayer_WKID_102697.Graphics.Add(myGraphic_WKID_102697); // Add the GraphicsLayer to the Map Control MyMap.Layers.Add(TruckGraphicsLayer_WKID_102697); } }
... View more
12-10-2013
10:39 AM
|
0
|
0
|
821
|
POST
|
If it`s not, then one more question: does the map service return geometry, not just attributes? If yes, then you could just set out spatial reference for your queries. If it doesn`t return geometry and you can`t make it return geometry (using XY event layers, for example) then you need to use Geometry Service indeed. There are few samples in the API documentation. http://resources.arcgis.com/en/help/silverlight-api/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Tasks.GeometryService~ProjectAsync.html http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Project There was a nice class for auto reprojection, but it looks like it`s not available now. http://blogs2.esri.com/esri/arcgis/2011/02/13/auto-reprojecting-graphics-layers/ TDenis, Thanks for the links to those examples. I have recreated the example in the API samples successfully. As I have been stepping through the sample code I notice this line of code: MapPoint inputMapPoint = new MapPoint(x, y, new SpatialReference(4326)); Could I not just add my map points to the map specifying my spatial reference? Like this: feature.Geometry = new MapPoint(lat, lon, new SpatialReference(102697));
... View more
12-10-2013
04:25 AM
|
0
|
0
|
821
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|