1. Hugh (cheesegrits) here. Thank you for all the good wishes. My back surgery was a success, post-op recovery is going well, and I'm getting stronger and feeling better every day. I hope to be getting back in the saddle and working support again over the next few days.
  2. IMPORTANT NOTE - we have made some changes in our github branch naming. The 'master' branch no longer exists, and is now called 'joomla25' (which is Fabrik 3.0). The 'joomla3' branch (which is Fabrik 3.2) remains unchanged. We have also removed all the other testing branches which had accuulated over the last few years. I have posted a thread in the Community forum for 3.0 with some more information, feel free to as questions there.

Calculating distance and writing to table

Discussion in 'Standard Support' started by pfleischman, Aug 8, 2011.

Thread Status:
Not open for further replies.
  1. pfleischman New Member

    Level: Community
    I found some great writeups on how to do this, but I'd like to work more seamlessly into a Fabrik form. I would assume it would have to be javascript that would run upon submission, pulling the variables and then writing the data to a field? Or would you recommend a different method?

    This seems like such an easy option to add to Google Maps Element if you're looking to beef that up.

    Example Javascript using two manually entered address into two form fields:
    Code (text):
    var geocoder, location1, location2;   function initialize() {   geocoder = new GClientGeocoder(); }   function showLocation() {     geocoder.getLocations(document.forms[0].address1.value, function (response) {       if (!response || response.Status.code != 200)       {           alert("Sorry, we were unable to geocode the first address");        }       else        {           location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};             geocoder.getLocations(document.forms[0].address2.value, function (response) {               if (!response || response.Status.code != 200)               {                   alert("Sorry, we were unable to geocode the second address");               }               else                {                   location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};                     calculateDistance();                }           });         }   }); }   function calculateDistance() {  try     {       var glatlng1 = new GLatLng(location1.lat, location1.lon);       var glatlng2 = new GLatLng(location2.lat, location2.lon);       var miledistance = glatlng1.distanceFrom(glatlng2, 3959).toFixed(1);        var kmdistance = (miledistance * 1.609344).toFixed(1);          document.getElementById('results').innerHTML = '<strong>Address 1: </strong>' + location1.address + '<br /><strong>Address 2: </strong>' + location2.address + '<br /><strong>Distance: </strong>' + miledistance + ' miles (or ' + kmdistance + ' kilometers)';    }   catch (error)   {       alert(error);   } }
  2. pfleischman New Member

    Level: Community
    Completely disregard what I just posted. I did more searching and realized you wrote the Radius Search Plugin.

    Just in case someone else is looking for this info:

    Radius Search Plugin
    http://fabrikar.com/wiki/index.php/Radius_search_table_plugin
    Version 2.1
    http://fabrikar.com/downloads/details/36/142
Thread Status:
Not open for further replies.

Share This Page