php – 如何在Google Maps API上查看区域内的地址

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 如何在Google Maps API上查看区域内的地址脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个地址字符串E.g. “12 Swiss Ave,Gonville,Wanganui,New Zealand”

如果地址位于新西兰的北岛或南岛,我需要解决这个问题.

如果我将地址传递给GOOGLE maps api,我收到的数据会在下面,不幸的是它虽然没有告诉我它在哪个岛.所以,我该如何检查?

{
    "results": [
        {
            "address_components": [
                {
                    "long_name": "12","short_name": "12","tyPEs": [
                        "street_number"
                    ]
                },{
                    "long_name": "Swiss Avenue","short_name": "Swiss Ave","types": [
                        "route"
                    ]
                },{
                    "long_name": "Gonville","short_name": "Gonville","types": [
                        "sublocalITy","political"
                    ]
                },{
                    "long_name": "Wanganui","short_name": "Wanganui","types": [
                        "locality",{
                    "long_name": "Manawatu-Wanganui","short_name": "Manawatu-Wanganui","types": [
                        "administrative_area_level_1",{
                    "long_name": "New Zealand","short_name": "NZ","types": [
                        "country",{
                    "long_name": "4501","short_name": "4501","types": [
                        "postal_code"
                    ]
                }
            ],"formatted_address": "12 Swiss Avenue,Wanganui 4501,New Zealand","geometry": {
                "location": {
                    "lat": -39.9444245,"lng": 175.0239575
                },"location_type": "ROOFTOP","viewport": {
                    "northeast": {
                        "lat": -39.9430755197085,"lng": 175.0253064802915
                    },"southwest": {
                        "lat": -39.9457734802915,"lng": 175.0226085197085
                    }
                }
            },"types": [
                "street_address"
            ]
        }
    ],"status": "OK"
}

解决方法

一种选择是获取两个岛的多边形,并在地理位置上进行多边形分析.

Example using FusionTables

Example using Polygons defined by KMLgeoxml3

Proof of concept(使用fusion Tables中的自然地球数据集和“州到岛”地图)

脚本宝典总结

以上是脚本宝典为你收集整理的php – 如何在Google Maps API上查看区域内的地址全部内容,希望文章能够帮你解决php – 如何在Google Maps API上查看区域内的地址所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。