How to enable Google map in Shipper and Receiver address

shipper-receiver-google-map

Setting up the Google Map

  1. Go to your wordpress admin.
  2. When you already in wordpress admin go to: wpcargo > Map Settings
  3. Enable the Enable Shipment History Map
  4. Enter your google map API key
  5. After fill in click the Save Map Setting button
shipper-receiver-google-map

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);
	}";
}
0
    0
    Your Cart
    Your cart is emptyReturn to Shop