-
-
Save wpflippercode/e70cca7623ee07843e6b7077b62121de to your computer and use it in GitHub Desktop.
Multiple Google Map Post markers on single page using ACF plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter("wpgmp_markers","add_markers",1,2); | |
function add_markers($markers,$map_id) | |
{ | |
global $post; | |
//echo '<pre>'.print_r($markers).'</pre>'; | |
$new_markers = array(); | |
$the_query_map = new WP_Query( array( 'posts_per_page' => -1 ) ); | |
if($the_query_map->have_posts()) : | |
while($the_query_map->have_posts()): $the_query_map->the_post(); | |
$get_google_map = get_post_meta(get_the_id(),'location','true'); | |
//print_r($get_google_map); | |
if(is_array($get_google_map)) | |
{ | |
$temp_marker = array(); | |
$temp_marker ['location']['lat'] = $get_google_map['lat']; | |
$temp_marker ['location']['lng'] = $get_google_map['lng']; | |
$temp_marker ['title'] = get_the_title(get_the_id()); | |
$temp_marker ['id'] = get_the_id(); | |
$temp_marker ['address'] = $get_google_map['address']; | |
$temp_marker ['source'] = 'manual'; | |
$temp_marker ['content'] = get_the_content(get_the_id()); | |
$temp_marker ['location']['icon'] ='http://localhost/googlemap/wp-content/plugins/wp-google-map-gold/assets/images/icons/pin_green.png'; | |
$temp_marker ['location']['city'] =''; | |
$temp_marker ['location']['state'] =''; | |
$temp_marker ['location'] ['country'] =''; | |
$temp_marker ['location']['onclick_action'] ='marker'; | |
$temp_marker ['location']['redirect_custom_link'] =''; | |
$temp_marker ['location']['open_new_tab'] ='yes'; | |
$temp_marker ['location']['postal_code'] =''; | |
$temp_marker ['location']['draggable'] =''; | |
$temp_marker ['location']['infowindow_default_open'] =''; | |
$temp_marker ['location']['animation'] ='BOUNCE'; | |
$temp_marker ['location']['infowindow_disable']='1'; | |
$temp_marker ['location']['zoom'] ='12'; | |
$temp_marker ['location']['state'] =''; | |
$temp_marker ['extra_fields']['name']=''; | |
$temp_marker ['extra_fields']['address']=''; | |
$temp_marker ['extra_fields']['website']=''; | |
$temp_marker ['extra_fields']['phone-no']=''; | |
$temp_marker ['categories']['id']=''; | |
$temp_marker ['categories']['name']=''; | |
$temp_marker ['categories']['type']='category'; | |
$temp_marker ['categories']['icon']='http://localhost/googlemap/wp-content/plugins/wp-google-map-gold/assets/images/icons/pin_green.png'; | |
$temp_marker['listing_hook']=''; | |
$new_markers [] = $temp_marker; | |
} | |
endwhile; endif; | |
//Merge two arrays into one array | |
$markers = array_merge($markers, $new_markers); | |
return $markers; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have used this hook and override the location icon.
It is working fine when on page load but when i filter location from tab filter (unchecked category and check again) at that time icon replace with there category icon.
I want that icon which is set by hook.
Is there any other hook for tab filter or any solution for this?