最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Maps API warning: SensorNotRequired - Stack Overflow

programmeradmin1浏览0评论

On the site / I am having an issue where the map will load my geolocation (enable geolocation to see) and then load all results (the entire world) - I need this to stay at the geolocation and not jump to the entire map.

After checking out the console I see "Google Maps API warning: SensorNotRequired //developers.google/maps/documentation/javascript/error-messages#sensor-not-required" and then a dropdown of Object etc....After digging a bit i came across the following scripts that still have the sensors in place:

if(ddp('google_places_api')) { if(ddp('google_places_api') != '') { wp_register_script('google_maps_api', '='.ddp('google_places_api').'&sensor=false&libraries=places'); } }
		else { wp_register_script('google_maps_api', '?'); }
		
	}

On the site https://gearbottle.com/ I am having an issue where the map will load my geolocation (enable geolocation to see) and then load all results (the entire world) - I need this to stay at the geolocation and not jump to the entire map.

After checking out the console I see "Google Maps API warning: SensorNotRequired //developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required" and then a dropdown of Object etc....After digging a bit i came across the following scripts that still have the sensors in place:

if(ddp('google_places_api')) { if(ddp('google_places_api') != '') { wp_register_script('google_maps_api', 'https://maps.googleapis.com/maps/api/js?key='.ddp('google_places_api').'&sensor=false&libraries=places'); } }
		else { wp_register_script('google_maps_api', 'https://maps.googleapis.com/maps/api/js?'); }
		
	}

	$google_places_url = 'https://maps.googleapis.com/maps/api/place/autocomplete/xml?key='.ddp('google_places_api').'&sensor=false&input='.$fields[$field->post_name].'&types=(regions)';

$reference_url = 'https://maps.googleapis.com/maps/api/place/details/xml?key='.ddp('google_places_api').'&sensor=false&reference='.$place_reference;

....but I am clueless on what to replace the "Sensor" part in each script to or if this even matters - I really just need the map to stop jumping and that's really it.

This is an older version of a theme that has been reconstructed (purchased by choice)- there is no longer support from original devs, so I am attempting to fix things on my own.

Share Improve this question asked Aug 23, 2016 at 0:42 NickNick 791 gold badge2 silver badges6 bronze badges 3
  • 1 replace &sensor=false with nothing, nada. zip, zero length string :p – Jaromanda X Commented Aug 23, 2016 at 0:44
  • Lol - ok, let me give that a shot. – Nick Commented Aug 23, 2016 at 0:48
  • that will get rid of the warning - not sure about your problem – Jaromanda X Commented Aug 23, 2016 at 0:52
Add a comment  | 

2 Answers 2

Reset to default 15

As per the documentation on Google Map Error Codes for SensorNotRequired

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

It is a warning and you can safely remove &sensor=false from the urls

How to add Google Map API to Web

<script
    src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&loading=async&libraries=maps&v=beta" defer>
</script>

https://developers.google.com/maps/documentation/javascript/add-google-map

发布评论

评论列表(0)

  1. 暂无评论