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
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