Googlemap field not working in view
- This topic has 6 replies, 3 voices, and was last updated 3 years, 2 months ago by
Long Nguyen.
-
AuthorPosts
-
July 15, 2022 at 7:33 PM #37027
Chris P
ParticipantHi,
In the backend the maps works just fine. But in the front I get errors that say I'm not using a key. Which I am so what am I doing wrong.
API key is okay (exists, billable and no restrictions)
But still I keep getting this
You are using this API without a key. See https://developers.google.com/maps/documentation/javascript/error-messages?…aps_js&utm_medium=degraded&utm_campaign=billing#api-key-and-billing-errors
July 16, 2022 at 4:49 AM #37035Marius Doko
ParticipantHello,
I am also having issues on View, but not with google maps but with OSM. Since the last update, i can't see the map in the frontend. In backend works well
July 17, 2022 at 10:02 PM #37045Long Nguyen
ModeratorHi,
@Chris: Is the Google map a subfield (in a group) on your site? Please share some screenshots of the issue and the code that creates the custom fields.@Marius: Please use the option Map (custom style) when inserting the field map to View content. The option default style does not look working.
August 1, 2022 at 4:29 PM #37298Chris P
ParticipantHi Long,
Yes it's the map is a subfield of the address group
This is the map {{ mb.render_map( post.office_address.map_google ) }}In the backend it displays in the frontend it's an empty space
August 1, 2022 at 8:20 PM #37301Chris P
ParticipantUPDATE
ok these do not work:
{{ mb.render_map( post.office_address.map_google ) }} {{ mb.rwmb_meta( 'post.office_address.map_google') }}This does work
in functions.php
function my_map() { $group_values = rwmb_meta( 'office_address' ); $args = array( 'api_key' => 'GOOGLE API CODE' ); echo RWMB_Map_Field::render_map( $group_values['map_google'], $args ); }in view
{{ mb.my_map() }}October 20, 2022 at 7:52 PM #38763Chris P
ParticipantHi after updating,
My solution doesn't work anymore. But the standard map still doesn't work
I get the following error
ReferenceError: google is not definedIn the backend everything works fine in the front nothing shows up
I use {{ post.office_address.map_google.rendered }} to display it
Br,
ChrisOctober 21, 2022 at 9:45 AM #38769Long Nguyen
ModeratorHi,
If you want to output the subfield Google map in a group, you need to pass the API key to the function
render_map()as on the documentation https://docs.metabox.io/fields/map/#outputting-a-map-in-a-groupIn your case,
google is not defined, I think there is another JS error and it breaks all JS functions on your site. You can try to deactivate all plugins except Meta Box, MB extensions, switch to the standard theme of WordPress and recheck this issue. -
AuthorPosts
- You must be logged in to reply to this topic.