Site logo

Archived topic

Javascript to site

3 replies · Started by takkularapsis on January 25, 2022

Viewing posts 1–4 of 4

Hi,

Im trying to restrict Google Maps autocomplete to only in one country Finland.
Google technical support gave me this to be added in website javascript:

--------------------

const autocomplete = new google.maps.places.Autocomplete(input, options);

// Set initial restriction to the greater list of countries.
autocomplete.setComponentRestrictions({
country: ["FI"],
});

---------------

I have been trying to add it in gp hook but not quite sure if im doing everything allright.

Hi there,

you need to wrap you JS in script tags ie.

<script>
 Add the googlemaps code here
</script>

Which hook are you using ?

Hi,

Ok, tried to with script tags to wp_footer, wp_head, and few others. The maps itself comes from plugin and is not put by hooks.

Hi there,

I can only tell that WP_footershould be the hook for your code.

But I'm not sure if the code would work for the map from a 3rd party plugin.

This archived topic is closed to new replies.