-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
map: доработки #2
Comments
Я сейчас столкнулся с загрузкой GoogleMaps и сделал пока что так: modules.define('i-googlemaps', ['loader_type_js', 'i-googlemaps__config', 'identify'],
function(provide, loader, config, identify) {
var win = this.global,
apiLoadCallback = 'googleMapsLoadCallback__' + identify(),
loaderUrl = config.url + apiLoadCallback;
/* global google.maps */
function doProvide() {
/**
* @exports
* @type Function
*/
provide(google.maps);
}
win[apiLoadCallback] = function() {
doProvide();
};
typeof google !== 'undefined' && typeof google.maps !== 'undefined' ?
doProvide() :
loader(loaderUrl);
}); |
Привет, подключил по Вашему методу блок i-googlemaps, но почему-то вылетает ошибка в консоли: Uncaught TypeError: window.initializegoogleMapsLoadCallback__uniq1 is not a function modules.define('i-googlemaps__config', function(provide) { provide(/** @exports */{ /** * URL for loading GoogleMapsApi if it does not exist */ url : '//maps.googleapis.com/maps/api/js?v=3&sensor=false&callback=initialize' }); }); Весь код блока подключения здесь: https://github.com/redhedg/i-googlemaps Что я делаю не так? Помогите пожалуйста разобраться. |
Апи Google Maps возвращате код как jsonp (ну или типа того), поэтому значением параметра callback должно быть имя нашей функции. Поэтому, собственно, мы собираем Попробуйте изменить modules.define('i-googlemaps__config', function(provide) {
provide(/** @exports */ {
/**
* URL for loading GoogleMaps API if it does not exist
*/
url: '//maps.googleapis.com/maps/api/js?v=3.exp&signed_in=false&callback='
});
}); |
Спасибо большое, все заработало! |
Отлично! Хотя сейчас мне кажется, что лучше сделать так для большей очевидности: i-googlemaps__config.jsmodules.define('i-googlemaps__config', function(provide) {
provide(/** @exports */ {
/**
* URL for loading GoogleMaps API if it does not exist
*/
url: function(callbackName) {
return '//maps.googleapis.com/maps/api/js?v=3.exp&signed_in=false&callback=' + callbackName;
}
});
}); i-googlemaps.jsmodules.define('i-googlemaps', ['loader_type_js', 'i-googlemaps__config', 'identify'],
function(provide, loader, config, identify) {
var win = this.global,
apiLoadCallback = 'googleMapsLoadCallback__' + identify(),
loaderUrl = config.url(apiLoadCallback);
/* global google.maps */
function doProvide() {
/**
* @exports
* @type Function
*/
provide(google.maps);
}
win[apiLoadCallback] = function() {
doProvide();
};
typeof google !== 'undefined' && typeof google.maps !== 'undefined' ?
doProvide() :
loader(loaderUrl);
}); |
Я наконец снова добрался до кода
Что сделал:
Что нужно сделать
С чем испытываю проблемы
Отправляю правильный урл в loader_type_js
получаю в ответ ошибку
The text was updated successfully, but these errors were encountered: