按县限制 Google 地图地理编码请求?
Restricting a Google Maps geocode request by county?
我正在使用 JavaScript API,但似乎也无法使其与 CURL API 一起工作。
问题:我想按县 + 州限制我的地理编码结果。 Google 地图地理编码 API 组件过滤不再识别格式为 "San Mateo County, CA"
的 administrativeArea
(以前有效),并且即使它已识别 "San Mateo County"
根据结果对象绝对是 administrative_area_level_2
。
例如,"https://maps.googleapis.com/maps/api/geocode/json?address=oakland&components=country:US|administrative_area:San+Mateo+County&key=YOUR_KEY_HERE"
return 是奥克兰的结果,即使它位于阿拉米达县,而不是圣马特奥县。使用 "San Mateo County, CA" 也被完全忽略。做 components=country:US|administrative_area:San+Mateo+County|adminstrative_area:CA
同样是行不通的(据我所知,无论如何用 JS API 是不可能的)。
(最终用例是当经过地理编码的地址实际上不是位置时处理结果,例如 "Homeless",它曾经 return 一个错误代码但最近开始 return ing "United States",部分原因是组件过滤似乎已更改。)
如果您想使用 API,这里有一个 JS fiddle 可以实现:https://jsfiddle.net/Lzj1uvfd/
2018 年 1 月,地理编码 API 的组件过滤发生了变化。此变化后,只有邮政编码和国家/地区过滤器作为严格过滤器,路线、地区和管理区域不是严格过滤器并且只是影响结果。
Google 向高级计划客户发送了有关此更改的通知。我在此处共享此电子邮件的副本
Hello Maps APIs Premium Plan customer,
Upcoming quality improvements in Google Maps geocoding services will require that the Component Filtering feature of the Geocoding API become less restrictive. This will become effective on January 16, 2018.
In the meantime, we are exposing a test parameter on the Geocoding API web service, so that you can see whether this change will affect your geocoding requests utilizing the Component Filtering feature. To use the parameter, add relax_components=true to your requests.
This test parameter will be available through January 16, 2018. After that date the parameter will be ignored, but requests using the parameter will still be accepted. There is no JavaScript equivalent.
The quality improvements will provide higher quality results for requests that seek to find valid addresses. However, the following statements will not longer apply to the Component Filtering feature:
A query containing a component filter only returns the geocoding results that match the filter. If no matches are found, the geocoder returns a result that matches the filter itself.
Component filtering will return a ZERO_RESULTS response only if you provide filters that exclude each other.
Filters for postal codes and country codes will continue to be enforced strictly for all queries.
Examples
An address that is not strictly contained by the locality filter (Spring Valley, NV), but it is near (in Paradise, NV), will be found instead of a less specific result matching the locality filter exactly:
Example request #1: address=4755+W+Flamingo+Rd&components=locality:Spring+Valley|country:US
Current result: "W Flamingo Rd, Spring Valley, NV, USA" (route, partial_match)
Future result: "4755 W Flamingo Rd, Las Vegas, NV 89103, USA" (premise)
A result in the different locality may be returned, instead of ZERO_RESULTS, when the locality filter would otherwise form a non-existent address:
Example request #2: components=locality:Montreal+Lake+Reserve|administrative_area:Saskatchewan|country:CA
Current result: ZERO_RESULTS
Future result: "Montreal Lake, SK S0J 1Y0, Canada" (establishment)
Example request #3: components=country:US|locality:friends+creek+conservation+area+cisco|administrative_area:IL
Current result: ZERO_RESULTS
Future result: "Friends Creek Conservation Area, 13734 Friends Creek Park Rd, Cisco, IL 61830, USA" (park)
Mutually exclusive filters no longer guarantee ZERO_RESULTS. This has been already the case since the old forward geocoder was permanently retired on April 3, 2017. The upcoming change will make this happen more often, e.g. when the administrative_area filter is favoured over the locality filter:
Example request #4: address=Müslistrasse+16&components=locality:Spreitenbach|administrative_area:ZH|country:CH
Current result: ZERO_RESULTS
Future result: "Muslistrasse 16, 8820 Wädenswil, Switzerland" (street_address)
An invalid address that was never found will no longer yield a result that matches the filter itself. This may result in either ZERO_RESULTS or one or more valid addresses that match some of the filters.
Example request #5: address=13+Rue+del+Percebe&components=locality:Sydney|country:AU
Current result: "Sydney NSW 2000, Australia" (locality)
Future result: ZERO_RESULTS
Example request #6: address=Sesame+St&components=locality:Sydney|country:AU
Current result: "Sydney NSW 2000, Australia" (locality)
Future result: "Sesame St, Mount Waverley VIC 3149, Australia" (route) and 2 more
In rare cases, a valid address may no longer be found for a given value of filters.
Example request #7: address=Fuerteventura&components=locality:Almeria|administrative_area:AL|country:ES
Current result: "Calle Isla de Fuerteventura, 04007 Almería, Spain" (route)
Future result: ZERO_RESULTS
Regards,
The Google Maps API Team
希望这些信息对您有所帮助!
我正在使用 JavaScript API,但似乎也无法使其与 CURL API 一起工作。
问题:我想按县 + 州限制我的地理编码结果。 Google 地图地理编码 API 组件过滤不再识别格式为 "San Mateo County, CA"
的 administrativeArea
(以前有效),并且即使它已识别 "San Mateo County"
根据结果对象绝对是 administrative_area_level_2
。
例如,"https://maps.googleapis.com/maps/api/geocode/json?address=oakland&components=country:US|administrative_area:San+Mateo+County&key=YOUR_KEY_HERE"
return 是奥克兰的结果,即使它位于阿拉米达县,而不是圣马特奥县。使用 "San Mateo County, CA" 也被完全忽略。做 components=country:US|administrative_area:San+Mateo+County|adminstrative_area:CA
同样是行不通的(据我所知,无论如何用 JS API 是不可能的)。
(最终用例是当经过地理编码的地址实际上不是位置时处理结果,例如 "Homeless",它曾经 return 一个错误代码但最近开始 return ing "United States",部分原因是组件过滤似乎已更改。)
如果您想使用 API,这里有一个 JS fiddle 可以实现:https://jsfiddle.net/Lzj1uvfd/
2018 年 1 月,地理编码 API 的组件过滤发生了变化。此变化后,只有邮政编码和国家/地区过滤器作为严格过滤器,路线、地区和管理区域不是严格过滤器并且只是影响结果。
Google 向高级计划客户发送了有关此更改的通知。我在此处共享此电子邮件的副本
Hello Maps APIs Premium Plan customer,
Upcoming quality improvements in Google Maps geocoding services will require that the Component Filtering feature of the Geocoding API become less restrictive. This will become effective on January 16, 2018.
In the meantime, we are exposing a test parameter on the Geocoding API web service, so that you can see whether this change will affect your geocoding requests utilizing the Component Filtering feature. To use the parameter, add relax_components=true to your requests.
This test parameter will be available through January 16, 2018. After that date the parameter will be ignored, but requests using the parameter will still be accepted. There is no JavaScript equivalent.
The quality improvements will provide higher quality results for requests that seek to find valid addresses. However, the following statements will not longer apply to the Component Filtering feature: A query containing a component filter only returns the geocoding results that match the filter. If no matches are found, the geocoder returns a result that matches the filter itself. Component filtering will return a ZERO_RESULTS response only if you provide filters that exclude each other.
Filters for postal codes and country codes will continue to be enforced strictly for all queries.
Examples
An address that is not strictly contained by the locality filter (Spring Valley, NV), but it is near (in Paradise, NV), will be found instead of a less specific result matching the locality filter exactly:
Example request #1: address=4755+W+Flamingo+Rd&components=locality:Spring+Valley|country:US Current result: "W Flamingo Rd, Spring Valley, NV, USA" (route, partial_match) Future result: "4755 W Flamingo Rd, Las Vegas, NV 89103, USA" (premise)
A result in the different locality may be returned, instead of ZERO_RESULTS, when the locality filter would otherwise form a non-existent address:
Example request #2: components=locality:Montreal+Lake+Reserve|administrative_area:Saskatchewan|country:CA Current result: ZERO_RESULTS Future result: "Montreal Lake, SK S0J 1Y0, Canada" (establishment)
Example request #3: components=country:US|locality:friends+creek+conservation+area+cisco|administrative_area:IL Current result: ZERO_RESULTS Future result: "Friends Creek Conservation Area, 13734 Friends Creek Park Rd, Cisco, IL 61830, USA" (park)
Mutually exclusive filters no longer guarantee ZERO_RESULTS. This has been already the case since the old forward geocoder was permanently retired on April 3, 2017. The upcoming change will make this happen more often, e.g. when the administrative_area filter is favoured over the locality filter:
Example request #4: address=Müslistrasse+16&components=locality:Spreitenbach|administrative_area:ZH|country:CH Current result: ZERO_RESULTS Future result: "Muslistrasse 16, 8820 Wädenswil, Switzerland" (street_address)
An invalid address that was never found will no longer yield a result that matches the filter itself. This may result in either ZERO_RESULTS or one or more valid addresses that match some of the filters.
Example request #5: address=13+Rue+del+Percebe&components=locality:Sydney|country:AU Current result: "Sydney NSW 2000, Australia" (locality) Future result: ZERO_RESULTS
Example request #6: address=Sesame+St&components=locality:Sydney|country:AU Current result: "Sydney NSW 2000, Australia" (locality) Future result: "Sesame St, Mount Waverley VIC 3149, Australia" (route) and 2 more
In rare cases, a valid address may no longer be found for a given value of filters.
Example request #7: address=Fuerteventura&components=locality:Almeria|administrative_area:AL|country:ES Current result: "Calle Isla de Fuerteventura, 04007 Almería, Spain" (route) Future result: ZERO_RESULTS
Regards, The Google Maps API Team
希望这些信息对您有所帮助!