How to display linestring geojson and attach a popup? - popup

Using Leaflet, how can I show a linestring geojson and then attach a popup to it when selected.
Data below:
var aT0625124projectlimits = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
-76.60064603515116,
39.2066837882357
],
[
-76.6008535248809,
39.20570326707206
],
[
-76.60105527000235,
39.20472201267091
],
[
-76.60125126636073,
39.203740045211056
],
[
-76.60144150991955,
39.20275738488675
],
[
-76.60162599676089,
39.201774051907414
],
[
-76.6018047230853,
39.2007900664971
],
[
-76.60299312179492,
39.193882732157995
],
[
-76.60483513954705,
39.18255323412114
],
[
-76.60489278228994,
39.182128248360556
],
[
-76.60495754587669,
39.18170387663917
],
[
-76.60502941936728,
39.18128019065444
],
[
-76.60510839062077,
39.180857261989246
],
[
-76.60519444629716,
39.18043516209981
],
[
-76.60528757185979,
39.180013962303626
],
[
-76.6053877515777,
39.17959373376735
],
[
-76.60549496852833,
39.17917454749487
],
[
-76.6056092046005,
39.17875647431518
],
[
-76.60573044049717,
39.178339584870486
],
[
-76.60585865573897,
39.17792394960421
],
[
-76.60599382866758,
39.17750963874914
],
[
-76.60617652627226,
39.177121664458475
],
[
-76.60636490839762,
39.17673532510915
],
[
-76.60655895063945,
39.17635067077723
],
[
-76.60675862786046,
39.17596775132125
],
[
-76.60696391419323,
39.17558661637563
],
[
-76.60717478304375,
39.17520731534431
],
[
-76.60739120709482,
39.174829897394304
],
[
-76.60761315830962,
39.17445441144932
],
[
-76.60784060793526,
39.174080906183406
],
[
-76.60807352650656,
39.17370943001463
],
[
-76.60816228715875,
39.17349913171313
],
[
-76.60824421195713,
39.17328717211977
],
[
-76.60831924929514,
39.17307368473923
],
[
-76.60838735190463,
39.1728588040397
],
[
-76.60844847688598,
39.1726426653682
],
[
-76.60850258573491,
39.17242540486535
],
[
-76.60854964436678,
39.172207159379695
],
[
-76.60858962313806,
39.17198806638144
],
[
-76.60862249686508,
39.17176826387591
],
[
-76.60864824483978,
39.171547890316674
],
[
-76.60866685084282,
39.17132708451829
],
[
-76.60867830315375,
39.17110598556889
],
[
-76.60868259455846,
39.17088473274258
],
[
-76.6086797223537,
39.17066346541173
],
[
-76.60866968834873,
39.17044232295915
],
[
-76.60865249886422,
39.17022144469028
],
[
-76.60862816472833,
39.17000096974547
],
[
-76.60859670126976,
39.16978103701233
],
[
-76.60855812830823,
39.16956178503816
],
[
-76.60851247014186,
39.16934335194274
],
[
-76.60845975553198,
39.16912587533127
],
[
-76.60486484997955,
39.160119126302206
],
[
-76.6031119623949,
39.15567291444671
],
[
-76.60301746521947,
39.155492180230205
],
[
-76.6029171958774,
39.15531332546758
],
[
-76.6028112165009,
39.15513646100156
],
[
-76.60269959276044,
39.15496169644217
],
[
-76.60258239382402,
39.15478914009891
],
[
-76.60245969231435,
39.154618898913505
],
[
-76.60233156426384,
39.15445107839363
],
[
-76.60219808906741,
39.15428578254751
],
[
-76.60205934943343,
39.154123113819416
],
[
-76.60191543133236,
39.15396317302611
],
[
-76.60176642394347,
39.15380605929436
],
[
-76.60161241959973,
39.153651869999464
],
[
-76.60145351373039,
39.153500700704846
],
[
-76.60128980480201,
39.1533526451028
],
[
-76.60112139425733,
39.15320779495642
],
[
-76.60096054494588,
39.153103629654076
],
[
-76.60080411502742,
39.15299549255137
],
[
-76.60065226750757,
39.15288349631307
],
[
-76.60050516061695,
39.15276775762517
],
[
-76.60036294764629,
39.15264839707341
],
[
-76.60022577678663,
39.15252553901769
],
[
-76.60009379097497,
39.15239931146259
],
[
-76.59996712774533,
39.152269845923996
],
[
-76.59984591908535,
39.15213727729223
],
[
-76.59973029129885,
39.15200174369145
],
[
-76.5996203648742,
39.151863386335854
],
[
-76.59951625435865,
39.1517223493826
],
[
-76.5994180682392,
39.15157877978164
],
[
-76.5993259088293,
39.15143282712265
],
[
-76.59923987216239,
39.15128464347925
],
[
-76.59916004789181,
39.15113438325055
],
[
-76.59908651919733,
39.15098220300037
],
[
-76.59901936269851,
39.1508282612941
],
[
-76.59895864837488,
39.150672718533535
],
[
-76.59890443949291,
39.15051573678981
],
[
-76.59885679254026,
39.15035747963449
],
[
-76.59881575716676,
39.15019811196923
],
[
-76.59878137613276,
39.15003779985392
],
[
-76.59875368526457,
39.14987671033372
],
[
-76.59873271341702,
39.14971501126499
],
[
-76.59871354523216,
39.14954117895811
],
[
-76.5987007594645,
39.1493669937907
],
[
-76.59869436645675,
39.14919259666234
],
[
-76.59869437138029,
39.14901812864508
],
[
-76.59870077423113,
39.14884373086941
],
[
-76.59871356982994,
39.148669544410005
],
[
-76.59873274782606,
39.14849571017167
],
[
-76.59875829270608,
39.14832236877533
],
[
-76.59879018380626,
39.148149660444254
],
[
-76.59882839532929,
39.147977724890644
],
[
-76.59887289636515,
39.14780670120258
],
[
-76.5989236509161,
39.147636727731495
],
[
-76.59898061792586,
39.14746794198023
],
[
-76.59904375131272,
39.14730048049179
],
[
-76.59911300000688,
39.14713447873889
],
[
-76.59915824935317,
39.14697040897072
],
[
-76.59919686808175,
39.14680532269757
],
[
-76.59922881850031,
39.146639381038824
],
[
-76.59925406942494,
39.14647274594983
],
[
-76.59927259621044,
39.14630558006388
],
[
-76.59928438077446,
39.14613804653345
],
[
-76.59928941161517,
39.145970308871036
],
[
-76.59928768382242,
39.145802530789496
],
[
-76.59927919908253,
39.14563487604232
],
[
-76.5992639656767,
39.14546750826381
],
[
-76.5992419984729,
39.14530059080933
],
[
-76.59921331891135,
39.14513428659586
],
[
-76.59917795498362,
39.14496875794305
],
[
-76.59913594120529,
39.144804166414616
],
[
-76.5990873185822,
39.14464067266083
],
[
-76.59903213457062,
39.14447843626152
],
[
-76.5989704430307,
39.144317615570394
],
[
-76.59890230417403,
39.14415836756038
],
[
-76.59882778450488,
39.144000847670455
],
[
-76.59871039511414,
39.14381296339047
],
[
-76.59858666171772,
39.143627543371956
],
[
-76.59845667027793,
39.14344471645316
],
[
-76.5983205111047,
39.143264609671554
],
[
-76.59817827879294,
39.14308734817545
],
[
-76.59803007215685,
39.14291305513707
],
[
-76.59787599416107,
39.142741851666834
],
[
-76.59771615184947,
39.14257385672924
],
[
-76.5975506562705,
39.14240918706008
],
[
-76.59737962240017,
39.14224795708532
],
[
-76.5972031690622,
39.14209027884153
],
[
-76.59702141884533,
39.141936261897946
],
[
-76.58825103712245,
39.1346544258951
],
[
-76.58045276453394,
39.127224334409114
],
[
-76.57774321632357,
39.1244032753277
],
[
-76.57760321539834,
39.12426195154371
],
[
-76.57745790588315,
39.124123890127386
],
[
-76.57730741404438,
39.12398921106639
],
[
-76.57715187065149,
39.123858031409476
],
[
-76.57699141086356,
39.12373046516474
],
[
-76.57682617411169,
39.123606623200494
],
[
-76.57665630397794,
39.123486613148806
],
[
-76.57648194807055,
39.12337053931196
],
[
-76.57630325789565,
39.12325850257174
],
[
-76.5761203887256,
39.123150600301656
],
[
-76.57593349946411,
39.123046926282356
],
[
-76.57574275250816,
39.12294757061994
],
[
-76.5755483136068,
39.12285261966775
],
[
-76.57535035171726,
39.122762155951136
],
[
-76.575149038858,
39.12267625809573
],
[
-76.57494454995934,
39.122595000759134
],
[
-76.57473706271138,
39.12251845456585
],
[
-76.57452675740966,
39.122446686045976
],
[
-76.57431381679844,
39.12237975757727
],
[
-76.5740984259119,
39.12231772733094
],
[
-76.57388077191345,
39.12226064922102
],
[
-76.57366104393296,
39.122208572857474
],
[
-76.57343943290253,
39.12216154350309
],
[
-76.57321613139048,
39.12211960203402
],
[
-76.57299133343412,
39.12208278490434
],
[
-76.57276523437105,
39.12205112411425
],
[
-76.57253803066949,
39.122024647182286
],
[
-76.57183568648361,
39.121947169632264
],
[
-76.57113247288498,
39.121874593548064
],
[
-76.57042844670683,
39.12180692481037
],
[
-76.56972366484807,
39.12174416890229
],
[
-76.56901818426863,
39.12168633090883
],
[
-76.568312061985,
39.12163341551655
],
[
-76.56760535506547,
39.121585427013116
],
[
-76.56689812062557,
39.12154236928701
],
[
-76.56619041582351,
39.121504245827175
],
[
-76.5654822978555,
39.121471059722715
],
[
-76.56477382395111,
39.1214428136627
],
[
-76.5640650513687,
39.121419509935905
],
[
-76.56335603739079,
39.12140115043062
],
[
-76.56264683931936,
39.12138773663452
],
[
-76.56193751447134,
39.12137926963451
],
[
-76.561446305482,
39.12137129928427
],
[
-76.56095500521809,
39.12136820885034
],
[
-76.5604636942228,
39.12136999884
],
[
-76.55997245304108,
39.121376668959456
],
[
-76.5594813622064,
39.12138821811379
],
[
-76.5589905022276,
39.12140464440728
],
[
-76.55849995357568,
39.12142594514358
],
[
-76.55800979667058,
39.12145211682627
],
[
-76.55752011186806,
39.12148315515939
],
[
-76.55703097944644,
39.12151905504809
],
[
-76.55654247959352,
39.121559810599564
],
[
-76.55605469239333,
39.121605415123994
],
[
-76.55556769781317,
39.121655861135615
],
[
-76.55521308611485,
39.1216939692341
],
[
-76.55485762075449,
39.121726944806795
],
[
-76.55450142514484,
39.12175477641226
],
[
-76.5541446229521,
39.121777454393836
],
[
-76.55378733805308,
39.12179497088303
],
[
-76.55342969449222,
39.12180731980219
],
[
-76.55307181643845,
39.12181449686667
],
[
-76.55271382814212,
39.121816499586274
],
[
-76.55235585389184,
39.121813327266125
],
[
-76.55199801797136,
39.12180498100691
],
[
-76.5516404446164,
39.121791463704504
],
[
-76.55128325797153,
39.121772780048936
],
[
-76.55092658204705,
39.12174893652283
],
[
-76.55057054067593,
39.12171994139908
],
[
-76.55021525747088,
39.121685804738036
],
[
-76.5498608557813,
39.12164653838404
],
[
-76.54950745865065,
39.12160215596124
],
[
-76.53496304390565,
39.12008273370951
],
[
-76.52618315525284,
39.119164425733
],
[
-76.52569014311455,
39.11910232710676
],
[
-76.52519606567124,
39.11904555304786
],
[
-76.52470101845684,
39.118994114546915
],
[
-76.52420509719285,
39.11894802156168
],
[
-76.52370839776971,
39.118907283015105
],
[
-76.52321101622839,
39.11887190679364
],
[
-76.5227130487417,
39.11884189974564
],
[
-76.52221459159581,
39.11881726768008
],
[
-76.52171574117148,
39.118798015365414
],
[
-76.52121659392559,
39.11878414652864
],
[
-76.52071724637237,
39.118775663854606
],
[
-76.5202177950648,
39.11877256898544
],
[
-76.51971833657592,
39.11877486252028
],
[
-76.51921896748017,
39.11878254401512
],
[
-76.51871978433466,
39.11879561198292
],
[
-76.51822088366062,
39.118814063893886
],
[
-76.51123310027648,
39.11898002522117
],
[
-76.5107994396434,
39.11897479749558
],
[
-76.51036593336157,
39.11896441021431
],
[
-76.50993268340919,
39.11894886581861
],
[
-76.50949979170417,
39.11892816796172
],
[
-76.50911835443813,
39.118905638880555
],
[
-76.50873734489493,
39.118879108572635
],
[
-76.50835683280118,
39.11884858188862
],
[
-76.50797688779258,
39.11881406440987
]
]
},
"properties": {
"OBJECTID": 17,
"Contract_N": "AT0625124",
"SHAPE_Leng": "53224.7785428",
"Completion": "100"
}
}
]
}

