Home › Toolset Professional Support › [Resolved] Maps Plugin API Problem
Problem:
Using URL referrer restrictions for the API key is preventing Maps from working properly.
Solution:
This will be fixed in Maps 1.5, which will allow you to add separate API keys for client-based requests (with URL restrictions) and server-based requests (with optional IP address restrictions).
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.
Our next available supporter will start replying to tickets in about 8.87 hours from now. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
Tagged: Toolset Maps, Views plugin
Related documentation:
This topic contains 24 replies, has 2 voices.
Last updated by Nigel 6 years, 5 months ago.
Assisted by: Nigel.
Hi,
I have a custom taxonomy called "Places".
I want to build a layout for it, so when visitors click on a term, they go to the pages that shows the relevant posts, but also show a map of the place.
I installed the Maps plugin, obtained an api key and did all the steps in the documentation.
However, there are multiple problems I can't solve:
1- The plugin will now work except if I made the API key unrestricted. Please check screenshot 001.jpg
If I restrict the api key to my website,
hidden link
and went to "check api" from the Plugin settings page, I get the following message:
REQUEST_DENIED - API keys with referer restrictions cannot be used with this API.
this is bad because anyone can use my api key and cost me money, as the api key usage is paid after a certain usage quote, according to Google.
Also, please check your documentation. It explains that I can restrict the api key:
https://toolset.com/documentation/user-guides/display-on-google-maps/creating-a-google-maps-api-key/
(this is not a local website issue, i tried the same steps on a testing server and had the exact same results).
.
2- It seems that the plugin is calling a retired version of the java scrip library.
I can see this message in the console:
"Google Maps API warning: RetiredVersion hidden link"
please check screenshot "Capture 2.jpg"
.
3- I made the API unrestricted for the time being till i hear back from you so I can create the layout.
- I created a terms field group and added an "Address" field to it. the field is called "Place Address".
- I created a layout and assigned it to the "Places Taxonomy".
- Then I edited one of the taxonomy terms and added the address of that place.
-I opened the layout and added a visual cell field
- Then I added a "map" from the fields and views.
- Then I tried adding a marker.
In the section called: The Marker address comes from:
there is this option, which is what I want:
Google Maps taxonomy field "Place Address"
But whenever I try to insert the shortcode, the plugin does not allow me to do so, because is says that the
Term ID is is mandatory,
although the description under the field says "can", not "should or must":
you can use a term id
Please check the attached screenshot "Capture.jpg".
When I entered the ID of the term manually, it worked. However, this should not be the case as I can't add term Id's in a layout!!!
------
4- Not every place will have a map. So i wanted to put a conditional saying:
if the "Place Address" field is not empty, display the map".
However, there is no conditional that works on term fields, the field does not show in the conditional dropdown list of available fields.
so this is the result of a term that doesnt have an address:
hidden link
can you please advise solutions for problems #1, #3, #4 and let the developers know about problem #2?
thanks a lot.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi there
We have a Maps update in final testing which I think should be published and which will solve 1 and 2.
The API key referrer problem affects a minority of users, and the solution will be to add two keys, one for client side requests (which should include a referrer restriction because the key is exposed) and a second key for server requests (which may optionally include an IP restriction but which is not required because the keys are not exposed).
For 3, I set up a test site to reproduce and I can confirm the problem.
I'm escalating this so that my colleagues can take a look and I'll update you when I have some news.
thanks a lot Nigel for your prompt response.
I had added a 4th problem while you were replying.
I thought of combining it here , rather than having 2 support tickets for a related matter.
thanks
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi there
The problem with trying to display the map and marker on a taxonomy archive is that the marker shortcode must always be added directly inside the loop (or a single post/page), but you need map to display outside the loop section of the archive.
Clearly our UI doesn't handle this very well, but this is the reason you cannot do what you are trying to do.
Here's how you can display the map and marker on the taxonomy archive and have it work:
1. Create a Taxonomy View
2. Query your custom taxonomy and add a filter: Taxonomy is set by the current post
3. In the LoopOutput section add the map and marker. For the marker, pass the Term ID:
[wpv-map-marker map_id=”map-2″ marker_id=”marker-[wpv-taxonomy-id]” marker_termmeta=”wpcf-place-address” id=”[wpv-taxonomy-id]”][/wpv-map-marker]
(You may need to edit the field slug, the map ID will be generated to match the map.)
4. Insert this new View into the Layout assigned to the archive.
You should then find the map displaying as expected on the archive pages.
I haven't tested it, but I think you should also be able to use the term meta fields inside conditional shortcodes in this View.
Let me know how you get on.
Hi,
thanks for the update.
I followed the steps, made the API key pbulic, until you fix the plugin.
There is an empty map that shows now on all taxonomy terms, whether the terms have an address or not.
here is a term that has the address filled:
hidden link
here is a term withe an empty address:
hidden link
obviously it's not picking up the term id
here are the steps:
- created a taxonomy view
- chose: query by taxonomy term / Taxonomy is set by the current post
- left the loop wizard locked.
- this is the section of the output editor:
[wpv-filter-meta-html] [wpv-layout-meta-html] [wpv-map-render map_id="map-2"][/wpv-map-render] [wpv-map-marker map_id="map-2" marker_id="marker-[wpv-taxonomy-id]" marker_termmeta="wpcf-place-address" id="[wpv-taxonomy-id]"][/wpv-map-marker]
can you please recheck the code?
thanks
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
I noted above that "the marker shortcode must always be added directly inside the loop" but in the code you show above you say that you didn't add it to the Loop Output section and instead added it to the final Output Editor.
Try adding the marker shortcode to the Loop Output section in between the wpv-loop tags.
Hi Nigel,
Thanks for the update. Sorry I misunderstood.
I now added it inside the loop like this:
[wpv-layout-start] [wpv-items-found] <!-- wpv-loop-start --> <wpv-loop> [wpv-map-render map_id="map-2"][/wpv-map-render] [wpv-map-marker map_id="map-2" marker_id="marker-[wpv-taxonomy-id]" marker_termmeta="wpcf-place-address" id="[wpv-taxonomy-id]"][/wpv-map-marker] </wpv-loop> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end]
The result is displaying 2 maps per taxonomy page.
here is a term that has the address filled:
hidden link
it shows one proper map, and one empty map.
here is a term withe an empty address:
hidden link
it shows 2 empty maps.
The assigned layout has only one line:
[wpv-view name="places-taxonomy-view"]
if i deleted this line, no maps show at all, so the 2 maps come from the view.
I appreciated your help.
thanks.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Sorry, only the marker shortcode should appear within the Loop, the map shortcode should be outside the Loop.
You can either add it in the Loop Output section immediately after the wpv-layout-start shortcode, or leave it in the Output Editor as you had it before.
Does it work correctly then?
Hi Nigel,
thanks a lot.
now it worked 🙂
However, not all places will have an address, so I tried to put a conditional to hide the map when the "wpcf-place-address" field is not filled, but i ended up hiding the map altogether.
here is the code i tried in the view:
[wpv-conditional if="( $(wpcf-place-address) ne '' )"] [wpv-map-render map_id="map-2"][/wpv-map-render] [/wpv-conditional]
then i tried adding the conditional to the layout itself, but still didn't work:
[wpv-conditional if="( $(wpcf-place-address) ne '' )"] [wpv-view name="places-taxonomy-view"] [/wpv-conditional]
any idea how to show the map conditionally, when the "wpcf-place-address" is filled?
thanks a lot.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
I've set up a test site to try and get this working myself and I cannot.
The conditional shortcode doesn't seem to work with term fields even when the View is a taxonomy View.
I'm double-checking with colleagues to confirm whether there is a way for this to work or whether it is broken.
I'll get back to you.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Good news.
Entering the condition in the correct format is tricky and must be done manually, but it works.
Here is the start of the Loop Output section for my View, which is where you add the conditional shortcode wrapped around the map shortcode:
[wpv-layout-start] [wpv-conditional if="( '[types termmeta='place-address'][/types]' ne '' )"] [wpv-map-render map_id="map-2"][/wpv-map-render] [/wpv-conditional]
Hi Nigel,
Thanks a lot for your follow up. I am glad it is working for you.
I couldn't get it to work for me.
here is my complete code, but now no maps show at all, whether the custom field is filled or not:
[wpv-layout-start] [wpv-conditional if="( '[types termmeta='place-address'][/types]' ne '' )"] [wpv-map-render map_id="map-2"][/wpv-map-render] [/wpv-conditional] [wpv-items-found] <!-- wpv-loop-start --> <wpv-loop> [wpv-map-marker map_id="map-2" marker_id="marker-[wpv-taxonomy-id]" marker_termmeta="wpcf-place-address" id="[wpv-taxonomy-id]"][/wpv-map-marker] </wpv-loop> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end]
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Sorry, that's frustrating.
The slug of your term address field is "place-address", no?
Can you simply output the types field where you have the conditional to check that for those terms where it should have a value it does?
[wpv-layout-start] <p>Test: [types termmeta='place-address'][/types]</p> [wpv-conditional if="( '[types termmeta='place-address'][/types]' ne '' )"] [wpv-map-render map_id="map-2"][/wpv-map-render] [/wpv-conditional] [wpv-items-found] <!-- wpv-loop-start --> <wpv-loop> [wpv-map-marker map_id="map-2" marker_id="marker-[wpv-taxonomy-id]" marker_termmeta="wpcf-place-address" id="[wpv-taxonomy-id]"][/wpv-map-marker] </wpv-loop> <!-- wpv-loop-end --> [/wpv-items-found] [wpv-no-items-found] <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong> [/wpv-no-items-found] [wpv-layout-end]
Does it print the address field correctly when it should?
Hi Nigel.
Yes it is called "place-address".
when I pasted the code you gave me now, the result shows the words:
Test:
but no address is shown
you can see it here:
hidden link
the test address i have in the field:
65 Holt Street, Eagle Farm QLD, Australia
thanks.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
That page is the place taxonomy archive for the term jericho, to which you should have added a taxonomy View where you would have inserted the types shortcode for place-address.
If that does not output anything on the page then it suggests that this term (jericho) does not have a place-address term field value.
If it does then there must be something different in your set-up to mine.
I think I should get credentials from you so that I can look at your site and check that myself.
Let me mark your next reply as private.
Could you set up a temporary admin user, and set their profile language to English?