Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在谷歌地图中检测具有多边形坐标的区域的完美标签位置?_Php_Google Maps - Fatal编程技术网

Php 如何在谷歌地图中检测具有多边形坐标的区域的完美标签位置?

Php 如何在谷歌地图中检测具有多边形坐标的区域的完美标签位置?,php,google-maps,Php,Google Maps,我有荷兰Lelystad的以下多边形坐标数据: 5.332127179145246,52.467626991535148 5.331970965072638,52.468478368585529 5.339985197333735,52.471922018564761 5.342336379785317,52.472026121459116 5.340052855673807,52.47186602708171 5.335255658432869,52.469806044919608 5.332

我有荷兰Lelystad的以下多边形坐标数据:

5.332127179145246,52.467626991535148 5.331970965072638,52.468478368585529 5.339985197333735,52.471922018564761 5.342336379785317,52.472026121459116 5.340052855673807,52.47186602708171 5.335255658432869,52.469806044919608 5.332037659207283,52.468415901281858 5.332127179145246,52.467626991535148

5.4194037152942,52.509520103500066 5.417731846729617,52.508395181243863 5.394371313350969,52.495109914111367 5.405798471819133,52.502103086672633 5.418249196750788,52.509046647264732 5.418107135676522,52.50974497898337 5.418618341699897,52.509346734432697 5.419599168443415,52.510020373033576 5.425552687134712,52.511094242592073 5.419981074116888,52.509928200797731 5.4194037152942,52.509520103500066

5.423804364580252,52.514285889994397 5.426384223487512,52.513658513379227 5.423104184882624,52.514210845328975 5.421983028853912,52.512540220137637 5.417038352606411,52.511665040794341 5.42201641128192,52.512794682855116 5.425759454051307,52.519714693413107 5.423201032331017,52.514395900130182 5.423804364580252,52.514285889994397
更像这样

当我计算多边形的中心时,检测到的值它不是放置区域名称的最佳位置,因为荷兰有很多“在水中”的土地,所以中心看起来很奇怪。

我想知道GMAP上是如何决定放置区域标签的

那么,有没有人知道如何检测出描述该地区的最佳坐标(比如GMAP)


谢谢。

我不确定谷歌是否计算出了标签的位置。 你觉得使用谷歌地点搜索怎么样? 就你而言:

您可以看到以下结果:

{
"html_attributions" : [],
"results" : [
   {
     "formatted_address" : "Lelystad, Netherlands",
     "geometry" : {
        "location" : {
           "lat" : 52.51853699999999,
           "lng" : 5.471422
        },
        "viewport" : {
           "northeast" : {
              "lat" : 52.6928127,
              "lng" : 5.6059639
           },
           "southwest" : {
              "lat" : 52.3843956,
              "lng" : 5.2584712
           }
        }
     },
     "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
     "id" : "95409359bba204dfa8c7fb61548871c897b55230",
     "name" : "Lelystad",
     "photos" : [
        {
           "height" : 534,
           "html_attributions" : [
              "\u003ca href=\"https://maps.google.com/maps/contrib/112598045772762555469/photos\"\u003eSiebe Swart\u003c/a\u003e"
           ],
           "photo_reference" : "CoQBcwAAANs7TjL2gnjoe1qO0QuXeZVFIBs-sv0PW3ZPsrmpomUzAXT87tUsGYV3gYns_eBgwilCiD-IP_FoyQGPm-4Pv-5EgZCoNs6vfnBF_hi3gVL2JFLD-JLdww6wEDDqdGR_1D-aV00oa0qMS6TSHcc-oJNjbso0fns2X8e9JmQBi9k2EhCUP-J5rYmxUS4jjW765w0wGhQCeY0T3YLcN86T9pL7MCUYKb_hgA",
           "width" : 800
        }
     ],
     "place_id" : "ChIJueLr9pApxkcRtRqmY2hULdM",
     "reference" : "CnRwAAAAeiiAOb9Vx74yWO3LnEO7_bKndCywQ3d45auMCRRrONBCR-ZAfnD3rjCZTyCxMrGsKNbkEUs2zqRmPmiVavV_c8TMf_G0eo4n_jdEHuBCbBoC9QLIpXcbh0qJblGVrMiPCwA5V3GitbS49HLz4cUOyxIQnhNTd-2xnMsL6tFk8cGszhoU3xvtgTVy4X466Vw0liTz-ZgZ3TI",
     "types" : [ "locality", "political" ]
  }
],
 "status" : "OK"
}
我认为您可以使用
几何体.position
几何体.viewport
也与您的不同。
希望这能有所帮助。

我不确定谷歌是否计算出标签的位置。 你觉得使用谷歌地点搜索怎么样? 就你而言:

您可以看到以下结果:

{
"html_attributions" : [],
"results" : [
   {
     "formatted_address" : "Lelystad, Netherlands",
     "geometry" : {
        "location" : {
           "lat" : 52.51853699999999,
           "lng" : 5.471422
        },
        "viewport" : {
           "northeast" : {
              "lat" : 52.6928127,
              "lng" : 5.6059639
           },
           "southwest" : {
              "lat" : 52.3843956,
              "lng" : 5.2584712
           }
        }
     },
     "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
     "id" : "95409359bba204dfa8c7fb61548871c897b55230",
     "name" : "Lelystad",
     "photos" : [
        {
           "height" : 534,
           "html_attributions" : [
              "\u003ca href=\"https://maps.google.com/maps/contrib/112598045772762555469/photos\"\u003eSiebe Swart\u003c/a\u003e"
           ],
           "photo_reference" : "CoQBcwAAANs7TjL2gnjoe1qO0QuXeZVFIBs-sv0PW3ZPsrmpomUzAXT87tUsGYV3gYns_eBgwilCiD-IP_FoyQGPm-4Pv-5EgZCoNs6vfnBF_hi3gVL2JFLD-JLdww6wEDDqdGR_1D-aV00oa0qMS6TSHcc-oJNjbso0fns2X8e9JmQBi9k2EhCUP-J5rYmxUS4jjW765w0wGhQCeY0T3YLcN86T9pL7MCUYKb_hgA",
           "width" : 800
        }
     ],
     "place_id" : "ChIJueLr9pApxkcRtRqmY2hULdM",
     "reference" : "CnRwAAAAeiiAOb9Vx74yWO3LnEO7_bKndCywQ3d45auMCRRrONBCR-ZAfnD3rjCZTyCxMrGsKNbkEUs2zqRmPmiVavV_c8TMf_G0eo4n_jdEHuBCbBoC9QLIpXcbh0qJblGVrMiPCwA5V3GitbS49HLz4cUOyxIQnhNTd-2xnMsL6tFk8cGszhoU3xvtgTVy4X466Vw0liTz-ZgZ3TI",
     "types" : [ "locality", "political" ]
  }
],
 "status" : "OK"
}
我认为您可以使用
几何体.position
几何体.viewport
也与您的不同。
希望这能有所帮助。

听起来是个解决方案。我会试试的,谢谢。听起来是个解决办法。我会试试的,谢谢。