Jump to content

Geo Directories


draco66

Recommended Posts

Looking for suggestions on how to create Geo Directories with Fusion Pro. These are listings of health care providers within a set radius of the recipients address.

 

Any suggestions would be helpful.

 

Software to create tagged data that can then be run through Fusion Pro?

 

Thank you.

Link to comment
Share on other sites

Google has several well-documented API's that you'd probably find useful for this. Specifically: Places and possibly Maps Geocoding. Note that there are usage limitations tied to the latter.

 

In any event, I've done something similar in the past and had the most success with processing an existing data list of addresses and updating it with the results of the API queries prior to going to FusionPro. So essentially, the script loads a data file, walks through each record calling the script below for each address, and tacks on an additional field for "nearby health care providers" that you could then parse and format within your template. While the script that I wrote is in PHP, you could easily modify it for JavaScript if you'd like:

 

<?php

function google_API($url, $params){
 $api = '##################################'; // Google API KEY
 $output = "json"; // json or xml
 $params = array_filter($params);
 $params['key'] = $api;
 $params = implode('&', array_map(function ($v, $k) { return $k . '=' . $v; }, $params, array_keys($params)));
 $jsondata = json_decode(file_get_contents($url . '/' . $output .'?'.$params));

 if ($jsondata->status === "OK"){
   return $jsondata;
 }
 return '';
}

function get_long_lat($address) {
 $url = "https://maps.googleapis.com/maps/api/geocode";
 $parameters = array (
     "address" => urlencode($address),
     "region" => "us"
   );
 $coordinates = google_API($url, $parameters);
 $lat = $coordinates->results[0]->geometry->location->lat;
 $lng = $coordinates->results[0]->geometry->location->lng;
 $result = implode(',', array_filter(array ($lat,$lng)));
 return $result;
}   

function get_nearby($address){
 $url = 'https://maps.googleapis.com/maps/api/place/nearbysearch';
 $parameters = array (
     "location" => get_long_lat($address),
     "radius" => 500,
     "types" => "health|hospital" 
   );  
 $result = google_API($url, $parameters);
 if (empty($result)) {
   return '';
 }
 $locations = array();
 foreach ($result->results as $i) {
   $name = $i->name;
   if (!empty($name)){
     array_push($locations, $name);
   }
 }
 $locations = implode('|', $locations);
 return $locations;
}

print get_nearby('1600 Pennsylvania Avenue, Washington DC');
?>

 

The script above returns a list of places of type "health" or "hospital" within a 500 meter radius of the White House which I've delimited with a pipe so the appended field would have a value of:

return Field("nearest health care provider"); // "Harris Teeter|Safeway|Safeway Pharmacy (inside Safeway)|Malone Thomas O DDS|Capitol Hill Dental Associates|Shelton R. Penn, DDS, PC|Comprehensive Psychiatric Emergency Program|Malone Bennye L DDS|Bmarchai Studios|Baker Moorean a DDS|Chardonnay Dialysis Inc|2fitt Wellness|Freed Bodyworks Holistic Wellness Center|Harris Teeter Pharmacy|Think Pilates!|Yorke Leigh V|Khojandi Mohammad MD|Erin Lee, PharmD|Dr. Carlos H. Powers Jr, DDS|William Community Residential"

 

And you could make a list of them like this:

return Field("nearest health care provider").split('|').join('\n<br>');
/*
Harris Teeter
Safeway
Safeway Pharmacy (inside Safeway)
Malone Thomas O DDS
Capitol Hill Dental Associates
Shelton R. Penn, DDS, PC
Comprehensive Psychiatric Emergency Program
Malone Bennye L DDS
Bmarchai Studios
Baker Moorean a DDS
Chardonnay Dialysis Inc
2fitt Wellness
Freed Bodyworks Holistic Wellness Center
Harris Teeter Pharmacy
Think Pilates!
Yorke Leigh V
Khojandi Mohammad MD
Erin Lee, PharmD
Dr. Carlos H. Powers Jr, DDS
William Community Residential
*/

Link to comment
Share on other sites

We have BCC, which can use a function called "nearestLocation" comparing recipient's address to a listing of address (healthcare in your case), and can return x number (you specify) of nearest locations in distance. I'm not familiar with Satori, but I assume they might have a similar tool/process to achieve it.

 

I'm sorry I couldn't be of an assistance on this.

 

Thanks.

Link to comment
Share on other sites

Bulk Mailer Pro by Satori.

 

There is a Geocode add-on for Bulk Mailer Pro and Business that will Append latitude and longitude information during the address correction process.

 

Using this information, we've calculated the distance between two locations as mentioned in this post.

 

Of course, the distance is "as the crow flies", not actual driving distance.

Edited by David Miller
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...