POST
|
A while back I wrote a function with a deferred object that has been working successfully for several months. This morning, it fails and I am not sure why. I am using the 3.11 ESRI Javascript Library: Here is the function call with the deferred object (it is in a helper class, so it can be called over mulitple pages): addTract: function () { var d = new Deferred(); var layer = new FeatureLayer(tractFeatureurl, { mode: FeatureLayer.MODE_ONDEMAND, outFields: ["*"] }); layer.setDefinitionExpression("tract_id = " + this.tractid); this.mapObj.map.addLayer(layer); this.tracts = layer; var q = new Query(); q.returnGeometry = true; q.outFields = ["*"]; var cb = layer.queryFeatures(q); cb.then(lang.hitch(this, function (results) { this.tractFeature = results.features[0]; console.debug(this.tractFeature); this.mapObj.zoomToFeatures(results.features); d.resolve(this.tractFeature); return d.promise; })); } It is being class on a page like this: var res = utils.addTract(); console.debug(res); if (res == undefined) { alert("undefined"); return; } res.then(function (tract) { // do more processing.... }); Up until this morning, it was working fine, but now the response back from the addTract function is undefined.
... View more
02-05-2015
07:19 AM
|
0
|
1
|
3757
|
POST
|
I have a requirement to implement HTML 5 history tracking in my javascript application. To Keep it simple I wanted to update the history state every time the user panned or zoomed on the map. The problem is that each popstate event that gets triggered and I would reset the extent to the previous extent it also triggered the original event adding another item in the history state. This is the code that sets the listener on the pan event... var eventHandlers = []; var currentState = {}; function setEventTriggers() { var e = map.on("pan-end", function (e) { var pt = e.extent.getCenter(); var state = { action: "pan", x: pt.x, y: pt.y }; if (currentState && (currentState.x == pt.x && pt.y == currentState.y)) { console.debug("this is history"); } else { window.history.pushState(state, null, "CreateTract.aspx?x=" + pt.x + "&y=" + pt.y); } }); eventHandlers.push(e); } this is the code that handles the pop state window.addEventListener("popstate", function (e) { event.stop(e); console.debug(e); prevStates = []; currentState = e.state; var url = document.location.href; //console.debug(url); var u = urlUtils.urlToObject(url); if (u.query) { if (u.query.x && u.query.y) { var pt = new Point(u.query.x, u.query.y, map.spatialReference); var state = { action: "pan", x: pt.x, y: pt.y }; prevStates.push(state); map.centerAt(pt); } } fsMap._processBasicRequest(); }); As you can see I set a Current state variable at the beginning of the pop state routine and then check to see whether the current state is the same as state which I would be putting into history... As this is rather kluggy, I was hoping someone else had a better idea. I also tried to disconnect the event triggers but that could get really complicated in my application which has alot of UI javascript classes that trigger there own events... Mark Andrews Durham, NC
... View more
01-28-2015
06:36 AM
|
0
|
3
|
4028
|
POST
|
My bad. It was actually firefox that was giving me the problem.
... View more
01-14-2014
08:30 AM
|
0
|
0
|
266
|
POST
|
I am having a problem printing a PDF Map in: ArcGIS Server 10.2 Windows Server 2012 (Virtual Server) Javascript API 3.8 (Although it fails even if you just pass the JSON to Rest Portal) When I try to print a template in PDF Format the text for the scalebar and scale text does not appear. It prints fine in PNG32. Anybody else having this problem. Please Advise. Mark Andrews
... View more
01-13-2014
10:05 AM
|
0
|
2
|
589
|
POST
|
The above code works using a point as input. I'll try to get the code to first query the parcels service and get the geometry or I may create a table using python at night with a x,y pair for the centroid and the pin number just to get around having large irregular polygons. Again, I'm not sure if this is something other people have problems with. I just wanted to not have to deal with referencing a version of ArcObjects libraries in the code. Mark
... View more
06-20-2013
12:40 PM
|
0
|
0
|
1282
|
POST
|
Private Function doBuffer() As String Dim y1 = 551215.00819465192 Dim y2 = 613015.459091723 Dim x1 = 584470.22833333921 Dim x2 = 770134.56166666746 Dim x As Double = ((x2 - x1) / 2) + x1 Dim y As Double = ((y2 - y1) / 2) + y1 Dim sb As New StringBuilder(100) sb.Append("{""geometryType"" : ""esriGeometryPoint"",""geometries"" : [ {""x"" :") sb.Append(x) sb.Append(", ""y"" :") sb.Append(y) sb.Append("}]}") 'Dim sb As New StringBuilder(100) 'sb.Append("{'geometryType' : 'esriGeometryPoint','geometries' : [ {'x' :") 'sb.Append(x) 'sb.Append(", 'y' :") 'sb.Append(y) 'sb.Append("}]}") Dim sb2 As String = String.Format("geometries=%7B%0D%0AgeometryType+%3A+esriGeometryPoint%2C%0D%0Ageometries+%3A+%5B%0D%0A+%7Bx+%3A+{0}%2C+y+%3A+{1}%7D%0D%0A%0D%0A%5D%0D%0A%7D", x, y) Dim buffer As String = "" Dim requestUri As String = "http://server2.co.orange.nc.us/ArcGIS/rest/services/Geometry/GeometryServer/buffer" Dim data As New StringBuilder(100) data.AppendFormat("?geometries={0}", sb.ToString()) 'data.AppendFormat("?geometries={0}", sb2) data.Append("&inSR=%7B+wkid%3A+2264+%7D&outSR=&bufferSR=&distances=2000&unit=9002&unionResults=false&f=json") Dim request As HttpWebRequest = WebRequest.Create(requestUri & data.ToString()) Dim response As HttpWebResponse = request.GetResponse Using response Dim reader As StreamReader = New StreamReader(response.GetResponseStream()) Dim responseString As String = reader.ReadToEnd() Dim jss As System.Web.Script.Serialization.JavaScriptSerializer = New JavaScriptSerializer Dim results As Dictionary(Of String, Object) = jss.DeserializeObject(responseString) If (results IsNot Nothing And results.ContainsKey("geometries")) Then 'IEnumerable<object> features = results["features"] as IEnumerable<object>; Dim geometries As IEnumerable(Of Object) = results("geometries") 'foreach (IDictionary<string, object> feature in features) Dim bufferObject As New StringBuilder() For Each g As Dictionary(Of String, Object) In geometries bufferObject.Append("{rings:[") Dim rings As IEnumerable(Of Object) = g("rings") For Each ring() As Object In rings bufferObject.Append("[") For Each pt As Object In ring bufferObject.Append("[") bufferObject.Append(pt(0) & "," & pt(1)) bufferObject.Append("],") Next bufferObject.Remove(bufferObject.Length - 1, 1) bufferObject.Append("],") Next bufferObject.Remove(bufferObject.Length - 1, 1) bufferObject.Append("], spatialReference : {wkid : 4326}}") buffer = bufferObject.ToString() Exit For Next End If End Using Return buffer End Function Private Sub ExecuteGISSearch() Dim searchresults As List(Of SearchResult) = New List(Of SearchResult) Dim pinList As New List(Of String) Dim requestUri As String = "http://gis2.maconnc.org/ArcGIS/rest/services/Advanced/MapServer/7/query?f=json" Dim data As New StringBuilder(100) 'data.AppendFormat("?f={0}", "json") data.Append("&returnGeometry=false") data.Append("&geometryType=esriGeometryPolygon") Dim sBuffer As String = Me.doBuffer() data.AppendFormat("&geometry={0}", sBuffer) data.AppendFormat("&outFields={0}", "PIN") Dim request As HttpWebRequest = WebRequest.Create(requestUri) request.Method = "POST" Dim postData As String = data.ToString() Dim encoding As New ASCIIEncoding() Dim byte1 As Byte() = encoding.GetBytes(postData) request.ContentType = "application/x-www-form-urlencoded" request.ContentLength = byte1.Length Dim newStream As Stream = request.GetRequestStream() newStream.Write(byte1, 0, byte1.Length) newStream.Close() Dim response As HttpWebResponse = request.GetResponse Using response Dim reader As StreamReader = New StreamReader(response.GetResponseStream()) Dim responseString As String = reader.ReadToEnd() Dim jss As System.Web.Script.Serialization.JavaScriptSerializer = New JavaScriptSerializer Dim results As Dictionary(Of String, Object) = jss.DeserializeObject(responseString) If (results IsNot Nothing And results.ContainsKey("features")) Then Dim features As IEnumerable(Of Object) = results("features") For Each f As Dictionary(Of String, Object) In features Dim attributes As IDictionary(Of String, Object) = f("attributes") Dim result As New SearchResult 'result.Owner_Name = attributes("OWNER_NAME").ToString() 'result.PIN = attributes("PIN").ToString() 'result.Property_Address = attributes("PROP_ADDR").ToString() 'searchresults.Add(result) pinList.Add(attributes("PIN").ToString()) Next End If End Using mPinList = pinList.ToArray() End Sub
... View more
06-20-2013
12:37 PM
|
0
|
0
|
1282
|
POST
|
I have a rather simple problem that I would like a simple solution to. I have a non-GIS website that I want to be able to use the query and buffer functions of ArcGIS Server to query data in the GIS database. The website is written in .Net and the version of ArcGIS Server is 10.1. In the previous version of the APP I used ArcObjects and the WebADF to do this query, but I would like to move away from that if I can. I have consumed the REST API using C# in another application but never the Buffer Operation and it seemed deserializing the JSON of a complex polygon is rather difficult. I must be missing something simple and wanted some direction. Here is the steps: 1. User makes some advanced query requests, Give me all the property with X,Y,Z within a mile or two of a certain piece of property. 2. If there is no spatial component, I would just query the SQL database using C#. There are multiple tables not registered with the Geodatabase that need to be queried. 3. With the spatial component, I want to get a list of properties that meet the spatial query criteria and then see which one of those meet the criteria for the non-spatial data queries (or vice versa whichever is simpler) Which technology should I use to achieve this function in C#. Mark
... View more
06-19-2013
05:00 AM
|
0
|
3
|
9491
|
POST
|
Does anyone know how to get all the source files for the JavaScript API. I have a client that has some users that do not have internet access but would still like to use the website. I would like to host the JavaScript files on our internal server. Thanks
... View more
04-30-2010
07:57 AM
|
0
|
2
|
735
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|