Map instead of Flexislider on Detail page
This topic contains 14 replies, has 6 voices, and was last updated by Fearless_Shultz 9 years, 11 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
August 19, 2014 at 10:43 pm #12623
Hi, I’m not really using the photos feature often, and think it would be much more useful for my test site to display the map instead of the flexislider on the details page. I’ve scoured the forum and gone through the code but can’t seem to find an easy way to do this? Perhaps some of the wizards here can help?
August 20, 2014 at 11:13 am #12651I’ll alert the wizards for you 🙂
August 20, 2014 at 2:49 pm #12681So from my reading i think you wnat to remove the slider and place the map there instead?
#1 remove the slider, add this code to your child theme functions.php
remove_action( 'geodir_details_main_content', 'geodir_action_details_slider',30);
That’s the easy bit over, now on to the hard bit.
You need to move the map into that position so we add this code.
add_action( 'geodir_details_main_content', 'geodir_action_details_map_replace_slider',30); function geodir_action_details_map_replace_slider(){ global $post,$post_images,$video,$special_offers, $related_listing,$geodir_post_detail_fields; $map_args = array(); $map_args['map_canvas_name'] = 'detail_page_map_canvas2' ; $map_args['width'] = '600'; $map_args['height'] = '300'; if($post->post_mapzoom){$map_args['zoom'] = ''.$post->post_mapzoom.'';} $map_args['autozoom'] = false; $map_args['child_collapse'] = '0'; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; $map_args['enable_map_direction'] = true; geodir_draw_map($map_args); }
Some CSS may be required but that’s basically it.
Stiofan(the wizard)
November 15, 2014 at 1:00 pm #21611Hi There, I am trying to do something quite similar but rather than replace the slider, I am wanting to move the map to a different area as I don’t want to use the tabs. I have implemented the code code above with the slight modification of trying to remove map in tabs and wrapping the new map in a div.
The new map is showing in the position that I want it to, but with a grey overlay and a loading icon which never finishes. The map is still showing in the tabs area but in the same state.
Looking in Chrome developer tools, I get the following errors related to the map:
You have included the Google Maps API multiple times on this page. This may cause unexpected errors
Uncaught InvalidValueError: setMap: not an instance of Map; and not an instance of StreetViewPanorama
These would make sense as there are two versions of the map on the page, but I am not too sure how to target removing the one in tabs.
Below is the code I am using in functions.php
remove_action( 'geodir_details_main_content', 'geodir_action_details_map',30); function geodir_action_details_map_replace_slider(){ global $post,$post_images,$video,$special_offers, $related_listing,$geodir_post_detail_fields; $map_args = array(); $map_args['map_canvas_name'] = 'detail_page_map_canvas2' ; $map_args['width'] = '100%'; $map_args['height'] = '300'; if($post->post_mapzoom){$map_args['zoom'] = ''.$post->post_mapzoom.'';} $map_args['autozoom'] = false; $map_args['child_collapse'] = '0'; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; $map_args['enable_map_direction'] = true; echo '<div id="detailMapContainer">'; geodir_draw_map($map_args); echo '</div>'; } add_action( 'geodir_details_main_content', 'geodir_action_details_map_replace_slider',30);
November 15, 2014 at 1:00 pm #21612This reply has been marked as private.November 15, 2014 at 1:13 pm #21613Do you still have that problem once you tidy up your locations?
http://docs.wpgeodirectory.com/faqs/how-do-i-merge-locations/
For example you have a country called “all” in your database.November 15, 2014 at 1:25 pm #21614Hi Guust, this was one of the points I was going to ask about next although I didn’t think it would be related to this and more the fact that there are two map instances on the page.
The locations have gotten into a bit of a mess as we have had an external data entry person adding listings. I will go and merge the locations and see if that makes a difference.
I just want to confirm that I won’t be at risk of deleting any listings by doing this?
Many thanks
Mike
November 15, 2014 at 1:57 pm #21615If you MERGE locations, you will not loose any listings, but if you DELETE a location then you will also delete all listings in that location.
You can’t have 2 identical maps on the same page, but you can have the listing map to the detail page, http://www.bookhinterland.com.au/accommodation/julies-retreat/
November 15, 2014 at 2:15 pm #21616Hi Guust,
I have merged the locations. Please let me know if they look ok now.
The problem still exists though, even if I remove the custom action to add the map below the tabs box. So can you see anything else that is wrong?
Also, just to confirm, I don’t want two maps on the page, I just want one that appears outside of the tabbed area which I have partly done but as mentioned, neither that nor the map in the tabbed area are fully loading. Also for some reason, the map in the tabbed area is zoomed out to show a much larger area than just the intended one.
November 15, 2014 at 9:04 pm #21630Hi,
taking Stiofan’s example and modifying it, without actually looking at the original code will not work.
remove_action( 'geodir_details_main_content', 'geodir_action_details_map',30);
will do nothing because function geodir_action_details_map doesn’t exist. Priority 30 is assigned to slider.
The map is called with the tabs, so you should start by removing the tab.
Here is explained how to manipulate the tabs array:
https://wpgeodirectory.com/support/topic/exclude-selected-tabs-from-detail-page-if-empty/#post-7305
Once the tab for the map has been removed you will need part of the function of Stiofan to add it back, but you will have to add it correctly.
In your function you were trying to add it where the slider is, which you had not removed and that cannot work.
Actions of the detail page are:
add_action( 'geodir_details_main_content', 'geodir_action_before_single_post',10); add_action( 'geodir_details_main_content', 'geodir_action_page_title',20); add_action( 'geodir_details_main_content', 'geodir_action_details_slider',30); add_action( 'geodir_details_main_content', 'geodir_action_details_taxonomies',40); add_action( 'geodir_details_main_content', 'geodir_action_details_micordata',50); add_action( 'geodir_details_main_content', 'geodir_show_detail_page_tabs',60); add_action( 'geodir_details_main_content', 'geodir_action_after_single_post',70); add_action( 'geodir_details_main_content', 'geodir_action_details_next_prev',80);
Something like this should work.
add_action( 'geodir_details_main_content', 'geodir_action_details_map_in_content',65); function geodir_action_details_map_in_content(){ global $post,$post_images,$video,$special_offers, $related_listing,$geodir_post_detail_fields; $map_args = array(); $map_args['map_canvas_name'] = 'detail_page_map_canvas2' ; $map_args['width'] = '600'; $map_args['height'] = '300'; if($post->post_mapzoom){$map_args['zoom'] = ''.$post->post_mapzoom.'';} $map_args['autozoom'] = false; $map_args['child_collapse'] = '0'; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; $map_args['enable_map_direction'] = true; geodir_draw_map($map_args); }
I haven’t tested it, so let us know.
Thx
November 16, 2014 at 2:03 am #21646Hi Paolo,
Many thanks for the reply. When I followed the instructions that you provided the result was actually the same as with the original code. I excluded the maps tab within the Geodirectory interface and used the following to make sure the map was removed:
remove_action( ‘geodir_details_main_content’, ‘geodir_show_detail_page_tabs’,60);
Something I have noticed is that if I change $map_args[‘enable_jason_on_load’] to false, then the map actually loads but doesn’t have any markers for the listings on and is not zoomed to the relevant place on the map for the listing. Does this give any further indication as to what the problem might be?
Kind Regards
Mike
November 17, 2014 at 6:23 pm #21747Hi,
I’ve just tested it on one of my test website:
1) Excluded Map tabs from detail page in GD >> DEsign >> Detail.
2) added this to theme functions.php file:
add_action( 'geodir_details_main_content', 'geodir_action_details_map_in_content',65); function geodir_action_details_map_in_content(){ global $post,$post_images,$video,$special_offers, $related_listing,$geodir_post_detail_fields; $map_args = array(); $map_args['map_canvas_name'] = 'detail_page_map_canvas2' ; $map_args['width'] = '600'; $map_args['height'] = '300'; if($post->post_mapzoom){$map_args['zoom'] = ''.$post->post_mapzoom.'';} $map_args['autozoom'] = false; $map_args['child_collapse'] = '0'; $map_args['enable_cat_filters'] = false; $map_args['enable_text_search'] = false; $map_args['enable_post_type_filters'] = false; $map_args['enable_location_filters'] = false; $map_args['enable_jason_on_load'] = true; $map_args['enable_map_direction'] = true; geodir_draw_map($map_args); }
Result here: http://dropct.com/wpgd/places/mexico/quintana-roo/playa-del-carmen/attractions/rittenhouse-square/
At the bottom of the Tabs I see the map. If I want to show it before the tabs I just have to change priority to 55 in the new added action instead of 65.
If it’s not working for you, it could be because not knowing exactly what to do, you’ve been adding functions randomly and some of them are creating conflicts.
Please delete all modifications made and try the simple instructions above.
Thx
November 19, 2014 at 9:10 am #21915I have used this solution and it works fine, except after you enter the directions, it overflows onto whatever is below it.
I’ve discovered that this is due to the height being styled inline and there is no way to override it except by editing map_template_tags.php. But I would prefer not to edit any core files.
Any ideas?
Thanks.
November 19, 2014 at 4:54 pm #21943Hi,
this should be fixed adding this css:
#detailMapContainer #sticky_map_detail_page_map_canvas2 { height: auto !important; }
Thx
December 6, 2014 at 2:20 pm #23688Hi,
Just a quick update as I have now resolved this issue which was, as I suggested in my original post related in the end to having multiple instances of the Google Maps API loading and not the code that I was using.
This was being caused by the wpmegamenu plugin and once I set that not to load use the maps API everything worked ok with the original code that I posted
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket