at path:
ROOT
/
wp-content
/
plugins
/
meta-box
/
js
/
map.js
run:
R
W
Run
block-editor
DIR
2026-03-30 21:13:33
R
W
Run
jqueryui
DIR
2026-03-30 21:13:33
R
W
Run
leaflet
DIR
2026-03-30 21:13:33
R
W
Run
select2
DIR
2026-03-30 21:13:33
R
W
Run
validation
DIR
2026-03-30 21:13:33
R
W
Run
wp-color-picker-alpha
DIR
2026-03-30 21:13:33
R
W
Run
autocomplete.js
1.62 KB
2019-08-29 08:43:46
R
W
Run
Delete
Rename
autosave.js
595 By
2018-09-08 07:29:32
R
W
Run
Delete
Rename
button-group.js
1018 By
2022-12-06 12:16:48
R
W
Run
Delete
Rename
clone.js
9.19 KB
2025-11-05 19:50:18
R
W
Run
Delete
Rename
color.js
1.33 KB
2023-03-21 05:35:52
R
W
Run
Delete
Rename
date.js
2.47 KB
2025-01-11 08:07:14
R
W
Run
Delete
Rename
datetime.js
2.87 KB
2025-01-11 08:07:14
R
W
Run
Delete
Rename
file-input.js
1.87 KB
2022-03-01 14:16:10
R
W
Run
Delete
Rename
file-upload.js
5.49 KB
2025-08-13 13:15:06
R
W
Run
Delete
Rename
file.js
3.88 KB
2023-01-29 07:00:16
R
W
Run
Delete
Rename
icon.js
795 By
2026-03-05 12:31:14
R
W
Run
Delete
Rename
image-advanced.js
2.22 KB
2025-08-13 13:15:06
R
W
Run
Delete
Rename
image-upload.js
1.09 KB
2025-08-13 13:15:06
R
W
Run
Delete
Rename
input-list.js
1.07 KB
2024-06-20 07:56:06
R
W
Run
Delete
Rename
map-frontend.js
2.01 KB
2025-08-13 13:15:06
R
W
Run
Delete
Rename
map.js
8.63 KB
2025-10-06 11:05:52
R
W
Run
Delete
Rename
media.js
17.87 KB
2025-08-13 13:15:06
R
W
Run
Delete
Rename
modal.js
4.12 KB
2024-07-02 05:43:22
R
W
Run
Delete
Rename
oembed.js
880 By
2023-08-10 18:36:10
R
W
Run
Delete
Rename
osm-frontend.js
1.23 KB
2025-08-13 13:15:06
R
W
Run
Delete
Rename
osm.js
7.84 KB
2025-10-06 11:05:52
R
W
Run
Delete
Rename
password.js
672 By
2025-05-21 12:41:30
R
W
Run
Delete
Rename
post.js
1.23 KB
2024-06-20 07:56:06
R
W
Run
Delete
Rename
range.js
475 By
2024-09-27 11:22:22
R
W
Run
Delete
Rename
script.js
751 By
2022-12-13 11:10:44
R
W
Run
Delete
Rename
select-advanced.js
3.67 KB
2025-08-13 13:15:06
R
W
Run
Delete
Rename
select-tree.js
1.62 KB
2021-06-01 12:45:46
R
W
Run
Delete
Rename
select.js
536 By
2023-05-23 08:06:40
R
W
Run
Delete
Rename
slider.js
922 By
2020-04-17 08:24:00
R
W
Run
Delete
Rename
taxonomy.js
1.21 KB
2024-06-20 07:56:06
R
W
Run
Delete
Rename
time.js
1.5 KB
2026-03-05 12:31:14
R
W
Run
Delete
Rename
user.js
1.43 KB
2024-06-20 07:56:06
R
W
Run
Delete
Rename
video.js
2.73 KB
2025-08-13 13:15:06
R
W
Run
Delete
Rename
wysiwyg.js
5.36 KB
2023-07-18 06:41:26
R
W
Run
Delete
Rename
error_log
up
📄
map.js
Save
( function ( $, document, window, google, rwmb, i18n ) { 'use strict'; // Use function construction to store map & DOM elements separately for each instance var MapField = function ( $container ) { this.$container = $container; }; // Geocoder service. var geocoder = new google.maps.Geocoder(); // Autocomplete Service. var autocomplete = new google.maps.places.AutocompleteService(); // Use prototype for better performance MapField.prototype = { // Initialize everything init: function () { this.initDomElements(); this.initMapElements(); this.initMarkerPosition(); this.addListeners(); this.autocomplete(); }, // Initialize DOM elements initDomElements: function () { this.$canvas = this.$container.find( '.rwmb-map-canvas' ); this.canvas = this.$canvas[ 0 ]; this.$coordinate = this.$container.find( '.rwmb-map' ); this.addressField = this.$container.data( 'address-field' ); }, setCenter: function ( location ) { if ( !( location instanceof google.maps.LatLng ) ) { location = new google.maps.LatLng( parseFloat( location.lat ), parseFloat( location.lng ) ); } this.map.setCenter( location ); if ( this.marker ) { this.marker.setPosition( location ); return; } this.marker = new google.maps.Marker( { position: location, map: this.map, draggable: this.$canvas.data( 'marker_draggable' ), } ); }, initMapElements: function () { this.map = new google.maps.Map( this.canvas, { zoom: 14, streetViewControl: 0, mapTypeId: google.maps.MapTypeId.ROADMAP } ); // If there is a saved location, don't set the default location. if ( this.$coordinate.val() ) { return; } // Load default location if it's set. let defaultLoc = this.$canvas.data( 'default-loc' ); if ( defaultLoc ) { const [ lat, lng ] = defaultLoc.split( ',' ); return this.setCenter( { lat, lng } ); } // Set default location to Dublin as a start. const dublin = { lat: 53.346881, lng: -6.258860 }; this.setCenter( dublin ); // Try to load current user location. Note that Geolocation API works only on HTTPS. if ( location.protocol.includes( 'https' ) && navigator.geolocation ) { navigator.geolocation.getCurrentPosition( position => this.setCenter( { lat: position.coords.latitude, lng: position.coords.longitude } ) ); } }, initMarkerPosition: function () { const coordinate = this.$coordinate.val(); if ( coordinate ) { const location = coordinate.split( ',' ); this.setCenter( { lat: location[ 0 ], lng: location[ 1 ] } ); const zoom = location.length > 2 ? parseInt( location[ 2 ], 10 ) : 14; this.map.setZoom( zoom ); } else if ( this.addressField ) { this.geocodeAddress( false ); } }, // Add event listeners for 'click' & 'drag' addListeners: function () { var that = this; /* * Auto change the map when there's change in address fields. * Works only for multiple address fields as single address field has autocomplete functionality. */ if ( this.addressField.split( ',' ).length > 1 ) { var geocodeAddress = that.geocodeAddress.bind( that ); var addressFields = this.addressField.split( ',' ).forEach( function ( part ) { var $field = that.findAddressField( part ); if ( null !== $field ) { $field.on( 'change', geocodeAddress ); } } ); } google.maps.event.addListener( this.map, 'click', function ( event ) { that.marker.setPosition( event.latLng ); that.updateCoordinate( event.latLng ); } ); google.maps.event.addListener( this.map, 'zoom_changed', function ( event ) { that.updateCoordinate( that.marker.getPosition() ); } ); google.maps.event.addListener( this.marker, 'drag', function ( event ) { that.updateCoordinate( event.latLng ); } ); /** * Custom event to refresh maps when in hidden divs. * @see https://developers.google.com/maps/documentation/javascript/reference ('resize' Event) */ var refresh = that.refresh.bind( this ); $( window ).on( 'rwmb_map_refresh', refresh ); // Refresh on meta box hide and show rwmb.$document.on( 'postbox-toggled', refresh ); // Refresh on sorting meta boxes $( '.meta-box-sortables' ).on( 'sortstop', refresh ); }, refresh: function () { if ( !this.map ) { return; } var zoom = this.map.getZoom(), center = this.map.getCenter(); google.maps.event.trigger( this.map, 'resize' ); this.map.setZoom( zoom ); this.map.panTo( center ); }, // Autocomplete address autocomplete: function () { var that = this, $address = this.getAddressField(); if ( null === $address ) { return; } // If Meta Box Geo Location installed. Do not run autocomplete. if ( $( '.rwmb-geo-binding' ).length ) { var geocodeAddress = that.geocodeAddress.bind( that ); $address.on( 'selected_address', geocodeAddress ); return false; } $address.autocomplete( { source: function ( request, response ) { // if add region only search in that region var options = { 'input': request.term, 'componentRestrictions': { country: that.$canvas.data( 'region' ) } }; // Change Geocode to getPlacePredictions . autocomplete.getPlacePredictions( options, function ( results ) { if ( results == null || !results.length ) { response( [ { value: '', label: i18n.no_results_string } ] ); return; } response( results.map( function ( item ) { return { label: item.description, value: item.description, placeid: item.place_id, }; } ) ); } ); }, select: function ( event, ui ) { geocoder.geocode( { 'placeId': ui.item.placeid }, function ( responses, status ) { if ( status == 'OK' ) { const latLng = new google.maps.LatLng( responses[ 0 ].geometry.location.lat(), responses[ 0 ].geometry.location.lng() ); that.setCenter( latLng ); that.updateCoordinate( latLng ); } } ); } } ); }, // Update coordinate to input field updateCoordinate: function ( latLng ) { var zoom = this.map.getZoom(); this.$coordinate.val( latLng.lat() + ',' + latLng.lng() + ',' + zoom ).trigger( 'change' ); }, // Find coordinates by address geocodeAddress: function ( notify ) { var address = this.getAddress(), that = this; if ( !address ) { return; } if ( false !== notify ) { notify = true; } geocoder.geocode( { 'address': address }, function ( results, status ) { if ( status !== google.maps.GeocoderStatus.OK ) { if ( notify ) { alert( i18n.no_results_string ); } return; } that.setCenter( results[ 0 ].geometry.location ); that.updateCoordinate( results[ 0 ].geometry.location ); } ); }, // Get the address field. getAddressField: function () { // No address field or more than 1 address fields, ignore if ( !this.addressField || this.addressField.split( ',' ).length > 1 ) { return null; } return this.findAddressField( this.addressField ); }, // Get the address value for geocoding. getAddress: function () { var that = this; return this.addressField.split( ',' ) .map( function ( part ) { part = that.findAddressField( part ); return null === part ? '' : part.val(); } ) .join( ',' ).replace( /\n/g, ',' ).replace( /,,/g, ',' ); }, // Find address field based on its name attribute. Auto search inside groups when needed. findAddressField: function ( fieldName ) { let selector = `input[name="${ fieldName }"], select[name="${ fieldName }"]`; // Not in a group. let $address = $( selector ); if ( $address.length ) { return $address; } let $groupWrapper = this.$container.closest( '.rwmb-group-clone' ); if ( ! $groupWrapper.length ) { $groupWrapper = this.$container.closest( '.rwmb-group-wrapper' ); } if ( ! $groupWrapper.length ) { return null; } selector = `input[name*="${ fieldName }"], select[name*="${ fieldName }"]`; $address = $groupWrapper.find( selector ); if ( $address.length ) { return $address; } return null; } }; function createController() { var $this = $( this ), controller = $this.data( 'mapController' ); if ( controller ) { return; } controller = new MapField( $this ); controller.init(); $this.data( 'mapController', controller ); } function init( e ) { $( e.target ).find( '.rwmb-map-field' ).each( createController ); } function restart() { $( '.rwmb-map-field' ).each( createController ); } rwmb.$document .on( 'mb_ready', init ) .on( 'clone', '.rwmb-input', restart ); } )( jQuery, document, window, google, rwmb, RWMB_Map );