Sitecore provides Geolocation-based services out of the box, which can help marketers create a personalized experience. It can also help empower consumers in finding trending products in their region or the nearest service stations.
In this recipe, we will take an example of an electronics product company, which wants to provide the nearest service station details to its visitor.
For this recipe, you should have configured the Sitecore Geolocation service, which you can do in a few steps shown at https://goo.gl/c9OQWj. Also, create some service providers' items with Title
, Address
, City
, Latitude
, and Longitude
fields.
We will first find the latitude and longitude of the visitor and search for nearby restaurants:
In the
SitecoreCookbook
project, create aPlacesHelper
class and aGetNearbyPlaces()
action method in theHelper
subfolder in theAnalytics
folder as follows:public static List<Item> GetNearbyPlaces...