This can simply be done in one html file. You have to use L.geoJson function. Check out the code snippet:
var map = L.map('mapid').setView([39.10, -76.60], 12);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpandmbXliNDBjZWd2M2x6bDk3c2ZtOTkifQ._QA7i5Mpkd_m30IGElHziw', {
id: 'mapbox.streets'
}).addTo(map);
var aT0625124projectlimits = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[-76.60064603515116,
39.2066837882357
],
[-76.6008535248809,
39.20570326707206
],
[-76.60105527000235,
39.20472201267091
],
[-76.60125126636073,
39.203740045211056
],
[-76.60144150991955,
39.20275738488675
],
[-76.60162599676089,
39.201774051907414
],
[-76.6018047230853,
39.2007900664971
],
[-76.60299312179492,
39.193882732157995
],
[-76.60483513954705,
39.18255323412114
],
[-76.60489278228994,
39.182128248360556
],
[-76.60495754587669,
39.18170387663917
],
[-76.60502941936728,
39.18128019065444
],
[-76.60510839062077,
39.180857261989246
],
[-76.60519444629716,
39.18043516209981
],
[-76.60528757185979,
39.180013962303626
],
[-76.6053877515777,
39.17959373376735
],
[-76.60549496852833,
39.17917454749487
],
[-76.6056092046005,
39.17875647431518
],
[-76.60573044049717,
39.178339584870486
],
[-76.60585865573897,
39.17792394960421
],
[-76.60599382866758,
39.17750963874914
],
[-76.60617652627226,
39.177121664458475
],
[-76.60636490839762,
39.17673532510915
],
[-76.60655895063945,
39.17635067077723
],
[-76.60675862786046,
39.17596775132125
],
[-76.60696391419323,
39.17558661637563
],
[-76.60717478304375,
39.17520731534431
],
[-76.60739120709482,
39.174829897394304
],
[-76.60761315830962,
39.17445441144932
],
[-76.60784060793526,
39.174080906183406
],
[-76.60807352650656,
39.17370943001463
],
[-76.60816228715875,
39.17349913171313
],
[-76.60824421195713,
39.17328717211977
],
[-76.60831924929514,
39.17307368473923
],
[-76.60838735190463,
39.1728588040397
],
[-76.60844847688598,
39.1726426653682
],
[-76.60850258573491,
39.17242540486535
],
[-76.60854964436678,
39.172207159379695
],
[-76.60858962313806,
39.17198806638144
],
[-76.60862249686508,
39.17176826387591
],
[-76.60864824483978,
39.171547890316674
],
[-76.60866685084282,
39.17132708451829
],
[-76.60867830315375,
39.17110598556889
],
[-76.60868259455846,
39.17088473274258
],
[-76.6086797223537,
39.17066346541173
],
[-76.60866968834873,
39.17044232295915
],
[-76.60865249886422,
39.17022144469028
],
[-76.60862816472833,
39.17000096974547
],
[-76.60859670126976,
39.16978103701233
],
[-76.60855812830823,
39.16956178503816
],
[-76.60851247014186,
39.16934335194274
],
[-76.60845975553198,
39.16912587533127
],
[-76.60486484997955,
39.160119126302206
],
[-76.6031119623949,
39.15567291444671
],
[-76.60301746521947,
39.155492180230205
],
[-76.6029171958774,
39.15531332546758
],
[-76.6028112165009,
39.15513646100156
],
[-76.60269959276044,
39.15496169644217
],
[-76.60258239382402,
39.15478914009891
],
[-76.60245969231435,
39.154618898913505
],
[-76.60233156426384,
39.15445107839363
],
[-76.60219808906741,
39.15428578254751
],
[-76.60205934943343,
39.154123113819416
],
[-76.60191543133236,
39.15396317302611
],
[-76.60176642394347,
39.15380605929436
],
[-76.60161241959973,
39.153651869999464
],
[-76.60145351373039,
39.153500700704846
],
[-76.60128980480201,
39.1533526451028
],
[-76.60112139425733,
39.15320779495642
],
[-76.60096054494588,
39.153103629654076
],
[-76.60080411502742,
39.15299549255137
],
[-76.60065226750757,
39.15288349631307
],
[-76.60050516061695,
39.15276775762517
],
[-76.60036294764629,
39.15264839707341
],
[-76.60022577678663,
39.15252553901769
],
[-76.60009379097497,
39.15239931146259
],
[-76.59996712774533,
39.152269845923996
],
[-76.59984591908535,
39.15213727729223
],
[-76.59973029129885,
39.15200174369145
],
[-76.5996203648742,
39.151863386335854
],
[-76.59951625435865,
39.1517223493826
],
[-76.5994180682392,
39.15157877978164
],
[-76.5993259088293,
39.15143282712265
],
[-76.59923987216239,
39.15128464347925
],
[-76.59916004789181,
39.15113438325055
],
[-76.59908651919733,
39.15098220300037
],
[-76.59901936269851,
39.1508282612941
],
[-76.59895864837488,
39.150672718533535
],
[-76.59890443949291,
39.15051573678981
],
[-76.59885679254026,
39.15035747963449
],
[-76.59881575716676,
39.15019811196923
],
[-76.59878137613276,
39.15003779985392
],
[-76.59875368526457,
39.14987671033372
],
[-76.59873271341702,
39.14971501126499
],
[-76.59871354523216,
39.14954117895811
],
[-76.5987007594645,
39.1493669937907
],
[-76.59869436645675,
39.14919259666234
],
[-76.59869437138029,
39.14901812864508
],
[-76.59870077423113,
39.14884373086941
],
[-76.59871356982994,
39.148669544410005
],
[-76.59873274782606,
39.14849571017167
],
[-76.59875829270608,
39.14832236877533
],
[-76.59879018380626,
39.148149660444254
],
[-76.59882839532929,
39.147977724890644
],
[-76.59887289636515,
39.14780670120258
],
[-76.5989236509161,
39.147636727731495
],
[-76.59898061792586,
39.14746794198023
],
[-76.59904375131272,
39.14730048049179
],
[-76.59911300000688,
39.14713447873889
],
[-76.59915824935317,
39.14697040897072
],
[-76.59919686808175,
39.14680532269757
],
[-76.59922881850031,
39.146639381038824
],
[-76.59925406942494,
39.14647274594983
],
[-76.59927259621044,
39.14630558006388
],
[-76.59928438077446,
39.14613804653345
],
[-76.59928941161517,
39.145970308871036
],
[-76.59928768382242,
39.145802530789496
],
[-76.59927919908253,
39.14563487604232
],
[-76.5992639656767,
39.14546750826381
],
[-76.5992419984729,
39.14530059080933
],
[-76.59921331891135,
39.14513428659586
],
[-76.59917795498362,
39.14496875794305
],
[-76.59913594120529,
39.144804166414616
],
[-76.5990873185822,
39.14464067266083
],
[-76.59903213457062,
39.14447843626152
],
[-76.5989704430307,
39.144317615570394
],
[-76.59890230417403,
39.14415836756038
],
[-76.59882778450488,
39.144000847670455
],
[-76.59871039511414,
39.14381296339047
],
[-76.59858666171772,
39.143627543371956
],
[-76.59845667027793,
39.14344471645316
],
[-76.5983205111047,
39.143264609671554
],
[-76.59817827879294,
39.14308734817545
],
[-76.59803007215685,
39.14291305513707
],
[-76.59787599416107,
39.142741851666834
],
[-76.59771615184947,
39.14257385672924
],
[-76.5975506562705,
39.14240918706008
],
[-76.59737962240017,
39.14224795708532
],
[-76.5972031690622,
39.14209027884153
],
[-76.59702141884533,
39.141936261897946
],
[-76.58825103712245,
39.1346544258951
],
[-76.58045276453394,
39.127224334409114
],
[-76.57774321632357,
39.1244032753277
],
[-76.57760321539834,
39.12426195154371
],
[-76.57745790588315,
39.124123890127386
],
[-76.57730741404438,
39.12398921106639
],
[-76.57715187065149,
39.123858031409476
],
[-76.57699141086356,
39.12373046516474
],
[-76.57682617411169,
39.123606623200494
],
[-76.57665630397794,
39.123486613148806
],
[-76.57648194807055,
39.12337053931196
],
[-76.57630325789565,
39.12325850257174
],
[-76.5761203887256,
39.123150600301656
],
[-76.57593349946411,
39.123046926282356
],
[-76.57574275250816,
39.12294757061994
],
[-76.5755483136068,
39.12285261966775
],
[-76.57535035171726,
39.122762155951136
],
[-76.575149038858,
39.12267625809573
],
[-76.57494454995934,
39.122595000759134
],
[-76.57473706271138,
39.12251845456585
],
[-76.57452675740966,
39.122446686045976
],
[-76.57431381679844,
39.12237975757727
],
[-76.5740984259119,
39.12231772733094
],
[-76.57388077191345,
39.12226064922102
],
[-76.57366104393296,
39.122208572857474
],
[-76.57343943290253,
39.12216154350309
],
[-76.57321613139048,
39.12211960203402
],
[-76.57299133343412,
39.12208278490434
],
[-76.57276523437105,
39.12205112411425
],
[-76.57253803066949,
39.122024647182286
],
[-76.57183568648361,
39.121947169632264
],
[-76.57113247288498,
39.121874593548064
],
[-76.57042844670683,
39.12180692481037
],
[-76.56972366484807,
39.12174416890229
],
[-76.56901818426863,
39.12168633090883
],
[-76.568312061985,
39.12163341551655
],
[-76.56760535506547,
39.121585427013116
],
[-76.56689812062557,
39.12154236928701
],
[-76.56619041582351,
39.121504245827175
],
[-76.5654822978555,
39.121471059722715
],
[-76.56477382395111,
39.1214428136627
],
[-76.5640650513687,
39.121419509935905
],
[-76.56335603739079,
39.12140115043062
],
[-76.56264683931936,
39.12138773663452
],
[-76.56193751447134,
39.12137926963451
],
[-76.561446305482,
39.12137129928427
],
[-76.56095500521809,
39.12136820885034
],
[-76.5604636942228,
39.12136999884
],
[-76.55997245304108,
39.121376668959456
],
[-76.5594813622064,
39.12138821811379
],
[-76.5589905022276,
39.12140464440728
],
[-76.55849995357568,
39.12142594514358
],
[-76.55800979667058,
39.12145211682627
],
[-76.55752011186806,
39.12148315515939
],
[-76.55703097944644,
39.12151905504809
],
[-76.55654247959352,
39.121559810599564
],
[-76.55605469239333,
39.121605415123994
],
[-76.55556769781317,
39.121655861135615
],
[-76.55521308611485,
39.1216939692341
],
[-76.55485762075449,
39.121726944806795
],
[-76.55450142514484,
39.12175477641226
],
[-76.5541446229521,
39.121777454393836
],
[-76.55378733805308,
39.12179497088303
],
[-76.55342969449222,
39.12180731980219
],
[-76.55307181643845,
39.12181449686667
],
[-76.55271382814212,
39.121816499586274
],
[-76.55235585389184,
39.121813327266125
],
[-76.55199801797136,
39.12180498100691
],
[-76.5516404446164,
39.121791463704504
],
[-76.55128325797153,
39.121772780048936
],
[-76.55092658204705,
39.12174893652283
],
[-76.55057054067593,
39.12171994139908
],
[-76.55021525747088,
39.121685804738036
],
[-76.5498608557813,
39.12164653838404
],
[-76.54950745865065,
39.12160215596124
],
[-76.53496304390565,
39.12008273370951
],
[-76.52618315525284,
39.119164425733
],
[-76.52569014311455,
39.11910232710676
],
[-76.52519606567124,
39.11904555304786
],
[-76.52470101845684,
39.118994114546915
],
[-76.52420509719285,
39.11894802156168
],
[-76.52370839776971,
39.118907283015105
],
[-76.52321101622839,
39.11887190679364
],
[-76.5227130487417,
39.11884189974564
],
[-76.52221459159581,
39.11881726768008
],
[-76.52171574117148,
39.118798015365414
],
[-76.52121659392559,
39.11878414652864
],
[-76.52071724637237,
39.118775663854606
],
[-76.5202177950648,
39.11877256898544
],
[-76.51971833657592,
39.11877486252028
],
[-76.51921896748017,
39.11878254401512
],
[-76.51871978433466,
39.11879561198292
],
[-76.51822088366062,
39.118814063893886
],
[-76.51123310027648,
39.11898002522117
],
[-76.5107994396434,
39.11897479749558
],
[-76.51036593336157,
39.11896441021431
],
[-76.50993268340919,
39.11894886581861
],
[-76.50949979170417,
39.11892816796172
],
[-76.50911835443813,
39.118905638880555
],
[-76.50873734489493,
39.118879108572635
],
[-76.50835683280118,
39.11884858188862
],
[-76.50797688779258,
39.11881406440987
]
]
},
"properties": {
"OBJECTID": 17,
"Contract_N": "AT0625124",
"SHAPE_Leng": "53224.7785428",
"Completion": "100"
}
}]
}
L.geoJson(aT0625124projectlimits, {
style: function(feature) {
return {
stroke: true,
color: "red",
weight: 5
};
},
onEachFeature: function(feature, layer) {
layer.bindPopup("id: " + feature.properties.OBJECTID + "<br>" +
"Contract_N: " + feature.properties.Contract_N);
}
}).addTo(map);
<html>
<head>
<title>Leaflet polyline with popup</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
<link rel="stylesheet" href="https://unpkg.com/leaflet#1.0.3/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet#1.0.3/dist/leaflet.js"></script>
</head>
<body>
<div id="mapid" style="width: 100%; height: 800px;"></div>
</body>
</html>
Or check out the example on codepen: http://codepen.io/dagmara223/pen/NdJJBJ

