Ok - as you marked this ticket resolved once, the system automatically removes the access details you share with private reply. Can you please share access details and I would be happy to dive into your site again and find out why its not working as expected.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
This code has been working great, but there is one unpleasant limitation. If there are multiple views on a page, the map center gets applied to all of them, causing the other views to return no items found (since they are not map related).
With snippet enabled - hidden link (notice the missing quote, and the missing 'mentioned in' section)
With snipped disabled - hidden link (notice the broken nearby places - shows them all)
Here's a final version of the code that limits the code to geo-based views only. The solution turned out to be properly detecting the geo-based views with the following line:
!empty($view_settings['map_distance_filter'])
...and injecting the mapcenter only into the views that passed.
add_filter( 'wpv_view_settings', 'func_filter_distance_center_address', 10, 2 );
function func_filter_distance_center_address( $view_settings, $view_id ) {
global $post;
//Only post_type 'place' has a place-address that can be injected - skip others
//Only geo-filtered views (have a non-empty map_distance_filter) need a map center - skip others
if ( $post->post_type == 'place' && !empty($view_settings['map_distance_filter']) ) {
$latlong=types_render_field("place-address",array('format'=>"FIELD_LATITUDE,FIELD_LONGITUDE",'item'=>$post->ID));
if(!empty($latlong)) {
$latlon = explode(",",$latlong);
$view_settings['map_distance_filter']['map_center_lat'] = $latlon[0];
$view_settings['map_distance_filter']['map_center_lng'] = $latlon[1];
}
}
return $view_settings;
}