Select to view content in your preferred language

World Geocoder Locator result point offset? (search widget)

3759
6
07-02-2015 08:30 AM
DerekLoi
New Contributor III

Hello,

Is there a way to have the returned result point be offset to be either on the right or left side of the street?

I would use a custom locator from our ArcGIS Server's locator but its not as up to date as the world geocoder provided as default in the search widget.

Here's the snippet of code i'm using:

search = new esri.dijit.Search({
  enableButtonMode: false,
  enableLabel: false,
  enableInfoWindow: false,
  autoComplete: true,
  map: map,
  sources: 
  [
   {
     locator: new Locator("//geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"),
     singleLineFieldName: "SingleLine",
     outFields: ["Addr_type"],
     name: "world_geocoder",
     localSearchOptions: {
          minScale: 300000,
          distance: 50000
     },
     placeholder: "Search Place or Address",
     highlightSymbol: new esri.symbol.PictureMarkerSymbol("images/pins/red-pin.png", 17, 32).setOffset(18, 27)
   }
  ]
}, "searchAddress");
search.startup();

as you can see, the offset is set on the picturemarkersymbol and was taken from an example in the arcgis javascript api documentation.

however, its incorrect as the offset will always be at a fixed point... i need the correct offset set by the locator.

any insight would be appreciated.

0 Kudos
6 Replies
JoshHevenor
Occasional Contributor II

Your search dijit has a 'search-results' event that you can use to handle the marker yourself.  You might need to set autoNavigate to false.

AkshayHarshe
Esri Contributor

Hi Derek,

It is really difficult to offset the searched point to left or right of the street. And there is no out of the box functionality like that. However, as Josh suggested you are able to use onSearchResults event to modify the geometry of the located point.

You Turn the autoNavigate and tweak the resulting geometry something like following then set extent as needed.

s.on("search-results", function (evt){
           console.log("x Coordinate is : " + evt.results[0][0].feature.geometry.x + " Y Coordinate is : " + evt.results[0][0].feature.geometry.y);
             evt.results[0][0].feature.geometry.x = evt.results[0][0].feature.geometry.x + 10000;// Tweak the geomery here.
             evt.results[0][0].feature.geometry.y = evt.results[0][0].feature.geometry.y + 10000;
           console.log("NEW x Coordinate is : " + evt.results[0][0].feature.geometry.x + " NEW Y Coordinate is : " + evt.results[0][0].feature.geometry.y);
         });

Let me know if this helps.

Thanks,

Akshay Harshe

Esri Technical Support.

Thanks,
Akshay Harshe
DerekLoi
New Contributor III

Hi Akshay,

Thank you for your response.

I will test it out and will let you know the results.

Edit:

So you are saying that with AutoNavigate set to true (which I assume will zoom to the result) and that adding 10000 to both the x and y coordinates of the resulting geometry ... will help me determine which side of the street the result is truly on?  I'm asking is because I need to verify if an address falls within a said polygon whereas its boundaries are drawn right down the middle of a street segment.

Edit again... lol... i missed what you said in the beginning of your reply.

I will look to other options and if I find a solution, I will post it here.

Regards,

Derek

0 Kudos
DerekLoi
New Contributor III

ok I guess my only option is to pass the address & zip to google maps and get the returned json

then parse the json for the lat/lon ... create a Point from that and place on the map

0 Kudos
AkshayHarshe
Esri Contributor

Derek,

I am just giving an example.. adding 10000 is just too much deviation.  You will need to figure out how and where you want to move the point it can be just -10 or anything.

This is not really efficient which is why I said you will not be able to determine which is the other side of the road. The best option is to get the address on the other side of the road somehow .

Can you explain your workflow little bit? I can try to make a suggestion if I can!

Thanks,

Akshay

Thanks,
Akshay Harshe
0 Kudos
DerekLoi
New Contributor III

Akshay,

The reason why i'm using the World Geocoder for the search widget is because our streets dataset and locator is not as up to date as the one from ESRI, Google, etc.

And I am modifying our current app to geocode a candidate address and then do some geoprocessing to verify whether the address falls within a particular boundary.... thus the need for the correct offset of either the left or right side of the street ... since most boundary lines run thru a street segment.  I can use our in-house locator which has the offset option set in the locator settings as the source for the search widget.  But like I said, the streets dataset is a couple years old.

Thanks for your help,

Derek

0 Kudos