универсальный виджет карт
"use strict";
(function(root, factory) {
if(typeof exports === 'object') {
module.exports = factory();
}
else if(typeof define === 'function' && define.amd) {
define(['jquery', 'googlemaps!'], factory);
}
else {
root.Map = factory();
}
}(this, function() {
/*!
* GMaps.js v0.4.24
* http://hpneo.github.com/gmaps/
*
* Copyright 2016, Gustavo Leon
* Released under the MIT License.
*/
var mapType = '';
var Map = (function(global) {
"use strict";
var Map = function(type, options) {
if (!this) return new Map(type, options);
mapType = type;
};
return Map;
})(this);
var YMaps = (function() {
"use strict";
var YMaps = function() {
if (!this) return new YMaps(options);
console.log('YMaps');
};
return YMaps;
})(this);
var GMaps = (function() {
"use strict";
var GMaps = function() {
if (!(typeof window.google === 'object' && window.google.maps)) {
if (typeof window.console === 'object' && window.console.error) {
console.error('Google Maps API is required. Please register the following JavaScript library https://maps.googleapis.com/maps/api/js.');
}
return function() {};
}
if (!this) return new GMaps(options);
console.log('GMaps');
};
return GMaps;
})(this);
if(mapType == 'yandex'){
Map = YMaps;
}else if(mapType == 'google'){
Map = GMaps;
}
console.log(mapType);
return Map;
}));
<?php require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php");?>
<style type="text/css">
#map {
width: 400px;
height: 400px;
}
</style>
<div id ="map" class="map-yadex"></div>
<script>
var map = new Map('yandex', 111);
</script>
<? require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php");?>