Related

How to handle selected item for dynamically generated ListView in Flutter

final variationMap = HashMap<String, List>();
In this map, I have
key -> ["color"] = value -> ["White", "Black"];
key -> ["ram"] = value -> ["128GB", "256GB"];
Based on this information I have designed the below UI.
**I want -> If I select white, white will be selected and black will remain unselected. And If I select black white will become unselected.
The same goes for Ram. Selecting one will make the other unselected. Two list view selections will work independently. **
For a single list view, we can achieve this using a selectedIndex variable.
Here is the API response. Here attribute value can be multiple. But I need to show one value in UI. So after some logic, I store the label and value into a map.
"productVariation": [
{
"price": 406089.25,
"qty": 449,
"variationAttribute": [
{
"attribute_value": "White",
"attributeDetails": {
"attributeLabel": [
{
"label": "Color"
}
]
}
},
{
"attribute_value": "128GB",
"attributeDetails": {
"attributeLabel": [
{
"label": "Ram"
}
]
}
}
]
},
{
"price": 292561.69,
"qty": 246,
"variationAttribute": [
{
"attribute_value": "White",
"attributeDetails": {
"attributeLabel": [
{
"label": "Color"
}
]
}
},
{
"attribute_value": "256GB",
"attributeDetails": {
"attributeLabel": [
{
"label": "Ram"
}
]
}
}
]
},
{
"price": 951456.88,
"qty": 828,
"variationAttribute": [
{
"attribute_value": "Black",
"attributeDetails": {
"attributeLabel": [
{
"label": "Color"
}
]
}
},
{
"attribute_value": "128GB",
"attributeDetails": {
"attributeLabel": [
{
"label": "Ram"
}
]
}
}
]
},
{
"price": 930735.09,
"qty": 321,
"variationAttribute": [
{
"attribute_value": "Black",
"attributeDetails": {
"attributeLabel": [
{
"label": "Color"
}
]
}
},
{
"attribute_value": "256GB",
"attributeDetails": {
"attributeLabel": [
{
"label": "Ram"
}
]
}
}
]
}
]
Here is the UI code. This code is for the bottom sheet dialog.
variationView() {
final widgets = <Widget>[];
var i = 1; // maintain vertical dot line between variation
for (var key in widget.controller.variationMap.keys) {
final list = widget.controller.variationMap[key];
widgets.add(
GlobalText(
str: "Select $key",
fontSize: 18,
fontWeight: FontWeight.w300,
),
);
widgets.add(
const SizedBox(
height: 20,
),
);
widgets.add(
SizedBox(
height: 60,
child: ListView.builder(
itemCount: list!.length,
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemBuilder: (ctx, index) {
return GestureDetector(
onTap: () {
setState(() {
isSelectedIndex = index;
isSelectedIndexForListView = i;
});
},
child:Container(
margin: EdgeInsets.only(right: 11),
padding: EdgeInsets.all(4),
width: 60,
height: 55,
decoration: BoxDecoration(
color: Color(0xfff8f8f8),
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: isSelectedIndex == index && isSelectedIndexForListView == i
? Colors.black
: Color(0xffe2e2e2),
width: 1,
),
),
child: Center(
child: GlobalText(
str: list[index],
color: Color(0xff535960),
fontSize: 13,
fontWeight: FontWeight.w400,
maxLines: 2,
),
),
),
);
},
),
),
);
if (i < widget.controller.variationMap.keys.length) {
widgets.add(
const SizedBox(
height: 30,
),
);
}
i++;
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: widgets,
);
}
I have tried multiple ways but failed to hold or manage the state of the selected item.
In this code, I have tried to hold the index of the list view and another for item selected index. but When I select a ram, So same index color also goes selected and vice versa.
I have also tried using Unique key. But failed to solve the problem.
First you can create a model class for Value which will have to fields one for the value name another for checking if it's selected or not.
class Value{
String valueName;
bool isSelected;
}
Then create another class which will have one field of String type that is the label and another field of type List of Value object.
class Model {
String label;
List<Value> valueList;
}
From your controller or viewmodel class or the class you are using to update the states you will just have to update the value of isSelected field.

