使用jquery在geojson文件中查找多边形中的点
Posted
技术标签:
【中文标题】使用jquery在geojson文件中查找多边形中的点【英文标题】:Find point in polygon with geojson file using jquery 【发布时间】:2020-06-19 15:37:35 【问题描述】:我如何找出地理定位 latlng 是否在我写在 geojson 文件中的 polygens 中?使用 jquery
我的地理位置是[35.7040022,51.403697]
我的geojson文件是这样的:
"type":"FeatureCollection",
"crs":
"type":"name",
"properties":
"name":"urn:ogc:def:crs:OGC:1.3:CRS84"
,
"features":[
"type":"Feature",
"properties":
"id":51,
"osm_id":-6729033,
"name":"Area 14",
"type":"administrative",
"admin_leve":10,
"area":14
,
"geometry":
"type":"Polygon",
"coordinates":[[[51.44581686570847,35.66568829544207],[51.44616957619402,35.6711424836561],[51.44656654312831,35.67719974980349],[51.447495593276074,35.689315287926604],[51.447352430369875,35.689598344796764],[51.49173762515878,35.69273527205945],[51.49493783579041,35.692921769405075],[51.498832487099996,35.69211853162395],[51.49939549953615,35.692031359830935],[51.50009002403311,35.69204108283864],[51.50053745002452,35.69200562738819],[51.50418005750566,35.691423588031824],[51.505380765135264,35.6911920798662],[51.50557396800343,35.691107757920264],[51.50566466019574,35.69101798773727],[51.505726099546024,35.6908955281319],[51.505738840038845,35.69060643629146],[51.50578167156405,35.69015959703327],[51.519058522371864,35.67705776036371],[51.51424286754158,35.67370139487596],[51.51399677486441,35.673043247838756],[51.52324662411155,35.66912613302869],[51.52281721921196,35.667966161448504],[51.52246023395582,35.66771185450622],[51.521300932927886,35.66701012157253],[51.52031304181986,35.666025080311584],[51.51944065333757,35.665039368498384],[51.5186251779778,35.66391217015959],[51.518098291544305,35.66278379835438],[51.517629324061744,35.66170202993081],[51.517275440109785,35.66052579745846],[51.51691267134043,35.65798314713078],[51.51661494613969,35.65657104790313],[51.51637648099441,35.65539414487855],[51.51607967780305,35.65412336453841],[51.51549386659025,35.65280665136888],[51.51514056937148,35.651724547669176],[51.51461385057604,35.650596092044935],[51.51366527059392,35.64911584794449],[51.51260588185181,35.64848863013],[51.511540122863295,35.64777574926512],[51.51041552291451,35.64706228166699],[51.50950549968695,35.646242866812734],[51.508576198082096,35.64546192489404],[51.50779634581084,35.64454636961042],[51.50759233028759,35.6441633166354],[51.505468858937625,35.644364063216386],[51.50255556085162,35.6446253271383],[51.50240309403287,35.644637397078895],[51.50141042524004,35.64473697408857],[51.49926256255181,35.644940486697635],[51.49810384825713,35.64584715716393],[51.49746011809338,35.64706772990405],[51.50188048237001,35.660318764450096],[51.49085023306977,35.66276703454804],[51.49041353591445,35.66164805047438],[51.490117151818225,35.66078085877203],[51.48952815548224,35.65908469684584],[51.48917485826348,35.65800577826934],[51.48889398068812,35.657147387565345],[51.48853582196551,35.65604734659286],[51.46992321923551,35.65865168772791],[51.46907606028176,35.658801053242456],[51.468410537169774,35.659069944696256],[51.46734611928579,35.659288880007146],[51.46614666894166,35.65961057745096],[51.46577786520203,35.659621473925085],[51.465069762021926,35.65943832934073],[51.46322448603826,35.658863079325926],[51.46274562790995,35.65873877570186],[51.46226534485813,35.658456724660084],[51.46175287529809,35.6581147430106],[51.46132548205528,35.65847072243838],[51.460606566220086,35.65902862191362],[51.459720096140444,35.65940128132871],[51.458122840671706,35.65985675394717],[51.45728465035435,35.66008122131415],[51.45664092019063,35.66036888823106],[51.454764798803296,35.66153916955216],[51.45019959523983,35.66460744902784],[51.449105253961505,35.664755641075935],[51.44587453320233,35.665211029875366],[51.44594024732319,35.66532217391145],[51.44598182156295,35.66550305538195],[51.44581686570847,35.66568829544207]]]
,
"type":"Feature",
"properties":
"id":52,
"osm_id":-6729035,
"name":"Area 8",
"type":"administrative",
"admin_leve":10,
"area":8
,
"geometry":
"type":"Polygon",
"coordinates":[[[51.45887654140506,35.72863764556064],[51.4588845880321,35.7296044980917],[51.458948961048485,35.73002241978392],[51.45923863962216,35.730431875753965],[51.45929228380248,35.73091953488059],[51.459442487507346,35.73116344826295],[51.46125566080184,35.733131770585175],[51.463809123784614,35.73614498095702],[51.4659119756528,35.73893179612415],[51.46684722840888,35.740345655551465],[51.46719943598023,35.74030542241624],[51.469066253455054,35.740026891773766],[51.47195239417479,35.7395391488281],[51.47410889022328,35.73919959793056],[51.47517096117437,35.73900798762401],[51.47632967546908,35.73880766013815],[51.48102898948332,35.73783225806584],[51.48190867022137,35.73771038519371],[51.48441921785991,35.73736203329781],[51.4882708700062,35.73671754876281],[51.49006258562857,35.736447651480624],[51.490770688808674,35.73635184632735],[51.49191867426731,35.73606443086754],[51.4935387285127,35.735872820560985],[51.50234718673871,35.73478426279584],[51.535745969581,35.73041226210054],[51.537419668006685,35.729471644926406],[51.538363889399164,35.728461374136884],[51.5384067209244,35.726580055969606],[51.53862138146468,35.72489906528815],[51.53815459327694,35.72477057071251],[51.5342278392782,35.724491872432],[51.52844508045976,35.72414343671707],[51.52470063285506,35.72387345561583],[51.522790983855025,35.72376884946424],[51.52185749129862,35.72288916872617],[51.52170728759373,35.72278464639359],[51.52134259098665,35.7227236261385],[51.520795336528465,35.72274106049709],[51.52052719944595,35.72286301718827],[51.520280352397464,35.7232288872618],[51.519969299970704,35.72342913092862],[51.51962589339768,35.72342913092862],[51.51905726508639,35.72335076013394],[51.51493739203855,35.72209657596209],[51.505742779533335,35.71919593454987],[51.49702023581485,35.71655655705956],[51.48665618017887,35.713368332549436],[51.47727917746058,35.710476156859414],[51.4746506964444,35.709648527740086],[51.47238682821626,35.7089254209533],[51.47220443800322,35.70920428687187],[51.47132467344613,35.71017122322198],[51.46653969638146,35.71515418083959],[51.46502684667766,35.71729709820494],[51.4645333202188,35.71807225661041],[51.46386276796493,35.71934404277894],[51.462446561604736,35.721399620713214],[51.45975362375316,35.72566768580916],[51.45906169764618,35.72722236120978],[51.45893823221243,35.727775483000215],[51.45887654140506,35.72863764556064]]]
【问题讨论】:
【参考方案1】:OSM 始终返回序列纬度、经度,即使在数组/列表中也是如此。
【讨论】:
以上是关于使用jquery在geojson文件中查找多边形中的点的主要内容,如果未能解决你的问题,请参考以下文章
在 Google Maps API v3 中缩放到 geojson 多边形边界
是否可以使用 JavaScript 确定 GeoJSON 点是否在 GeoJSON 多边形内?