mapbox / leaflet-omnivore

universal format parser for Leaflet & Mapbox.js
https://www.mapbox.com/mapbox.js/example/v1.0.0/omnivore-gpx/
Other
651 stars 126 forks source link

MultiPolygon not being added to map #26

Closed 1parkplace closed 10 years ago

1parkplace commented 10 years ago

I am not 100% sure if this is omnivore not being able to add the polygon, or if this is mapbox getBounds() that is failing to execute on the multipolygon object.

Basically, I create a layer then feed MULTIPOLYGON WKT to omnivore through omnivore.wkt.parse, I then pass that layer to "map.fitBounds(runLayer.getBounds());

At which point I get: Error: Invalid LatLng object: (NaN, NaN) https://api.tiles.mapbox.com/mapbox.js/v1.6.3/mapbox.js Line 1

The MultiPolygon object I am passing is: "MULTIPOLYGON (((-117.189582 32.725158, -117.189545 32.725187, -117.190133 32.725274, -117.189582 32.725158)), ((-117.190375 32.724537999999995, -117.190272 32.724779999999996, -117.190652 32.724907, -117.192605 32.724801, -117.190446 32.724548, -117.190375 32.724537999999995)), ((-117.182688 32.726089, -117.182454 32.7261, -117.180834 32.725528, -117.180219 32.725446, -117.179951 32.726959, -117.182389 32.72753, -117.184926 32.728311, -117.184477 32.728047, -117.184503 32.727964, -117.184991 32.727007, -117.184894 32.726886, -117.182688 32.726089)), ((-117.16132999999999 32.703193999999996, -117.160751 32.703821, -117.16032200000001 32.70354, -117.161226 32.702622, -117.161148 32.702567, -117.16107 32.702622, -117.160354 32.703364, -117.159834 32.703023, -117.15974299999999 32.703116, -117.159554 32.7031, -117.159385 32.702643, -117.160335 32.702363, -117.160303 32.702281, -117.159255 32.702583, -117.158878 32.702346, -117.158885 32.702290999999995, -117.160426 32.701841, -117.160374 32.701736, -117.158644 32.702258, -117.159041 32.702583, -117.15893 32.702681999999996, -117.158384 32.702352, -117.158312 32.702225, -117.157857 32.701912, -117.15787 32.701813, -117.158052 32.701741, -117.161096 32.700862, -117.161214 32.700784999999996, -117.161149 32.700686, -117.154893 32.696351, -117.154633 32.696296, -117.15194 32.697092999999995, -117.151765 32.696686, -117.15129 32.696349999999995, -117.151167 32.696141, -117.15064 32.695861, -117.152104 32.694431, -117.151955 32.694342999999996, -117.150549 32.695811, -117.150228 32.695595, -117.14981900000001 32.696025, -117.14926 32.696598, -117.149188 32.696912, -117.148863 32.696959, -117.148501 32.697139, -117.147395 32.698282, -117.149058 32.699436, -117.150769 32.700536, -117.149177 32.702161, -117.152729 32.704654999999995, -117.152838 32.70494, -117.15279100000001 32.705225, -117.151501 32.705227, -117.150342 32.705223, -117.14757 32.705235, -117.14773 32.706272999999996, -117.147733 32.709424999999996, -117.147763 32.710456, -117.147735 32.71166, -117.148026 32.713682999999996, -117.14819 32.714452, -117.148042 32.714557, -117.1479 32.715767, -117.148085 32.716043, -117.148076 32.716172, -117.14787799999999 32.716809999999995, -117.148082 32.717863, -117.14756 32.717864999999996, -117.147606 32.718378, -117.147776 32.719398999999996, -117.148336 32.721102, -117.148978 32.722215, -117.14944299999999 32.722828, -117.15010000000001 32.723478, -117.150669 32.723855, -117.151251 32.724104, -117.150528 32.725572, -117.149565 32.725076, -117.149067 32.723852, -117.14865 32.723456, -117.148239 32.723386999999995, -117.14838499999999 32.723017999999996, -117.148282 32.722805, -117.148086 32.72265, -117.147688 32.722558, -117.147287 32.722667, -117.146965 32.723008, -117.146748 32.723518, -117.14672999999999 32.722978, -117.146993 32.722468, -117.147075 32.722069, -117.146588 32.722452, -117.14648700000001 32.722767999999995, -117.14649 32.723213, -117.146196 32.723165, -117.146389 32.722358, -117.145506 32.722336999999996, -117.14479 32.722628, -117.144722 32.722894, -117.14487199999999 32.723532999999996, -117.14474200000001 32.723841, -117.144945 32.723667999999996, -117.14548500000001 32.724258999999996, -117.14556 32.72465, -117.14495099999999 32.724694, -117.144483 32.724948, -117.144223 32.725221, -117.143791 32.726326, -117.143584 32.726552999999996, -117.143177 32.726714, -117.142667 32.726709, -117.142067 32.726849, -117.14302599999999 32.730345, -117.143661 32.730547, -117.144012 32.730865, -117.14534 32.733354, -117.145419 32.733661999999995, -117.14540000000001 32.735077, -117.145475 32.735177, -117.145771 32.735212, -117.14572 32.736289, -117.14592 32.737499, -117.146355 32.738519, -117.147396 32.7402, -117.147499 32.740573999999995, -117.14752899999999 32.741169, -117.151181 32.741129, -117.1513 32.740507, -117.151546 32.740072999999995, -117.153902 32.738217999999996, -117.15478999999999 32.737296, -117.155784 32.736788, -117.155958 32.736706999999996, -117.155959 32.734852, -117.155852 32.734234, -117.15564 32.733596, -117.154921 32.732301, -117.154652 32.731418, -117.158027 32.731401, -117.158079 32.730559, -117.158253 32.729684, -117.15824 32.729296999999995, -117.15939399999999 32.729302, -117.159398 32.730354999999996, -117.15939900000001 32.731394, -117.163028 32.731373, -117.164849 32.731365, -117.16486 32.732423, -117.16575399999999 32.732394, -117.166687 32.732386999999996, -117.167516 32.732378, -117.167516 32.732315, -117.168173 32.732316, -117.169871 32.731808, -117.169468 32.73083, -117.17044 32.730526, -117.171365 32.731584999999995, -117.178548 32.73964, -117.179976 32.741143, -117.181014 32.741842, -117.182322 32.742536, -117.18323 32.741974, -117.183504 32.741687999999996, -117.18423899999999 32.740536, -117.184275 32.740480999999996, -117.185058 32.739543999999995, -117.185795 32.739115, -117.186657 32.73897, -117.187513 32.739205999999996, -117.188244 32.738963999999996, -117.188761 32.738758, -117.190761 32.738309, -117.191665 32.734950999999995, -117.196293 32.736069, -117.196992 32.736533, -117.201536 32.737637, -117.201993 32.73761, -117.202435 32.737840999999996, -117.202223 32.739286, -117.205482 32.739613, -117.206273 32.739321, -117.20698 32.740401, -117.20730499999999 32.740702999999996, -117.207918 32.741062, -117.208218 32.741431999999996, -117.20815999999999 32.741665, -117.207792 32.741813, -117.207649 32.742048, -117.207846 32.742821, -117.208963 32.742537, -117.209555 32.742539, -117.208891 32.740978, -117.208539 32.740935, -117.207843 32.740423, -117.207524 32.740319, -117.207537 32.740148, -117.207296 32.739972, -117.206639 32.738625, -117.20682099999999 32.738580999999996, -117.206814 32.738312, -117.206704 32.73829, -117.206769 32.737685, -117.206983 32.737173, -117.207437 32.736668, -117.208843 32.735765, -117.209129 32.734899, -117.20870099999999 32.734341, -117.209025 32.734367999999996, -117.209358 32.732034999999996, -117.208999 32.732, -117.208583 32.731958999999996, -117.208876 32.72983, -117.20894200000001 32.729461, -117.209362 32.729376, -117.20918 32.728982, -117.20528 32.729346, -117.205214 32.728637, -117.204613 32.729229, -117.202092 32.728626, -117.1996 32.72905, -117.199507 32.728502, -117.199083 32.728277, -117.198751 32.727975, -117.198549 32.727568, -117.198536 32.727095, -117.198647 32.726605, -117.198881 32.726186999999996, -117.19910899999999 32.725989999999996, -117.199577 32.725933999999995, -117.201542 32.726028, -117.205588 32.725901, -117.210831 32.725314, -117.213364 32.724905, -117.211845 32.724361, -117.20880199999999 32.724771, -117.207939 32.725155, -117.205801 32.725356, -117.20493 32.72512, -117.197937 32.725218, -117.197663 32.724999, -117.195945 32.724865, -117.195724 32.725093, -117.19630599999999 32.725252, -117.196511 32.725486, -117.196597 32.726611999999996, -117.196522 32.727133, -117.196313 32.728439, -117.19610399999999 32.728617, -117.195584 32.72869, -117.195307 32.728816, -117.195166 32.729006999999996, -117.195141 32.729383, -117.192991 32.729272, -117.18551 32.728849, -117.184271 32.728575, -117.181621 32.727700999999996, -117.180183 32.727515, -117.178597 32.727655999999996, -117.177395 32.727669999999996, -117.178366 32.727363, -117.177575 32.727365, -117.176722 32.727243, -117.175714 32.72688, -117.174563 32.72605, -117.17388 32.725207999999995, -117.173639 32.724641999999996, -117.173457 32.723735, -117.173475 32.719912, -117.17347699999999 32.719704, -117.17376999999999 32.719704, -117.173835 32.719605, -117.17381499999999 32.719159999999995, -117.173464 32.719132, -117.173458 32.717988, -117.176665 32.717945, -117.176659 32.716789999999996, -117.173452 32.716761999999996, -117.173452 32.716393, -117.173608 32.716394, -117.173608 32.716245, -117.173907 32.716234, -117.173907 32.716152, -117.173452 32.716135, -117.173445 32.715899, -117.176665 32.715921, -117.176665 32.715453, -117.173445 32.715453, -117.173445 32.715154999999996, -117.173445 32.714815, -117.176646 32.714838, -117.176639 32.714024, -117.173823 32.713989999999995, -117.173836 32.71393, -117.173608 32.713924, -117.173445 32.713847, -117.173446 32.713721, -117.173608 32.713721, -117.173576 32.712648, -117.174259 32.71283, -117.174577 32.713198999999996, -117.17554 32.712907, -117.175618 32.713100000000004, -117.175696 32.713100000000004, -117.17563799999999 32.71288, -117.17585199999999 32.712803, -117.175566 32.711686, -117.17585199999999 32.711538, -117.17572200000001 32.711192, -117.175644 32.711224, -117.17446100000001 32.709883, -117.174363 32.709993, -117.175527 32.711273999999996, -117.175105 32.711461, -117.175118 32.711554, -117.174948 32.711653, -117.173738 32.712253, -117.17351099999999 32.712225, -117.173361 32.712374, -117.173192 32.711978, -117.174077 32.711703, -117.174018 32.711571, -117.173127 32.711818, -117.172932 32.711362, -117.173329 32.711219, -117.173251 32.711020999999995, -117.172769 32.711003999999996, -117.172067 32.709452999999996, -117.172067 32.709184, -117.171319 32.708469, -117.17063 32.708463, -117.170609 32.708027, -117.169179 32.708441, -117.167293 32.708408, -117.163677 32.705943999999995, -117.165154 32.704498, -117.166168 32.705174, -117.166546 32.704965, -117.166728 32.704586, -117.166741 32.704344, -117.163782 32.702463, -117.162468 32.703876, -117.16322199999999 32.704364999999996, -117.162904 32.704646, -117.16319 32.70486, -117.163326 32.704738999999996, -117.163404 32.704794, -117.16278 32.705338999999995, -117.162403 32.705069, -117.162494 32.704997999999996, -117.160881 32.703908, -117.16146 32.703271, -117.16132999999999 32.703193999999996), (-117.172803 32.711469, -117.173129 32.712233999999995, -117.173104 32.715708, -117.171098 32.715711999999996, -117.171082 32.713587, -117.17105699999999 32.711482, -117.172803 32.711469)))"

tmcw commented 10 years ago

https://github.com/mapbox/leaflet-omnivore/commit/ee7a4f35dea161353aebfdb7fbd24d3e87be9a20 should fix this - please confirm. I've pushed 0.1.2 to mapbox.js plugin cdn as well.

1parkplace commented 10 years ago

You are truly a gentleman and a scholar, a true wizard. Thanks for the quick update, works GREAT.

akablacksun commented 9 years ago

this conversation works for me very good, thnx a lot guys :+1: