Problem configuring Google Maps API?

  • 0
    I found a manual on the Internet on the request of the client's geodata for customization in ordering.

    https://netrange.com/webdev/woocommerce-dostavra.html

    Created API added to the code on the page

    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=АПИ КОД&amp;sensor=false"></script>
    <script type="text/javascript">
    var geocoder;
    function initialize() {
    	geocoder = new google.maps.Geocoder();
    }
    if (navigator.geolocation) {
    	navigator.geolocation.getCurrentPosition(function(position) {
    		var pos = {
    		  lat: position.coords.latitude,
    		  lng: position.coords.longitude
    		};
    		console.log('your lat:'+position.coords.latitude+'your lon:'+position.coords.longitude);
    		geocoder.geocode( {'location': pos}, function(results, status) {
    			if (status == 'OK') {
    				var db_obj = results[0].address_components;
    				var route ='';
    				var street_number='';
    				jQuery.each(db_obj, function(i) {
    					if (this.types=='route'){
    						route = this.long_name;
    					}
    					if (this.types=='street_number'){
    						street_number = this.long_name;
    					}
    				});
    				var address = route+street_number;
    				console.log('your address: '+address);
    				if (address!=''){
    					jQuery('#shipping_address_1').val(route+' '+street_number);
    					jQuery('#shipping_address_1').change();
    				}
    			}
    		});
    	});
    }
    function codeAddress() {
    	var address = 'Узбекистан, Ташкенсткая область, Ташкент, '+jQuery('#shipping_address_1').val();
    	geocoder.geocode( { 'address': address}, function(results, status) {
    		if (status == 'OK') {
    			var db_obj = results[0].address_components;
    			jQuery.each(db_obj, function(i) {
    				if (this.types=='postal_code'){
    					console.log('your postal_code:'+this.long_name);
    					jQuery('#shipping_postcode').val(this.long_name);
    					jQuery('body').trigger('update_checkout');
    				}
    			});
    		}else {
    			alert('Geocode was not successful for the following reason: ' + status);
    		}
    	});
    }
    jQuery(document).ready(function(){
    	initialize();
    	jQuery('#shipping_address_1').change(function(){
    		codeAddress();
    	});
    });
    </script>


    When checking in the console, writes

    util. js: 229 Google Maps JavaScript API warning: SensorNotRequired https: //developers.google.com/maps/documentation/j ...
    Nz.o @ util.js: 229
    (anonymous) @ js? key = API CODE & amp; sensor = false: 140
    Promise.then (async)
    (anonymous) @ js? key = API CODE & amp; sensor = false: 140
    setTimeout (async)
    Jj @ js? Key = API CODE & amp; sensor = false: 140
    google.maps.Load @ js? key = API CODE & amp; sensor = false: 14
    (anonymous) @ js? key = API CODE & amp; sensor = false: 258
    (anonymous) @ js? key = API CODE & amp; sensor = false: 258

    How can I fix it please tell me in the documentation I'm starting to read the errors found nothing
    JavaScript Elliott Kirk, Sep 19, 2019

  • 1 Answers
  • 0
    I will quote the documentation for you, since you could not open it.

    The sensor parameter is no longer required for the Maps JavaScript API. It won't prevent the Maps JavaScript API from working correctly, but we recommend that you remove the sensor parameter from the script element.
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!