jquery-validation
9 years ago
jqueryui
9 years ago
select2
10 years ago
wp-color-picker-alpha
8 years ago
autocomplete.js
8 years ago
autosave.js
8 years ago
button-group.js
8 years ago
clone.js
8 years ago
color.js
9 years ago
date.js
8 years ago
datetime.js
8 years ago
file-input.js
9 years ago
file-upload.js
8 years ago
file.js
8 years ago
image-advanced.js
8 years ago
image-select.js
9 years ago
image-upload.js
8 years ago
input-list.js
8 years ago
map-frontend.js
8 years ago
map.js
8 years ago
media.js
8 years ago
oembed.js
8 years ago
range.js
8 years ago
script.js
8 years ago
select-advanced.js
8 years ago
select-tree.js
9 years ago
select.js
8 years ago
slider.js
8 years ago
thickbox-image.js
8 years ago
time.js
9 years ago
validate.js
8 years ago
video.js
8 years ago
wysiwyg.js
8 years ago
map-frontend.js
78 lines
| 1 | /* global google, jQuery */ |
| 2 | |
| 3 | jQuery( function ( $ ) { |
| 4 | 'use strict'; |
| 5 | |
| 6 | /** |
| 7 | * Callback function for Google Maps Lazy Load library to display map |
| 8 | * |
| 9 | * @return void |
| 10 | */ |
| 11 | function displayMap() { |
| 12 | var $container = $( this ), |
| 13 | options = $container.data( 'map_options' ); |
| 14 | |
| 15 | var mapOptions = options.js_options, |
| 16 | center = new google.maps.LatLng( options.latitude, options.longitude ), |
| 17 | map; |
| 18 | |
| 19 | switch ( mapOptions.mapTypeId ) { |
| 20 | case 'ROADMAP': |
| 21 | mapOptions.mapTypeId = google.maps.MapTypeId.ROADMAP; |
| 22 | break; |
| 23 | case 'SATELLITE': |
| 24 | mapOptions.mapTypeId = google.maps.MapTypeId.SATELLITE; |
| 25 | break; |
| 26 | case 'HYBRID': |
| 27 | mapOptions.mapTypeId = google.maps.MapTypeId.HYBRID; |
| 28 | break; |
| 29 | case 'TERRAIN': |
| 30 | mapOptions.mapTypeId = google.maps.MapTypeId.TERRAIN; |
| 31 | break; |
| 32 | } |
| 33 | mapOptions.center = center; |
| 34 | |
| 35 | // Typcast zoom to a number |
| 36 | mapOptions.zoom *= 1; |
| 37 | |
| 38 | if ( typeof mapOptions.styles === 'string' ) { |
| 39 | mapOptions.styles = JSON.parse(mapOptions.styles); |
| 40 | } |
| 41 | |
| 42 | map = new google.maps.Map( this, mapOptions ); |
| 43 | |
| 44 | // Set marker |
| 45 | if ( options.marker ) { |
| 46 | var marker = new google.maps.Marker( { |
| 47 | position: center, |
| 48 | map: map |
| 49 | } ); |
| 50 | |
| 51 | // Set marker title |
| 52 | if ( options.marker_title ) { |
| 53 | marker.setTitle( options.marker_title ); |
| 54 | } |
| 55 | |
| 56 | // Set marker icon |
| 57 | if ( options.marker_icon ) { |
| 58 | marker.setIcon( options.marker_icon ); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // Set info window |
| 63 | if ( options.info_window ) { |
| 64 | var infoWindow = new google.maps.InfoWindow( { |
| 65 | content: options.info_window, |
| 66 | minWidth: 200 |
| 67 | } ); |
| 68 | |
| 69 | google.maps.event.addListener( marker, 'click', function () { |
| 70 | infoWindow.open( map, marker ); |
| 71 | } ); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // Loop through all map instances and display them |
| 76 | $( '.rwmb-map-canvas' ).each( displayMap ); |
| 77 | } ); |
| 78 |