Skip to content

Commit b329ed1

Browse files
committed
Update Google Map API for google_map extension.
Signed-off-by: Kev Provance <[email protected]>
1 parent f10d86e commit b329ed1

File tree

7 files changed

+46
-18
lines changed

7 files changed

+46
-18
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Redux Framework
2-
[![WordPress plugin](https://img.shields.io/wordpress/plugin/v/redux-framework.svg?maxAge=3600)](https://wordpress.org/plugins/redux-framework) [![WordPress](https://img.shields.io/wordpress/v/redux-framework.svg?maxAge=3600)](https://wordpress.org/download/) [![Build Status](https://travis-ci.org/reduxframework/redux-framework.png?branch=master)](https://travis-ci.org/reduxframework/redux-framework) [![Slack](https://redux-slackin.herokuapp.com/badge.svg)](https://redux-slackin.herokuapp.com)
2+
[![WordPress plugin](https://img.shields.io/wordpress/plugin/v/redux-framework.svg?maxAge=3600)](https://wordpress.org/plugins/redux-framework) [![WordPress](https://img.shields.io/wordpress/v/redux-framework.svg?maxAge=3600)](https://wordpress.org/download/)
33

44
## New to Version 4.4 ##
55
* The Extendify Templates and Patterns library has been unbundled from Redux. To continue using Extendify, please download the standalone plugin from the WordPress.org repository: [https://wordpress.org/plugins/extendify](https://wordpress.org/plugins/extendify)
@@ -27,6 +27,9 @@
2727
* Removed: `async_typography` global arg. Google no longer supports it. Use `font_display` with one of the following `auto|block|swap|fallback|optional`. See: [https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display)
2828
* Automatic update option for Google Fonts without a Pro subscription.
2929

30+
## Join us on Slack ##
31+
[Redux Slack](https://join.slack.com/t/redux/shared_invite/zt-1op7uw3up-kXgZp4Y93TeCSmq_LALl~Q)
32+
3033
## Follow us on Social Media! ##
3134
[![Follow us on Twitter](https://www.download82.com/images/produse/iconuri/twitter-for-android.png "Follow us on Twitter")](https://www.twitter.com/ReduxFramework)
3235
[![Like us on Facebook](https://addons.thunderbird.net/user-media/addon_icons/79/79494-64.png "Like us on Facebook")](https://www.facebook.com/ReduxFramework/)

redux-core/assets/css/redux-fields.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

redux-core/assets/css/redux-fields.min.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

redux-core/inc/extensions/google_maps/class-redux-extension-google-maps.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Redux_Extension_Google_Maps extends Redux_Extension_Abstract {
2222
*
2323
* @var string
2424
*/
25-
public static $version = '4.3.21';
25+
public static $version = '4.4.0';
2626

2727
/**
2828
* Extension friendly name.

redux-core/inc/extensions/google_maps/google_maps/class-redux-google-maps.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -362,25 +362,39 @@ public function enqueue() {
362362

363363
$api_key = '';
364364
if ( ! empty( $this->api_key ) ) {
365-
$api_key = '&key=' . $this->api_key;
365+
//$api_key = '&key=' . $this->api_key;
366+
$api_key = $this->api_key;
366367
}
367368

368-
wp_enqueue_script(
369-
'redux-field-google_maps-api',
370-
'//maps.googleapis.com/maps/api/js?v=' . $this->field['map_version'] . $api_key . '&libraries=places',
371-
array( 'jquery' ),
372-
$this->field['map_version'],
373-
true
374-
);
369+
//wp_enqueue_script(
370+
// 'redux-field-google_maps-api',
371+
// '//maps.googleapis.com/maps/api/js?v=' . $this->field['map_version'] . $api_key . '&libraries=places&callback=initMap',
372+
// array( 'jquery' ),
373+
// $this->field['map_version'],
374+
// true
375+
//);
375376

376-
wp_enqueue_script(
377+
wp_register_script(
377378
'redux-field-google_maps-js',
378379
$this->url . 'redux-google-maps' . $min . '.js',
379-
array( 'jquery', 'redux-js', 'redux-field-google_maps-api' ),
380+
array( 'jquery', 'redux-js' ),
380381
Redux_Extension_Google_Maps::$version,
381382
true
382383
);
383384

385+
if ( ! wp_script_is('redux-field-google_maps-js','enqueued') ) {
386+
$script = '(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
387+
key:"' . $api_key . '",
388+
v:"' . $this->field['map_version'] . '",
389+
libraries:"places",
390+
callback:"initMap"
391+
});';
392+
393+
wp_add_inline_script( 'redux-field-google_maps-js', $script );
394+
}
395+
396+
wp_enqueue_script( 'redux-field-google_maps-js' );
397+
384398
if ( $this->parent->args['dev_mode'] ) {
385399
wp_enqueue_style(
386400
'redux-field-google_maps',

redux-core/inc/extensions/google_maps/google_maps/redux-google-maps.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
/* global jQuery, document, redux_change, redux, google */
66

7+
//async function initMap() {
8+
// const { Map } = await google.maps.importLibrary("maps");
9+
// console.log(map);
10+
//}
11+
12+
//initMap();
13+
714
(function( $ ) {
815
'use strict';
916

@@ -113,7 +120,7 @@
113120
};
114121

115122
/* MAP RENDER FUNCTION */
116-
redux.field_objects.google_maps.renderMap = function( el, mapClass ) {
123+
redux.field_objects.google_maps.renderMap = async function( el, mapClass ) {
117124
var scrollWheel;
118125
var streetView;
119126
var mapType;
@@ -134,7 +141,11 @@
134141

135142
// Create the autocomplete object, restricting the search
136143
// to geographical location types.
137-
g_autoComplete = new google.maps.places.Autocomplete(
144+
//var x = new google.maps
145+
//console.log(x);
146+
//g_autoComplete = new google.maps.importLibrary("places").Autocomplete(
147+
g_autoComplete = await google.maps.importLibrary( 'places' );
148+
var ac = new g_autoComplete.Autocomplete(
138149
( document.getElementById( autocomplete ) ),
139150
{
140151
types: ['geocode']
@@ -517,7 +528,7 @@
517528
redux.field_objects.google_maps.setupClickListener = function( id, types ) {
518529
var radioButton = document.getElementById( id );
519530

520-
google.maps.event.addEventListener(
531+
google.maps.event.addListener(
521532
radioButton,
522533
'click',
523534
function() {

redux-core/inc/extensions/google_maps/google_maps/redux-google-maps.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)