Javascript Google Maps API 警告:SensorNotRequired

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39090691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 22:11:16  来源:igfitidea点击:

Google Maps API warning: SensorNotRequired

javascriptjquerygoogle-maps

提问by Nick

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.

在网站https://gearbottle.com/ 上,我遇到了一个问题,地图将加载我的地​​理位置(启用地理位置查看)然后加载所有结果(整个世界) - 我需要这个来保持地理位置而不是跳转到整个地图。

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 Objectetc....After digging a bit i came across the following scripts that still have the sensors in place:

在查看控制台后,我看到“Google Maps API 警告:SensorNotRequired //developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required”,然后是Object等下拉菜单......之后挖掘了一下,我遇到了以下仍然有传感器的脚本:

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.

这是一个旧版本的主题,已经重建(选择购买)——不再有原始开发者的支持,所以我试图自己解决问题。

回答by Joyson

As per the documentation on Google Map Error Codesfor SensorNotRequired

根据SensorNotRequired 的Google Map Error Codes文档

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.

Google Maps JavaScript API 不再需要传感器参数。它不会阻止 Google Maps JavaScript API 正常工作,但我们建议您从脚本元素中删除传感器参数。

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

这是一个警告,您可以安全地&sensor=false从网址中删除