So the issue is that the FacetWP wants the Longitude and Latitude to be in meta fields from this plugin. But that plugin doesn’t have map output, hence GeoMashup. But now we need to do double geocoding, which is dumb and inefficient. So instead, I let GeoMashup do my geocoding using Pods fields, since that worked best with the CSV import that was involved.
Then I used a post_save filter to copy the longitude and latitude to the fields that FacetWP would be looking in. It’s a little silly but it worked. Here’s the filter I used:
/**
* Copies goecoding from one plugin to another
*
* @uses pods_api_post_save_pod_item_retailers
*
* @param $pieces
* @param $is_new_item
* @param $id
*/
add_action( 'pods_api_post_save_pod_item_retailers', slug_double_geocode, 10, 3 );
function slug_double_geocode( $pieces, $is_new_item, $id ) {
//check if marty geocoder has our geocoding, if so move on with life
if ( ! isset( $meta['martygeocoderlatlng'] ) || empty( $meta['martygeocoderlatlng'] ) ) {
//get post meta
$meta = get_post_meta( $id );
//get geo_mashup object
$gm_obj = GeoMashupDB::get_object_location( 'post', $id );
//set the variables we are trying to build to false.
$latlng = $address = false;
//see if geomashup has it and if so get geocoding data from there
if ( is_object( $gm_obj ) && isset( $gm_obj->lat ) && isset( $gm_obj->lng ) ) {
$lat = $gm_obj->lat;
$lng = $gm_obj->lng;
//put it the way marty geocoder likes it
$latlng = '('.$lat.', '.$lng.')';
//check that we can get address from the Pods fields
if ( isset( $meta[ 'store_address' ] ) && isset( $meta[ 'store_state' ] ) ) {
$address = $meta['store_address'][0].', '.$meta['store_state'][0];
}
//update our post meta from what we already have, if we can
if ( $address && $latlng ) {
update_post_meta( $id, 'martygeocoderlatlng', $latlng );
update_post_meta( $id, 'martygeocoderaddress', $address );
}
}
}
}
As I said, that’s kind of silly, what I should have done is add a filter for location source to the Proximity Facet.