How to set center for geojson layer in leaftet?

I added geojson Layer in leaflet.But I want to know can we change position of entire geojson layer in map.As of now Geojson layer displaying in [0,0] coordinates.
sample geojson and displaying code
var geojson={
"type": "FeatureCollection",
"name": "entities",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4269" } },
"features": [
{ "type": "Feature", "properties": { "Layer": "ELEV-FURN-MOVABLE # 1", "SubClasses": "AcDbEntity:AcDbBlockReference", "ExtendedEntity": " 100 1", "Linetype": "ByBlock", "EntityHandle": "A3479" }, "geometry": { "type": "MultiLineString", "coordinates": [ [ [ 28.906798251155124, 765.665582924624914, 0.0 ], [ 94.906798251162414, 765.665582924624914, 0.0 ] ], [ [ 94.906798251162414, 765.665582924624914, 0.0 ], [ 94.906798251162414, 783.665582924625596, 0.0 ] ], [ [ 94.906798251162414, 783.665582924625596, 0.0 ], [ 28.906798251155124, 783.665582924625596, 0.0 ] ], [ [ 28.906798251155124, 783.665582924625596, 0.0 ], [ 28.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 29.906798251155124, 783.665582924625596, 0.0 ], [ 29.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 30.906798251155124, 783.665582924625596, 0.0 ], [ 30.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 31.90679825115512, 783.665582924625596, 0.0 ], [ 31.90679825115512, 765.665582924624914, 0.0 ] ], [ [ 45.906798251155124, 783.665582924625596, 0.0 ], [ 45.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 44.906798251155131, 783.665582924625596, 0.0 ], [ 44.906798251155131, 765.665582924624914, 0.0 ] ], [ [ 43.906798251155124, 783.665582924625596, 0.0 ], [ 43.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 42.906798251155124, 783.665582924625596, 0.0 ], [ 42.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 41.906798251155124, 783.665582924625596, 0.0 ], [ 41.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 40.906798251155124, 783.665582924625596, 0.0 ], [ 40.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 39.906798251155124, 783.665582924625596, 0.0 ], [ 39.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 38.906798251155124, 783.665582924625596, 0.0 ], [ 38.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 37.906798251155124, 783.665582924625596, 0.0 ], [ 37.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 36.906798251155124, 783.665582924625596, 0.0 ], [ 36.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 35.906798251155124, 783.665582924625596, 0.0 ], [ 35.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 34.906798251155124, 783.665582924625596, 0.0 ], [ 34.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 33.906798251155124, 783.665582924625596, 0.0 ], [ 33.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 32.906798251155124, 783.665582924625596, 0.0 ], [ 32.906798251155124, 765.665582924624914, 0.0 ] ], [ [ 79.9067982511624, 783.665582924625596, 0.0 ], [ 79.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 80.9067982511624, 783.665582924625596, 0.0 ], [ 80.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 81.9067982511624, 783.665582924625596, 0.0 ], [ 81.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 93.9067982511624, 783.665582924625596, 0.0 ], [ 93.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 92.9067982511624, 783.665582924625596, 0.0 ], [ 92.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 91.9067982511624, 783.665582924625596, 0.0 ], [ 91.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 90.9067982511624, 783.665582924625596, 0.0 ], [ 90.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 89.906798251162414, 783.665582924625596, 0.0 ], [ 89.906798251162414, 765.665582924624914, 0.0 ] ], [ [ 88.9067982511624, 783.665582924625596, 0.0 ], [ 88.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 87.9067982511624, 783.665582924625596, 0.0 ], [ 87.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 86.9067982511624, 783.665582924625596, 0.0 ], [ 86.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 85.9067982511624, 783.665582924625596, 0.0 ], [ 85.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 84.9067982511624, 783.665582924625596, 0.0 ], [ 84.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 83.9067982511624, 783.665582924625596, 0.0 ], [ 83.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 82.9067982511624, 783.665582924625596, 0.0 ], [ 82.9067982511624, 765.665582924624914, 0.0 ] ], [ [ 48.181739517756796, 781.409011031471891, 0.0 ], [ 78.195410763022664, 781.409011031471891, 0.0 ], [ 78.195410763022664, 778.052665054441604, 0.0 ], [ 48.181739517756796, 778.052665054441604, 0.0 ], [ 48.181739517756796, 781.409011031471891, 0.0 ] ], [ [ 48.181739517756796, 776.302229679291486, 0.0 ], [ 78.195410763022664, 776.302229679291486, 0.0 ], [ 78.195410763022664, 772.945883702261199, 0.0 ], [ 48.181739517756796, 772.945883702261199, 0.0 ], [ 48.181739517756796, 776.302229679291486, 0.0 ] ], [ [ 48.181739517756796, 767.922154817778619, 0.0 ], [ 78.195410763022664, 767.922154817778619, 0.0 ], [ 78.195410763022664, 771.278500794808906, 0.0 ], [ 48.181739517756796, 771.278500794808906, 0.0 ], [ 48.181739517756796, 767.922154817778619, 0.0 ] ] ] } }
]}
let layer = L.geoJSON(geojson, {
onEachFeature: onEachFeature,
style: myStyle
}).addTo(this.map);
fitBounds is the method to which you specify layer bouds.
In your case it's called layer. Below is my example of geojson.
The map is set somewhere to London, after three seconds I set the center of my geojson.
// config map
let config = {
minZoom: 1,
maxZomm: 18,
};
// magnification with which the map will start
const zoom = 18;
// co-ordinates
const lat = 51.51527266031298;
const lon = -0.132200717926025;
// calling map
const map = L.map('map', config).setView([lat, lon], zoom);
// Used to load and display tile layers on the map
// Most tile servers require attribution, which you can set under `Layer`
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
var geojson = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
"name": "place"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
16.54541015625,
49.724479188712984
],
[
24.01611328125,
49.724479188712984
],
[
24.01611328125,
53.74871079689897
],
[
16.54541015625,
53.74871079689897
],
[
16.54541015625,
49.724479188712984
]
]
]
}
}]
}
let layer = L.geoJSON(geojson).addTo(map);
setTimeout(() => {
map.fitBounds(layer.getBounds());
}, 3000);
* {
margin: 0;
padding: 0
}
html {
height: 100%
}
body,
html,
#map {
height: 100%;
margin: 0;
padding: 0
}
body {
position: relative;
height: 100%;
min-height: 100%;
padding: 0;
margin: 0;
}
</style>
<link rel="stylesheet" href="https://unpkg.com/leaflet#1.6.0/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet#1.6.0/dist/leaflet.js"></script>
<div id="map"></div>

