Support Forum
Support › MB Frontend Submission › Map field don't work in front officeResolved
Hello,
I use the metabox
'type' => 'map',
and I get the api from google.
In the back office it run well and I can search and get places:
https://my.pcloud.com/publink/show?code=XZXB8O7ZK2W6kKdctnR4zEs7MN8tDFp1wKkX
But in the fron office it doesn't work:
https://my.pcloud.com/publink/show?code=XZpB8O7Z9c3uxoqUoOzeGB6JYt0cOuTSaQk7
Do you have any idea?
Thanks,
Sergio
Hi Sergo,
Please check the browser dev console to see if there's any message from Google Maps API. Usually, Google will tell you exactly why.
Also check the page source to see if the API key is correct. Maybe other plugins enqueue a different JS file using different a API key.
Thanks,
Whith the console web appears some errors:
https://my.pcloud.com/publink/show?code=XZ3tmO7Zc35RjPUs2bzsgL0sfU9CekJlBfKy
JQMIGRATE: Migrate is installed, version 1.4.1 jquery-migrate.min.js:2:542
TypeError: google.maps.places is undefined[Saber más] mb-geo.js:67:4
You have exceeded your request quota for this API. See https://developers.google.com/maps/documentation/javascript/error-messages?utm_source=maps_js&utm_medium=degraded&utm_campaign=billing#api-key-and-billing-errors
js:51:110
Google Maps JavaScript API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys util.js:221:12
And the source code is this:
<a href="https://maps.google.com/maps/api/js?v=quarterly&scu_version=21">https://maps.google.com/maps/api/js?v=quarterly&scu_version=21</a>
But the metabox is the same configuration:
// GOOGLE MAPS
$meta_boxes[] = array (
'id' => 'location',
'title' => 'Mapa',
'post_types' => 'local', //array( 'local' , 'negocio' ), //$post_types,
'context' => 'after_title',
'style' => 'seamless',
'priority' => 'high',
// 'geo' => true,
// Return only cities and business results
'geo' => array(
'types' => array( 'establishment' )
),
'storage_type' => 'custom_table', // Important
'table' => 'locales', // Your custom table name
'fields' => array(
// Address field.
...
...
array(
'id' => 'mb_mapa_map',
'name' => 'Mapa',
'type' => 'map',
//'language' => 'es',
// Default location: 'latitude,longitude[,zoom]' (zoom is optional)
// 'std' => '-6.233406,-35.049906,15',
// Address field ID
'address_field' => 'address_location',
//'geo' => true,
'api_key' => 'AIzaSyCjqt3G7n6brVxxxxxxxxx',
),
Don't understand why in the backoffice run and in the front office not... I'm doing anything wrong?
Thanks,
Sergio
Hi Sergio,
I guess you're using another plugin that also enqueues Google Maps. The URL above is different from what Meta Box outputs. If that's correct, it's easy to explain 2 errors in the console: the API key is not provided and the limit exceeds.
Oh perfect!!
I had another plugin installed;
https://es.wordpress.org/plugins/wp-flexible-map/
I desactivated this plugin and now it run perfect!!
Many thanks for your tips!!!!