Skip Navigation

[Resolved] ToTop when js-wpv-addon-maps-focus-map

This support ticket is created 5 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by romanB-3 5 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#1139500

Hello,
I have a very long list of posts, and when clicking on "center on the map", the page should go to top in order to see the map. How may I achieve this ?
Thank you.

#1140198

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi there,

Thank you for contacting us and I'll be happy to assist.

To make the page scroll to the map on top when the "focus on marker" link is clicked, you'll need to add some custom jQuery script. For example:


$(".js-wpv-addon-maps-focus-map").click(function() {
    $('html, body').animate({
        scrollTop: $("#js-wpv-addon-maps-render-map-1").offset().top - 70
    }, 1000);
});

Feel free to replace the class "js-wpv-addon-maps-focus-map" with the actual class attached to your marker focus link and the ID "js-wpv-addon-maps-render-map-1" with actual ID of your map's container.

For a more personalized assistance around custom code, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

I hope this helps.

regards,
Waqar

#1140277

This works great thank you very much.
Is it also possible to open the popup window related to the pin on the map on this same action ?
Thank you.

#1140314

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thanks for the update and glad the script works.

To make the marker's popup window also open when the "focus on marker" link is clicked, you'll find a "Clicking this item will also open the marker popup" checkbox, on the "Interaction" tab (when adding the focus on marker link).
( screenshot: hidden link )

For an already added link, you can include a special class "js-toolset-maps-open-infowindow-map-map-ID-marker-marker-ID" to it.
(where you'll replace "map-ID" with map's actual ID and "marker-ID" with the marker's actual ID)

For example, if your existing link's code is:


<a href="#" class="js-wpv-addon-maps-focus-map" data-map="map-1" data-marker="marker-[wpv-post-id]">Show on map</a>

It will become:


<a href="#" class="js-wpv-addon-maps-focus-map js-toolset-maps-open-infowindow-map-map-1-marker-marker-[wpv-post-id]" data-map="map-1" data-marker="marker-[wpv-post-id]">Show on map</a>

regards,
Waqar

#1140315

Thank you, this also works great.

Nevertheless, I just noticed a small problem with the "totop" functionality : I use a sticky header, and the top part of the map is hidden by it. Would it be easily possible to improve ?

#1140327

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

You can increase value "70" in the script and it will increase the offset value from the top of the page when scrolled.

regards,
Waqar

#1140328

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.