How can I properly setup flow with eslint?

My .eslintrc file is:
{
"extends": "google",
"plugins": [
"mocha",
"flowtype"
],
"rules": {
"strict": [
"error",
"never"
],
"comma-dangle": [
"error",
"never"
],
"object-curly-spacing": [
"error",
"always"
],
"require-jsdoc": [
"error",
{
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": false,
"ArrowFunctionExpression": false,
"FunctionExpression": false
}
}
],
"indent": [
"error",
2,
{
"SwitchCase": 1
}
],
"semi": [
"warn",
"always"
],
"no-console": [
"warn",
{
"allow": [
"debug",
"error"
]
}
],
"max-len": [
"off"
],
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "should"
}
],
"flowtype/boolean-style": [
2,
"boolean"
],
"flowtype/define-flow-type": 1,
"flowtype/delimiter-dangle": [
2,
"never"
],
"flowtype/generic-spacing": [
2,
"never"
],
"flowtype/no-primitive-constructor-types": 2,
"flowtype/no-types-missing-file-annotation": 2,
"flowtype/no-weak-types": 2,
"flowtype/object-type-delimiter": [
2,
"comma"
],
"flowtype/require-parameter-type": 2,
"flowtype/require-return-type": [
2,
"always",
{
"annotateUndefined": "never"
}
],
"flowtype/require-valid-file-annotation": 2,
"flowtype/semi": [
2,
"always"
],
"flowtype/space-after-type-colon": [
2,
"always"
],
"flowtype/space-before-generic-bracket": [
2,
"never"
],
"flowtype/space-before-type-colon": [
2,
"never"
],
"flowtype/type-id-match": [
2,
"^([A-Z][a-z0-9]+)+Type$"
],
"flowtype/union-intersection-spacing": [
2,
"always"
],
"flowtype/use-flow-type": 1,
"flowtype/valid-syntax": 1
},
"env": {
"es6": true,
"node": true
},
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": false
}
}
}
VSCode still shows:
Changing my .eslintrc to:
{
"extends": "google",
"parser": "babel-eslint",
"plugins": [
"mocha",
"flowtype"
],
"rules": {
"strict": [
"error",
"never"
],
"comma-dangle": [
"error",
"never"
],
"object-curly-spacing": [
"error",
"always"
],
"require-jsdoc": [
"error",
{
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": false,
"ArrowFunctionExpression": false,
"FunctionExpression": false
}
}
],
"indent": [
"error",
2,
{
"SwitchCase": 1
}
],
"semi": [
"warn",
"always"
],
"no-console": [
"warn",
{
"allow": [
"debug",
"error"
]
}
],
"max-len": [
"off"
],
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "should"
}
]
},
"env": {
"es6": true,
"node": true
},
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": true
}
}
}
helped

