POST
|
I'm in this club now too. I'm also looking into making my own templates since these are so limited.
... View more
10-03-2014
01:22 PM
|
0
|
0
|
756
|
POST
|
Did you ever figure out anything on this. Its an interesting question. I have some similar code but my result is currently only giving me one deferred or the other for some reason. It is as if result can only be used once.
... View more
09-16-2014
09:48 AM
|
0
|
0
|
245
|
POST
|
Well I'm happy to say that I got this to work the way I wanted to. I gave Robert credit for the correct answer since he was diligent in helping me out, though Melita got me on the right track. Thanks to Robert and Melita's guidance, I confirmed that the coordinates I was getting were Web Mercator already so I did not need to attempt to project them. I assumed my map was in Web Mercator and that the streets basemap was in Web Mercator but it did occur to me that when I created the map variable, I was setting the center to [-79.2, 39.5] which I know are geographic coordinates wkid:4326. I'm not sure how or why the map is using 4326. I also learned from reading about this that I don't need the entire extent (this is apparently an old way of doing this), I just needed the center and zoom level which are available through the getCenter and getLevel functions. I'm using v3.10 of the arcgis javascript API btw. I used webMercatorUtils to convert my center coordinates to lat/longs, and got the zoom level, and successfully got the map to load the php file with the extent from the original map html file. (function(){require(["esri/geometry/webMercatorUtils"],function(w){var c=w.webMercatorToGeographic(map.extent.getCenter());console.log([parseFloat(c.x.toFixed(3)), parseFloat(c.y.toFixed(3))]);});})(); I found this link where I got the above code snippet to be very helpful ... BearPanther.com | Esri JavaScript map center, zoom level and extent My testing code (in the html file) looked like this var center=webMercatorUtils.webMercatorToGeographic(map.extent.getCenter()); passedX = parseFloat(center.x.toFixed(5)); passedY = parseFloat(center.y.toFixed(5)); zoomLevel = map.getLevel(); console.log(passedX + ", " + passedY); console.log("Zoom: " + zoomLevel);
... View more
08-26-2014
08:13 AM
|
0
|
0
|
4211
|
POST
|
Thanks for your response - Yes I'm using MD State Plane. Here is a link to the service I'm trying to use. P_and_Z/Parcels_and_Zoning (MapServer) That is good information because I wasn't sure which to use or why it was on the list twice (now I know). It is probably best to use 2248 then if it is more up to date. It is possible (maybe probable now that I look at the extents of my service) that these coordinates are Web Mercator and not wkid: 2248 so perhaps I shouldn't be trying to project these anyway but I didn't have any luck earlier trying to set the map extent e.g. but maybe I should go back and work from this instead. map = new Map("map", { basemap: "streets", center: [avgX, avgY], // center: [-79.23, 39.51], extent: passedExtent, zoom: 12 }); the xMin, xMax, yMin, and yMax I get in console.log look like this -8819410.666559163 4792613.494165327 -8813596.67509507 4794481.424044095 pmeasure.js:50 -8816503.670827117 4793547.459104711 (avgX and avgY) which is not in the range I would expect.
... View more
08-25-2014
01:21 PM
|
0
|
1
|
4211
|
POST
|
Ok - Thanks for your help - if I send it this ... spatRef = new esri.SpatialReference({wkid:2248}); var passedExtent = new esri.geometry.Extent({"xmin": Number(xMin), "ymin": Number(yMin), "xmax": Number(xMax), "ymax": Number(yMax), "spatialReference":spatRef});` and then do this ... var projectParams = new ProjectParameters(); projectParams.geometries = [passedExtent]; projectParams.outSR = map.spatialReference; Now I'm getting this error instead ... Uncaught TypeError: Cannot read property 'wkid' of undefined which is actually where I was earlier ... and I still get this ... Map: Geometry (wkid: 102685) cannot be converted to spatial reference of the map (wkid: 102100) I noted too that the brackets don't matter, I get the exact same result either way with projectParams.geometries = [passedExtent]; or projectParams.geometries = passedExtent; Am I formatting the "Extent" incorrectly ? It seems to me I'm formatting it just like in this guide Setting and using extents in a map | Guide | ArcGIS API for JavaScript
... View more
08-25-2014
12:41 PM
|
0
|
1
|
4211
|
POST
|
The line that gives the error is this line. var defer = esri.config.defaults.geometryService.project(projectParams); I did add a line projectParams.spatialReference = new esri.SpatialReference({wkid:2248}); but if I comment that out I still get that error in red. In fact that is why I added it (in a weak attempt to fix the error). Uncaught TypeError: Cannot read property 'spatialReference' of undefined
... View more
08-25-2014
12:02 PM
|
0
|
3
|
4211
|
POST
|
Please help me if you can, I'm getting the following message in the console ... Map: Geometry (wkid: 102685) cannot be converted to spatial reference of the map (wkid: 102100) Similar to this thread https://community.esri.com/thread/66936 I also found this one which appears related Map options: issues with non-mercator spatial reference I tried using the suggestion by Adam Skoog in that first thread (66936) but when I get to what shows up as line # 07. In his code, I get an error as follows: Uncaught TypeError: Cannot read property 'spatialReference' of undefined Which seems odd since all of this is inside a require block that includes Map, ProjectParameters, SpatialReference, Extent, Geometry, GeometryService etc. etc. My code looks like this esriConfig.defaults.io.proxyUrl = "/proxy"; esriConfig.defaults.io.alwaysUseProxy = false; esriConfig.defaults.geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); // I have xMin, xMax, yMin, yMax sent in to this php file and it seems I need the Number() fx to get real numbers // This prints the following to the console ... // -8819410.666559163 4792613.494165327 -8813596.67509507 4794481.424044095 pmeasure.js:50 // -8816503.670827117 4793547.459104711 pmeasure.js:51 // AND IF THE BLOCK STARTING WITH "var defer = " IS UNCOMMENTED, I GET THIS // Uncaught TypeError: Cannot read property 'spatialReference' of undefined var avgX = ((Number(xMin) + Number(xMax)) / 2); var avgY = ((Number(yMin) + Number(yMax)) / 2); console.log(xMin, yMin, xMax, yMax); console.log(avgX, avgY); var passedExtent = new esri.geometry.Extent(Number(xMin), Number(yMin), Number(xMax), Number(yMax), new esri.SpatialReference({wkid:102685}) ); var projectParams = new esri.tasks.ProjectParameters(); projectParams.geometries = passedExtent; projectParams.outSR = new esri.SpatialReference({wkid:102100}); // map.spatialReference; ummmmm map not defined yet projectParams.spatialReference = new esri.SpatialReference({wkid:2248}); // map.spatialReference; // var defer = esri.config.defaults.geometryService.project(projectParams); // dojo.when(defer, function (projectedGeometry) { // if (projectedGeometry.length > 0) { // map.setExtent(projectedGeometry[0]); // } // }); map = new Map("map", { basemap: "streets", center: [avgX, avgY], // center: [-79.23, 39.51], extent: passedExtent, zoom: 12 });
... View more
08-25-2014
10:57 AM
|
0
|
9
|
10554
|
POST
|
I had tried that too which helped. I finally got this one fixed by taking bits of code out until the error disappeared. I had a couple of problems like functions that should have been inside the require section were outside the block. Thanks for your help.
... View more
07-17-2014
10:00 AM
|
0
|
0
|
995
|
POST
|
Thanks. I was missing that in the require. I noticed at the same time that I was also missing "dojo/data/ItemFileReadStore", so I've added that in. Now my map does load but for whatever reason I'm still getting an error in the javascript console that says "Uncaught TypeError: Cannot read property 'on' of undefined ". The map now doesn't load when I uncomment the line that says ... registry.byId("search").on("click", doFind); So I'm not out of the woods entirely. That was helpful though. I may need to go in and take things out to see if I can get the search functionality to start working. Thanks!
... View more
07-14-2014
12:16 PM
|
0
|
2
|
995
|
POST
|
I am attempting to merge this sample into an existing script where I am using the identify tool and making selections etc. Show find task results in a DataGrid | ArcGIS API for JavaScript https://developers.arcgis.com/javascript/jssamples/find_map_datagrid.html The sample has a search for parcel functionality that is just what I want though I'm adapting it to search for roads in a street centerlines layer. Chrome's javascript console tells me this which is one clue Cannot read property 'on' of undefined Where I'm getting this is on this line here registry.byId("search").on("click", doFind); Which is exactly how it is used in the sample. Here is how the "require" part starts out ... I also have a button control with the id "search" just as in the sample I linked to above (see html code posted below the require code). Can anyone see where I could be going wrong ? when the line of code above registry.byId ... is NOT commented out, the html bit below goes away. When I comment it out, I see the search control and the table. I also tried other methods to "connect" the click event to the search button but they don't work either. I have all the other code from the sample in there (such as the doFind function) which should run when the button is clicked. Any ideas why this is not working ? <code> <script src="http://js.arcgis.com/3.9/"></script> <script> var findTask, findParams; // * var map, center, zoom; // * center and zoom are new var grid, store; // * var identifyTask, identifyParams; require([ "esri/map", "esri/dijit/BasemapGallery", "esri/dijit/Popup", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/tasks/query", "esri/toolbars/draw", "esri/tasks/IdentifyTask", "esri/tasks/FindTask", "esri/tasks/FindParameters", "esri/layers/FeatureLayer", "esri/tasks/IdentifyResult", "esri/tasks/IdentifyParameters", "esri/dijit/InfoWindow", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "esri/InfoTemplate", "dojo/_base/array", "dojo/_base/Color", "dojo/dom", "dojo/on", "dijit/registry", "dojo/parser", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/TitlePane", "dijit/form/Button", "dijit/form/RadioButton", // "dojo/parser", "dojo/domReady!" ], function(Map, BasemapGallery, Popup, ArcGISDynamicMapServiceLayer, Query, Draw, IdentifyTask, FindTask, FindParameters, FeatureLayer, IdentifyResult, IdentifyParameters, InfoWindow, SimpleFillSymbol, SimpleLineSymbol, InfoTemplate, arrayUtil, Color, dom, on, registry, parser, BorderContainer, ContentPane, TitlePane, Button, RadioButton) { //setup the popup window parser.parse(); // * registry.byId("search").on("click", doFind); // on(dom.byId("search"), "click", doFind); // mapOnLoad = dojo.connect("search", "click", doFind); </code> <code> <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'" style="height:190px;"> <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'" style="height:30px; margin-top: 0;"> Road name: <input type="text" id="ownerName" size="60" value="ROCK LODGE RD" /> <button id="search" data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="button" >Search </button> </div> <table data-dojo-type="dojox/grid/DataGrid" data-dojo-id="grid" id="grid" data-dojo-props="rowsPerPage:'15', rowSelector:'20px'"> <thead> <tr> <!--<th field="PARCELID">Parcel ID</th>--> <th field="STREET_ALL">NAME</th> <!--<th field="OWNERNME1" >Owner 1</th>--> <th width="120px" field="MAINTENANCE">MAINTENANCE</th> <!--<th field="OWNERNME2">Owner 2</th>--> <th field="FROM_LEFT_P" >FROM LEFT</th> <th field="TO_LEFT_P">TO LEFT</th> <th width="130px" field="FROM_RIGHT_P">FROM RIGHT</th> <th field="TO_RIGHT_P">TO RIGHT</th> <!--<th field="RESYRBLT ">Year Built</th>--? <!--<th field="SITEADDRESS" width="100%">Address</th>--> </tr> </thead> </table> </div> </code>
... View more
07-11-2014
08:59 AM
|
0
|
6
|
6731
|
POST
|
Thanks Ken, I got it. I had to move the HomeButton directly after Map in order for it to work. I also found the blog post informative. That is the type of reading I am looking for to help me to make sense of this.
... View more
05-15-2014
06:45 AM
|
0
|
0
|
399
|
POST
|
Hi, I'm just getting started with using the ArcGIS API for Javascript. I have been trying samples using the sandbox site. I've had some general trouble trying to combine the functionality of one sample with another. So what I'm looking for is some guidance in how to effectively combine these scripts. For example, I brought up the measurement sample and I wanted to add a home button. So I added references to "esri/dijit/HomeButton" to the list in the "Require" function and added "HomeButton" to the function defined as the second argument in "Require" and then added code var home = new HomeButton({
map: map
}, "HomeButton");
home.startup();
at the end (before the final "});" near the end of the </script> tag. It seems to make everything stop working if everything isn't in the right order and even putting it at the end means that it works up until that code snippet that I included runs (I can check by adding an "alert" popup and I see that it stops working). Questions: 1. Should this work (if so, what am I doing wrong)? 2. Am I correct in assuming that listing these items (objects ?) in the wrong order will upset the script or should I be able to put that "HomeButton" anywhere in that list of arguments? function(dom, Color, keys, parser, esriConfig, has, Map, SnappingManager, Measurement, FeatureLayer, SimpleRenderer, GeometryService, SimpleLineSymbol, SimpleFillSymbol, HomeButton){<lots of code>}
... View more
05-15-2014
05:21 AM
|
0
|
3
|
737
|
POST
|
I'm having the same problem (same error anyway) as these other folks. I tried the above suggestion to add os.environ['ESRI_SOFTWARE_CLASS'] = 'Professional' in the interactive window in PythonWin and it accepts that command but when I then try to enter arcpy.AggregatePolygons_arc("input", "output", 30, 50000) I got ERROR 000824: The tool is not licensed. Failed to execute (AggregatePolygons). We do have the ArcInfo License installed. I'm using version 10.0 with no service packs (waiting for 10.1 I suppose).
... View more
09-17-2012
08:30 AM
|
0
|
0
|
1538
|
POST
|
Hi, I'm converting some of my pre-existing python scripts (that worked in version 9.3.1) to work with version 10 (and python 2.6). I have a script that has 3 arguments and a function. It works fine in 9.3.1 but in 10.0 (python 2.6) it is giving me an error when I simply try to import the script ... >>> from ExportIndividualFeatures2_v10 import ExpIndFeatures Traceback (most recent call last): File "<interactive input>", line 1, in <module> File "ExportIndividualFeatures2_v10.py", line 23, in <module> inWorkspace = sys.argv[1] IndexError: list index out of range Again, this error occurs when trying to simply import the script at the command line in PythonWin (see the command issued after the ">>>" above) The relevant parts of the script I am importing are these lines at the beginning ... import sys, string, os, arcpy inWorkspace = sys.argv[1] inShapeFile = sys.argv[2] inField = sys.argv[3] def ExpIndFeatures(inWorkspace, inShapeFile, inField): try: etc. etc. (code in here) Why does this work with 9.3.1 (python 2.52 pywin 32 build 210) and not with 10.0 (python 2.6 pywin 32 build 212) ???
... View more
08-29-2012
05:51 AM
|
0
|
1
|
6101
|
POST
|
I miss this function as well. While going through and updating old Python scripts I wrote for 9.3.1, I wondered what happened to this (which landed me here). I suppose I will have to use the Mosaic mentioned above instead. Bummer. I also miss having functionality right in the Spatial Analyst toolbar when working within ArcMap. Now I have to go into the toolbox just to use the raster calculator.
... View more
08-22-2012
05:30 AM
|
0
|
0
|
1005
|
Title | Kudos | Posted |
---|---|---|
1 | 01-10-2019 07:03 AM | |
1 | 06-30-2017 07:10 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|