find nearby locations mobile example using my data

577
1
Jump to solution
10-17-2012 12:16 PM
TracySchloss
Frequent Contributor
I am trying to create a version of "Find Nearby Locations" originally written to search using Yahoo.  I need to use my own service instead.    I think I have my proxy set up correctly because I can review the console when I'm debugging and in Firebug I can see that I have a POST with a status of OK. 

I have query function that takes the current geoLocation, runs it through a geometryService to buffer the point and run a featureLayer.selectFeatures.  The featureLayer isn't selecting anything.  I"m getting an error "illegal XML character" and I don't know if that's from the proxy or the buffer, which is supposed to be defining my input geometry to the selectFeatures.  My map spatial reference and the spatial reference of the features I'm trying to select are not the same.

Right now my callback function doesn't do anything, I'm still trying to determine if anything is selected before I go any farther.
function queryFeatures(queryVal, distance){             console.log("in queryFeatures");             createProgress('searchResults');             //var dist = dijit.byId("distVal").srcNodeRef.children[0].children[1].textContent.split(" ");             var params = new esri.tasks.BufferParameters();             params.geometries = [ currentGraphic.geometry ];             //buffer in linear units such as meters, km, miles etc.             if(distance){                 params.distances = distance;             } else{                 params.distances = [ currentBufferDist ];             }             params.unit = esri.tasks.GeometryService.UNIT_STATUTE_MILE;             params.outSpatialReference = map.spatialReference;             geomService.buffer(params, function(geometries){                 query.geometry = geometries[0]; query.outSpatialReference = map.spatialReference;                 switch(queryVal){                      case 'offSat':                     query.where = "1=1";                     featureLayer = offSatFeatureLayer;                     break;                     case 'vendor':                     query.where = "1=1";                     featureLayer = venFeatureLayer;                     break;                 }                 featureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW, function(features){                     console.log("inselectFeatures function I just added");                 }                 ,function(error){                    alert(error.message);                      });                                          }, function(error){                 alert(error.message);             });                      }
0 Kudos
1 Solution

Accepted Solutions
TracySchloss
Frequent Contributor
To answer my own question!:

I was mixing up a query based on geometry with a query based on a logical expression and had a bit of both in my code.  In my code I needed to take out the query.where lines
  switch(queryVal){                      case 'offSat':                     featureLayer = offSatFeatureLayer;                                   break;                     case 'vendor':                     featureLayer = venFeatureLayer;                                       break;                 }


Then I changed my geometry service buffer to use the extent of the returned geometry (the buffer) instead of the buffer polygon. When examinig the geometries object that was returned, it said it was "rings" and not "polygon".   Maybe these are the same thing, but I did notice the acceptable geometry for query was Point, Polygon, Line, Multipoint and Extent.  Rings was listed, but maybe I could have created a polygon from the rings?

Since I'm just trying to locate the nearest features to a piont and I didn't need absolute accuracy, using the extents was enough. 
  var bufferGeometry = geometries[0];                 var geometryExtent = bufferGeometry.getExtent();                  query.geometry = geometryExtent;

View solution in original post

0 Kudos
1 Reply
TracySchloss
Frequent Contributor
To answer my own question!:

I was mixing up a query based on geometry with a query based on a logical expression and had a bit of both in my code.  In my code I needed to take out the query.where lines
  switch(queryVal){                      case 'offSat':                     featureLayer = offSatFeatureLayer;                                   break;                     case 'vendor':                     featureLayer = venFeatureLayer;                                       break;                 }


Then I changed my geometry service buffer to use the extent of the returned geometry (the buffer) instead of the buffer polygon. When examinig the geometries object that was returned, it said it was "rings" and not "polygon".   Maybe these are the same thing, but I did notice the acceptable geometry for query was Point, Polygon, Line, Multipoint and Extent.  Rings was listed, but maybe I could have created a polygon from the rings?

Since I'm just trying to locate the nearest features to a piont and I didn't need absolute accuracy, using the extents was enough. 
  var bufferGeometry = geometries[0];                 var geometryExtent = bufferGeometry.getExtent();                  query.geometry = geometryExtent;
0 Kudos