2dsphere Index on Document with Valid GEOJSON Polygon Fails with Error: Can't extract geo keys from object, malformed geometry?

When I insert a document with a valid GeoJSON Object (called GEOJSONPOlYGON) and then attempt to create a 2dsphere index on the document on the GEOJSONPOlYGON the index fails to create with error: "Can't extract geo keys from object, malformed geometry?"
I have followed the mongo documentation and geoJSON docs to no avail. Can anyone help me pinpoint the issue?
The Polygon renders correctly in http://geojsonlint.com/
Below are the steps to reproduce.
Steps to Reproduce:
1)
mongodbshell> db.vendors.insert({ "NAME": "LUIGIS HARDWARE SUPPLY", "GEOJSONPOlYGON": { "type": "Polygon", "coordinates": [ [ [ -74.01087951660156, 40.73202133178711 ], [ -74.00675964355469, 40.73277282714844 ], [ -74.00328063964844, 40.73329162597656 ], [ -74.002685546875, 40.7330322265625 ], [ -74.0023322241211, 40.73254394533125 ], [ -74.00152587890625, 40.73143768310547 ], [ -74.00079345703125, 40.73137283325195 ], [ -73.99939771118164, 40.73091888427734 ], [ -73.99551391601562, 40.7287712097168 ], [ -73.99191284179688, 40.72701644897461 ], [ -73.98985290527344, 40.72616958618164 ], [ -73.989325018310547, 40.725384533691406 ], [ -73.98374496459961, 40.723512817382812 ], [ -73.983689270019531, 40.72489929199219 ], [ -73.973826385498047, 40.72125625610352 ], [ -73.97440338134766, 40.72047805786133 ], [ -73.97418975830078, 40.72200775146484 ], [ -73.97337341308594, 40.72340393066406 ], [ -73.97174072265625, 40.7264289855957 ], [ -73.97148132324219, 40.72916030883789 ], [ -73.97332763671875, 40.73130798339844 ], [ -73.97461700439453, 40.73602294921875 ], [ -73.97294616699219, 40.73894882202148 ], [ -73.97113800048828, 40.74395751953125 ], [ -73.986835327148438, 40.74704742431641 ], [ -73.96345520019531, 40.75289916992188 ], [ -73.95843505859375, 40.75819778442383 ], [ -73.95530700683594, 40.76128387451172 ], [ -73.925002746582031, 40.7671012878418 ], [ -73.94731903076172, 40.77009201049805 ], [ -73.94818115234375, 40.77070999145508 ], [ -73.95002746582031, 40.77149200439453 ], [ -73.95221710205078, 40.77239990234375 ], [ -73.954365850830078, 40.773434131469727 ], [ -73.96379852294922, 40.77727508544922 ], [ -73.967134782714844, 40.772823333374023 ], [ -73.96997833251953, 40.76898956298828 ], [ -73.97084045410156, 40.76788330078125 ], [ -73.97268676757812, 40.76525115966797 ], [ -73.97315979003906, 40.76463317871094 ], [ -73.9812240600586, 40.76814270019531 ], [ -73.9791259765625, 40.77149200439453 ], [ -73.97667694091797, 40.77509689331055 ], [ -73.981236983642578, 40.76817370324707 ], [ -73.97581481933594, 40.77584457397461 ], [ -73.97178649902344, 40.78150177001953 ], [ -73.9755630493164, 40.78232151184082 ], [ -73.97380044555664, 40.783332138061523 ], [ -73.9795913696289, 40.78400039672852 ], [ -73.983414611816406, 40.78582000732422 ], [ -73.98564910888672, 40.78387069702148 ], [ -73.98676300048828, 40.78227996826172 ], [ -73.98895263671875, 40.77964782714844 ], [ -73.99212646484375, 40.77529144287109 ], [ -73.99491882324219, 40.77155685424805 ], [ -73.9953842163086, 40.76996231079102 ], [ -73.9964599609375, 40.76814270019531 ], [ -73.99791717529297, 40.76615905761719 ], [ -73.999830926513672, 40.764034571533203 ], [ -74.00409698486328, 40.76323318481445 ], [ -74.00015258789062, 40.76408004760742 ], [ -74.002351007080078, 40.760395962524414 ], [ -74.00543212890625, 40.75748062133789 ], [ -74.00800323486328, 40.75331878662109 ], [ -74.00839233398438, 40.75172805786133 ], [ -74.00890350341797, 40.75088119506836 ], [ -74.009033203125, 40.74997329711914 ], [ -74.00826263427734, 40.74867248535156 ], [ -74.00873565673828, 40.74733734130859 ], [ -74.00886535644531, 40.7459716796875 ], [ -74.00899505615234, 40.74541854858398 ], [ -74.00924682617188, 40.74324035644531 ], [ -74.009731984863281, 40.740377224731445 ], [ -74.010340649414062, 40.738623457275391 ], [ -74.01087951660156, 40.73202133178711 ] ] ] }})
WriteResult({ "nInserted" : 1 })
2) See that creation of index fails with error mentioned above.
mongodbshell> db.vendors.ensureIndex({GEOJSONPOlYGON : "2dsphere"})
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 1,
"ok" : 0,
"errmsg" : "Can't extract geo keys from object, malformed geometry?: { _id: ObjectId('549471aa68cfa2950001cd6e'), NAME: \"LUIGIS HARDWARE SUPPLY\", GEOJSONPOlYGON: { type: \"Polygon\", coordinates: [ [ [ -74.01087951660156, 40.73202133178711 ], [ -74.00675964355469, 40.73277282714844 ], [ -74.00328063964844, 40.73329162597656 ], [ -74.002685546875, 40.7330322265625 ], [ -74.0023322241211, 40.73254394533125 ], [ -74.00152587890625, 40.73143768310547 ], [ -74.00079345703125, 40.73137283325195 ], [ -73.99939771118164, 40.73091888427734 ], [ -73.99551391601562, 40.7287712097168 ], [ -73.99191284179688, 40.72701644897461 ], [ -73.98985290527344, 40.72616958618164 ], [ -73.98932501831055, 40.7253845336914 ], [ -73.98374496459961, 40.72351281738281 ], [ -73.98368927001952, 40.72489929199219 ], [ -73.97382638549804, 40.72125625610352 ], [ -73.97440338134766, 40.72047805786133 ], [ -73.97418975830078, 40.72200775146484 ], [ -73.97337341308594, 40.72340393066406 ], [ -73.97174072265625, 40.7264289855957 ], [ -73.97148132324219, 40.72916030883789 ], [ -73.97332763671875, 40.73130798339844 ], [ -73.97461700439453, 40.73602294921875 ], [ -73.97294616699219, 40.73894882202148 ], [ -73.97113800048828, 40.74395751953125 ], [ -73.98683532714844, 40.74704742431641 ], [ -73.96345520019531, 40.75289916992188 ], [ -73.95843505859375, 40.75819778442383 ], [ -73.95530700683594, 40.76128387451172 ], [ -73.92500274658204, 40.7671012878418 ], [ -73.94731903076172, 40.77009201049805 ], [ -73.94818115234375, 40.77070999145508 ], [ -73.95002746582031, 40.77149200439453 ], [ -73.95221710205078, 40.77239990234375 ], [ -73.95436585083007, 40.77343413146973 ], [ -73.96379852294922, 40.77727508544922 ], [ -73.96713478271485, 40.77282333337402 ], [ -73.96997833251953, 40.76898956298828 ], [ -73.97084045410156, 40.76788330078125 ], [ -73.97268676757812, 40.76525115966797 ], [ -73.97315979003906, 40.76463317871094 ], [ -73.98122406005859, 40.76814270019531 ], [ -73.9791259765625, 40.77149200439453 ], [ -73.97667694091797, 40.77509689331055 ], [ -73.98123698364257, 40.76817370324707 ], [ -73.97581481933594, 40.77584457397461 ], [ -73.97178649902344, 40.78150177001953 ], [ -73.97556304931641, 40.78232151184082 ], [ -73.97380044555663, 40.78333213806152 ], [ -73.97959136962891, 40.78400039672852 ], [ -73.9834146118164, 40.78582000732422 ], [ -73.98564910888672, 40.78387069702148 ], [ -73.98676300048828, 40.78227996826172 ], [ -73.98895263671875, 40.77964782714844 ], [ -73.99212646484375, 40.77529144287109 ], [ -73.99491882324219, 40.77155685424805 ], [ -73.99538421630859, 40.76996231079102 ], [ -73.9964599609375, 40.76814270019531 ], [ -73.99791717529297, 40.76615905761719 ], [ -73.99983092651367, 40.7640345715332 ], [ -74.00409698486328, 40.76323318481445 ], [ -74.00015258789062, 40.76408004760742 ], [ -74.00235100708008, 40.76039596252441 ], [ -74.00543212890625, 40.75748062133789 ], [ -74.00800323486328, 40.75331878662109 ], [ -74.00839233398438, 40.75172805786133 ], [ -74.00890350341797, 40.75088119506836 ], [ -74.009033203125, 40.74997329711914 ], [ -74.00826263427734, 40.74867248535156 ], [ -74.00873565673828, 40.74733734130859 ], [ -74.00886535644531, 40.7459716796875 ], [ -74.00899505615234, 40.74541854858398 ], [ -74.00924682617188, 40.74324035644531 ], [ -74.00973198486328, 40.74037722473145 ], [ -74.01034064941406, 40.73862345727539 ], [ -74.01087951660156, 40.73202133178711 ] ] ] } }",
"code" : 16755
}
mongodbshell>
`
If you visualize the polygon on GeoJsonLint and look on the west side near 50th street, you'll see the polygon's boundary crosses itself. Note that the two points:
[ -73.999830926513672, 40.764034571533203 ], [ -74.00409698486328, 40.76323318481445 ]
Are causing the polygon to overlap itself and that is not a correctly formed polygon.
Fixed that odd spot causes the 2dsphere index build to succeed.
There are tools such as MapShaper for fixing and Simplifying corrupted Pologons/Multipolygons

Check which polygon contains a point in mongodb

I would like to have a collection with polygons (certain areas on the planet) and considering that I have a point(a single place on the planet), I would like to know which polygons contain this point.
consider the collection like.
{
"_id" : "xxx",
"geo" : {
"type" : "MultiPolygon",
"coordinates" : [
[
[
[
34.5245361328125,
26.4386062678873
],
[
34.5327758789062,
26.4754901967738
],
[
34.5272827148438,
26.5099045314139
],
[
34.508056640625,
26.5688765479507
],
[
34.5135498046875,
26.6376388866459
],
[
34.5053100585938,
26.7210803908617
],
[
34.4943237304688,
26.7872992221561
],
[
34.5135498046875,
26.8608304092814
],
[
34.5382690429688,
26.9587976785709
],
[
34.5767211914062,
27.08113703389
],
[
34.595947265625,
27.2741611173747
],
[
34.5492553710938,
27.3766453536396
],
[
34.12353515625,
27.5448063177539
],
[
33.59893798828125,
27.94467306257741
],
[
33.6676025390625,
27.51314343580719
],
[
33.5577392578125,
27.3912773132324
],
[
33.4588623046875,
27.3351745605469
],
[
33.4259033203125,
27.2326526641846
],
[
33.4121704101562,
27.1300354003906
],
[
33.4808349609375,
27.0077495574951
],
[
33.5467529296875,
26.8804302215576
],
[
33.6044311523438,
26.7382526397705
],
[
33.6758422851562,
26.5664196014404
],
[
33.7197875976562,
26.4090900421143
],
[
33.760986328125,
26.2712516784668
],
[
33.81591796875,
26.1505069732666
],
[
33.8818359375,
26.0937881469727
],
[
33.9669799804688,
26.1381797790527
],
[
34.0713500976562,
26.2318382263184
],
[
34.1372680664062,
26.2540092468262
],
[
34.1867065429688,
26.2663249969482
],
[
34.2333984375,
26.2761764526367
],
[
34.27734375,
26.2811031341553
],
[
34.3927001953125,
26.3081885431537
],
[
34.4833374023438,
26.3451141501178
],
[
34.5245361328125,
26.4066306425568
],
[
34.5245361328125,
26.4386062678873
]
],
...
]
]
}
}
How do I achieve this?
db['countries'].find( {
"geo.coordinates" : {
$geoIntersects : {
$geometry : {
type : "Point" ,
coordinates : [
34.5245361328125,
26.4386062678873
]
}
}
}
})