Base theme for LMMI Journal
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.2 KiB

6 years ago
(function ($, Drupal, drupalSettings) {
Drupal.behaviors.mtGoogleMaps = {
attach: function (context, settings) {
var mapSelectorClass = "google-map-canvas";
var mapSelector = "." + mapSelectorClass;
function initialize() {
$(context).find(mapSelector).once('mtGoogleMapsInit').each(function(index, item) {
var lat = $(this).attr('data-attribute-mt-latitude');
var lon = $(this).attr('data-attribute-mt-longitude');
var zoom = parseInt($(this).attr('data-attribute-mt-map-zoom'));
var latlng = new google.maps.LatLng(lat, lon);
var mapOptions = {
zoom: zoom,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: latlng,
scrollwheel: false
};
var map = new google.maps.Map(this,mapOptions);
var marker = new google.maps.Marker({
map:map,
draggable:true,
position: latlng
});
google.maps.event.addDomListener(window, "resize", function() {
map.setCenter(latlng);
});
});
}
google.maps.event.addDomListener(window, "load", initialize);
}
};
})(jQuery, Drupal, drupalSettings);