fbpx

Searching by Location Name

Searching by Location Name

Searching by location name

Over the last two weeks I have discussed location based search and map based search. I covered searching for a location given a longitude and latitude. I also covered finding a longitude and latitude from a point on a map. In this article, I take a look at searching by location name to retrieve a longitude and latitude.

It is all very well and good being able to click on a map to find a location, but sometimes a website visitor wants to enter the name of a place to search near.

The Process of Searching by Location Name

The process for searching by location name is relatively simple. All places that are searchable need to be stored in a table. I found it useful have a field to store the primary location name, and a field to store alternative spellings. Some villages have two spellings for their name, the local spelling and the official spelling. Some towns have hyphens in their names but a visitor to the website might not type the hyphens in. Conversely, a visitor might put hyphens in a long name when they are not technically part of the name. Finally, there can simply be a case of common misspellings.

When a visitor enters the name of a place they wish to search for, I perform a “Like” search on the two fields in the database. If there is only one match, then I take that as the place they were looking for, if there are multiple matches I list all matches and allow them to select the one they want.

Each place stored in the table also has a longitude and latitude stored with it. I use that longitude and latitude to perform a location based search.

Data Volume

The time consuming part, for me, was entering the searchable places and their longitude and latitudes. Thankfully I was only mapping an area the size of a county. It took time to create my list of places but it wasn’t an insurmountable task. For larger areas this is not practical and there are really only two options:

  • Limit the searchable places: in essence only include locations large enough to be of note, thus reducing the size of the data set.
  • Utilise a third-party data-set: this could either be an external API (supplied by an organisation such as Google), or a purchased database (supplied by an organisation such as the Post Office).

SAMWare UK creates bespoke solutions and websites. Contact us to arrange a chat to discuss your needs and for a free no obligation quote.

One thought on “Searching by Location Name

Leave a Reply

Your email address will not be published. Required fields are marked *