Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Calculating distance from Postcode in Custom Filter View modes: 
User avatar
Member
Member
paul.truman-sunmed.co - 10/31/2013 5:27:01 AM
   
Calculating distance from Postcode in Custom Filter
Hi Folks, I'm hoping someone's already done this and can help me out here .... I've created a dealer locator page where a user can enter their postcode. On this page is a custom filter that references a CustomTable Datasource for addresses that match that postcode and displays the results in a repeater (I'll mention here that the results shown are companies that cover this postcode area, regardless of distance).

What I would like to do however is show the distance of these results to the postcode entered. In the custom table, I have the dealer's latitude and longitude distances recorded - what I'm unsure of however is how to get the user's lat/long based on the postcode they've entered. Does anyone have any example code of how to approach this using a custom-filter?

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 12/9/2013 4:21:53 PM
   
RE:Calculating distance from Postcode in Custom Filter
Hi,

You've probably already figured something out, but anyway, you need some service to translate the users postcode to latitude and longitude and then use some math to calculate the distance. Of course you don't have to reinvent the wheel, just find suitable parts and put them together in your custom filter control. Except searching for solutions, a quick guide could be the "marked as answer" post here at stackoverflow.com.
Hope this will be helpful.

Regards,
Zdenek