I am trying to: have the map of an establishment show in a view.
The map WORKS in a single establishment page, for example.
I use Elementor pro > map > Dynamic > Toolset field. I see the map nice, right location, and the custom marker.
But then I have a cocktail single page, in which I need a view showing which establishment is serving that cocktail.
In this view I have the logo of the establishment, telephone number, and map.
Logo works, telephone works, they are the right one. So that means the loop is right, with the right query.
But the maps ends up in the pacific with no marker.
I tried:
- Putting the map outside the loop: still in the pacific
I know:
- That the query is ok (it shows right logo, text etc)
I have a relashionship where many cocktails can be in one establishment
I have connected the cocktail to the establishment
Code: [wpv-map-render map_id="mapEtabliCocktail" single_zoom="15" map_type_control="off" street_view_control="off" marker_icon="//invasioncocktailOUI.com/2019/wp-content/uploads/icon_marker.png"]Téléchargement de la carte[/wpv-map-render]
So the question:
- why does the map work, in the single establishment page, or when I add a new establishment/modify an establishment in admin
- But does not work in a view
In this view I have the logo of the establishment, telephone number, and map.
Hi, what about a map marker shortcode? You didn't mention one, and I don't see one in your code sample. If a map marker is included, please copy + paste the code here for me to review. If not, you must add one to the View's wpv-loop area. If you add the marker shortcode and it's not working as expected, please also insert the Address field using the Types field shortcode just after the map marker shortcode. This will print the address to the screen and help us confirm the address is stored as expected for the Establishment post.
I made it work with an old code, like this:
[wpv-map-render map_id="maptest2" map_height="284px" single_zoom="15" general_zoom="14" marker_icon="//invasioncocktailOUI.com/2019/wp-content/uploads/icon_marker.png" id="$etablissement"][wpv-map-marker map_id="maptest2" marker_id="marker-de-etablissement" marker_field="wpcf-etablissement-adresse" id="$etablissement"][/wpv-map-marker]
- Is it working because I added the marker?
- Or because I had to manually add the $etablissement
- Should I not close the wpv-map-render tag?
- Is it working because I added the marker?
A marker shortcode is required to display a marker or center the map automatically, so yes this is probably the main reason it's working better now.
- Or because I had to manually add the $etablissement
Maybe, but probably not. Look at the map shortcode here:
[wpv-map-render map_id="maptest2" map_height="284px" single_zoom="15" general_zoom="14" marker_icon="//invasioncocktailOUI.com/2019/wp-content/uploads/icon_marker.png" id="$etablissement"]
The "id" attribute here is unnecessary, because the map isn't directly associated with any post. The map is just a space where you can show marker(s) based on some other information associated with the Establishment post. Now look at the marker shortcode:
[wpv-map-marker map_id="maptest2" marker_id="marker-de-etablissement" marker_field="wpcf-etablissement-adresse" id="$etablissement"][/wpv-map-marker]
The id="$etablissement" is probably not necessary in this shortcode either. It depends on the content selection in the View and whether or not you have migrated to the new Post Relationships system. If Establishment posts are the Content Selection in this View, and the map marker shortcode is placed in the same View's loop tags (not nested inside another View), then the "id" attribute is not necessary because the address field is related to the current post in the loop. It would only be necessary if the View is a View of some other related post type, and if you are still using the old post relationships system. If you've updated to the new Types relationships system the syntax has been changed a bit and should be updated. You should use the Fields and Views button to regenerate this marker shortcode to work with the new relationships syntax if that is the case.
- Should I not close the wpv-map-render tag?
Yes, the system should automatically close it for you if you use the Fields and Views button to insert the map. If you copy + paste from another location, you should manually close it if necessary.