Sauter la navigation

[Résolu] How to make map not draggable

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: We would like to prevent Users from moving the map by adding draggable:false to the map options. Is this possible?

Solution: You can add map options with JavaScript by following the steps in the related documentation. The draggable option is being replaced by gestureHandling, but it is still available for now.

Relevant Documentation:
https://toolset.com/documentation/user-guides/maps/programmatically-change-map-settings/

This support ticket is created Il y a 4 années et 9 mois. 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par jasonH-5 Il y a 4 années et 9 mois.

Assisté par: Christian Cox.

Auteur
Publications
#1557747

Is there a way to add:

draggable: false

to the Google Map API?

We do not want people to move the map

Thanks for your help

#1559187

Hi, yes please check out this article for more information about interacting with MapOptions via the Google Maps JavaScript API, including example code:
https://toolset.com/documentation/user-guides/maps/programmatically-change-map-settings/

You mentioned draggable, which is still available but deprecated in favor of the more robust gestureHandling: https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.draggable

Also I should mention if you just want a picture of a map, Google offers a Static Maps API. This is great if you want to display a thumbnail map in a list of results, where the full interactive map isn’t necessary. Your page will appear to load faster, since fewer assets need to be loaded. It's also subject to a different pricing model, so you may pay less for this service in the long run. Be sure to enable the Static Maps API for your API key – this is a separate API that must be enabled in the Google API Console.

Example static map for a Types custom address field:

<img src="<em><u>lien caché</u></em> field='address-field-slug'][/types]&zoom=13&size=300x150&maptype=roadmap&markers=color:red&key=YOURAPIKEY" />
 

Change address-field-slug to match your address field. If your site isn’t https, change the protocol to http. You can also change the zoom and size parameters to fit your needs, and you must update YOURAPIKEY to use your actual API key. Other customization can be added as well, so you should review the full API documentation here:
lien caché

Let me know if you have questions about that.

#1561451

My issue is resolved now. Thank you!