Searching locations based on coordinates.

tahnalos
Kilo Sage

My client uses the Locations table in order to provide a mapping of all servicable assets for our technicians.  However, a new request has come in to be able to search for these locations based on the input of coordinates.  They are asking to narrow down to locations nearest to inputted coordinates with maximum distance of 500 meters.

Is there a script that can help calculate distance and convert that to meters?

1 ACCEPTED SOLUTION

Check if this is helpful

https://stackoverflow.com/questions/5260423/torad-javascript-function-throwing-error


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

10 REPLIES 10

Jai21
Mega Expert

Hi 

Try Geolocation>Administration>geolocation properties. 

you can set the maximum distance to 500 (it is defaulted in meters) 

 

tahnalos
Kilo Sage

This doesn't quite answer my question for two reasons:

1) we use two different standards for this, as while we want to be able to search for locations within 500 meters, we already have code that auto assigns based on distance of 200 meters.

2) we are looking to filter a list of locations so that said list is limited to those within 500 meters.  So the obvious approach would be to modify the reference but don't know how to filter the list based on coordinates.

Please advise.

SanjivMeher
Kilo Patron
Kilo Patron

You may activate the Geolocation plugin, which can help achieve this.

https://docs.servicenow.com/bundle/kingston-servicenow-platform/page/administer/geolocation/concept/c_Geolocation.html?cshalt=yes

 

You can then refer the client script on task table to build your code.

find_real_file.png


Please mark this response as correct or helpful if it assisted you with your question.

We already have the geolocation plugin turned on.  Which is why we are using location tracking.

However as I said earlier, there is no logic to filter a location reference based on coordinates and output the logic into a list.   I want to be able to input a longitude and latitude, then select a location (that also has longitude and latitude) based on those sets of coordinates.  I therefore need a script include plugged into the reference definition but unsure how to convert the coordinates and determine if the location in question is within a 500 meter radius.