How to enable Google map in Shipper and Receiver address
Setting up the Google Map
- Go to your wordpress admin.
- When you already in wordpress admin go to: wpcargo > Map Settings
- Enable the Enable Shipment History Map
- Enter your google map API key
- After fill in click the Save Map Setting button
Following are the codes for the Google Map Address will work in Address field of shipper and receiver
Copy and paste this code in your functions.php file in you active theme.
/* * componentRestrictions: {country: 'us'} - To restrict by country */ add_action( 'wpc_after_get_dynamic_place', 'mt_after_map_script', 10 ); function mt_after_map_script(){ echo " var shipper_input = document.getElementsByClassName('wpcargo_shipper_address'); var receiver_input = document.getElementsByClassName('wpcargo_receiver_address'); var new_options = { bounds: defaultBounds, types: ['geocode'], componentRestrictions: {country: 'us'} }; for (i = 0; i < shipper_input.length; i++) { autocomplete = new google.maps.places.Autocomplete(shipper_input[i], new_options); } for (i = 0; i < receiver_input.length; i++) { autocomplete = new google.maps.places.Autocomplete(receiver_input[i], new_options); }"; }