/* Admin End Scripts */ /* Location image Upload */ jQuery(document).ready(function ($) { $('#upload_location_image').click(function (e) { e.preventDefault(); var image = wp.media({ title: 'Upload Image', multiple: false }).open() .on('select', function (e) { var uploaded_image = image.state().get('selection').first(); console.log(uploaded_image); var location_image = uploaded_image.toJSON().url; $('#location_image').val(location_image); var img_tag = $('#location_image').val(location_image); }); }); }); /* Marker image Upload */ jQuery(document).ready(function ($) { $('#upload_marker_image').click(function (e) { e.preventDefault(); var image = wp.media({ title: 'Upload Image', multiple: false }).open() .on('select', function (e) { var uploaded_image = image.state().get('selection').first(); console.log(uploaded_image); var location_marker_img = uploaded_image.toJSON().url; $('#location_marker_img').val(location_marker_img); var img_tag = $('#location_marker_img').val(location_marker_img); }); }); }); /* Center Location Image Upload */ jQuery(document).ready(function ($) { $('#upload_center_image').click(function (e) { e.preventDefault(); var image = wp.media({ title: 'Upload Image', multiple: false }).open() .on('select', function (e) { var uploaded_image = image.state().get('selection').first(); console.log(uploaded_image); var center_image = uploaded_image.toJSON().url; $('#center_image').val(center_image); var img_tag = $('#center_image').val(center_image); }); }); }); /* Route Autocomplte js for direction map */ function initMaproute() { var map = new google.maps.Map(document.getElementById('map_route'), { mapTypeControl: false, center: {lat: 25.1231298197085, lng: 75.82576941970854}, zoom: 14 }); new AutocompleteDirectionsHandler(map); } /** * @constructor */ function AutocompleteDirectionsHandler(map) { this.map = map; this.originPlaceId = null; this.destinationPlaceId = null; this.travelMode = 'WALKING'; var originInput = document.getElementById('origin-input'); var destinationInput = document.getElementById('destination-input'); var modeSelector = document.getElementById('mode-selector'); this.directionsService = new google.maps.DirectionsService; this.directionsDisplay = new google.maps.DirectionsRenderer; this.directionsDisplay.setMap(map); var originAutocomplete = new google.maps.places.Autocomplete( originInput, {placeIdOnly: true}); var destinationAutocomplete = new google.maps.places.Autocomplete( destinationInput, {placeIdOnly: true}); this.setupClickListener('changemode-walking', 'WALKING'); this.setupClickListener('changemode-transit', 'TRANSIT'); this.setupClickListener('changemode-driving', 'DRIVING'); this.setupPlaceChangedListener(originAutocomplete, 'ORIG'); this.setupPlaceChangedListener(destinationAutocomplete, 'DEST'); this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(originInput); this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(destinationInput); this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(modeSelector); } /* Sets a listener on a radio button to change the filter type on Places */ /* Autocomplete. */ AutocompleteDirectionsHandler.prototype.setupClickListener = function (id, mode) { var radioButton = document.getElementById(id); var me = this; radioButton.addEventListener('click', function () { me.travelMode = mode; me.route(); }); }; AutocompleteDirectionsHandler.prototype.setupPlaceChangedListener = function (autocomplete, mode) { var me = this; autocomplete.bindTo('bounds', this.map); autocomplete.addListener('place_changed', function () { var place = autocomplete.getPlace(); if (!place.place_id) { window.alert("Please select an option from the dropdown list."); return; } if (mode === 'ORIG') { me.originPlaceId = place.place_id; } else { me.destinationPlaceId = place.place_id; } me.route(); }); }; AutocompleteDirectionsHandler.prototype.route = function () { if (!this.originPlaceId || !this.destinationPlaceId) { return; } var me = this; this.directionsService.route({ origin: {'placeId': this.originPlaceId}, destination: {'placeId': this.destinationPlaceId}, travelMode: this.travelMode }, function (response, status) { if (status === 'OK') { me.directionsDisplay.setDirections(response); } else { window.alert('Directions request failed due to ' + status); } }); }; /* Show/hide InfoWindow Customization Options */ jQuery(document).ready(function () { $("#info_window_custom_controls").hide(); $("#info_win_custom").click(function () { if ($(this).is(":checked")) { $("#info_window_custom_controls").show(); } else { $("#info_window_custom_controls").hide(); } }); $("#customization_center").hide(); $("#map_custom_center").click(function () { if ($(this).is(":checked")) { $("#customization_center").show(); } else { $("#customization_center").hide(); } }); $('.color-field').wpColorPicker(); }); /* Show/Hide Redirect URL Input box */ function non_redirect_url() { document.getElementById('redirect_input_div').style.display = 'none'; document.getElementById('redirect_info_div').style.display = 'flex'; } function redirect_url() { document.getElementById('redirect_input_div').style.display = 'flex'; document.getElementById('redirect_info_div').style.display = 'none'; } /* Show/Hide WayPoint Option Box */ function route_text() { document.getElementById('waypoints_options').style.display = 'none'; } function route_location() { document.getElementById('waypoints_options').style.display = 'block'; } /* Add Region script for Interactive Map Cpt */ var t; jQuery(document).ready(function () { t = $('#example').DataTable(); $("#submit_region").click(function () { var check_box = "