I need to make a map with google maps api with various latitudes and longitudes, this data is from a running workout or a walk

Asked

Viewed 47 times

-1

var map; Function initMap() {

  var nussa = [{lat:-23.99000683799386,
          lng:-46.28644368611276},

          {lat:-23.99000977165997,
          lng:-46.286408733576536},

          {lat:-23.990014549344778,
          lng:-46.286373026669025},

          {lat:-23.99001756682992,
          lng:-46.286336397752166},

          {lat:-23.990019913762808,
          lng:-46.286298679187894},

          {lat:-23.990025026723742,
          lng:-46.286258110776544},

          {lat:-23.990031061694026,
          lng:-46.28621553070843},

          {lat:-23.9900375995785,
          lng:-46.28617295064032},

          {lat:-23.990045227110386,
          lng:-46.28613037057221},

          {lat:-23.990054111927748,
          lng:-46.28608628176153},

          {lat:-23.990062745288014,
          lng:-46.28603992983699},

          {lat:-23.9900703728199,
          lng:-46.28599223680794},

          {lat:-23.990078754723072,
          lng:-46.28594378940761},

          {lat:-23.990085879340768,
          lng:-46.28589534200728},

          {lat:-23.990091998130083,
          lng:-46.28584764897823},

          {lat:-23.990099038928747,
          lng:-46.28580163232982},

          {lat:-23.990106331184506,
          lng:-46.28575695678592},

          {lat:-23.990114461630583,
          lng:-46.285711443051696},

          {lat:-23.99012317880988,
          lng:-46.28566433675587},

          {lat:-23.990131812170148,
          lng:-46.28561580553651},

          {lat:-23.99014019407332,
          lng:-46.28556760959327},

          {lat:-23.990148659795523,
          lng:-46.28552100621164},

          {lat:-23.990156538784504,
          lng:-46.28547515720129},

          {lat:-23.99016416631639,
          lng:-46.285428972914815},

          {lat:-23.990171877667308,
          lng:-46.28538287244737},

          {lat:-23.990179169923067,
          lng:-46.285336185246706},

          {lat:-23.9901861269027,
          lng:-46.28529050387442},

          {lat:-23.99019291624427,
          lng:-46.28524532541633},

          {lat:-23.990199621766806,
          lng:-46.28519997932017},

          {lat:-23.99020574055612,
          lng:-46.285153878852725},

          {lat:-23.990212278440595,
          lng:-46.285107946023345},

          {lat:-23.990220157429576,
          lng:-46.285062013193965},

          {lat:-23.990228790789843,
          lng:-46.28501540981233},

          {lat:-23.990238178521395,
          lng:-46.284965705126524},

          {lat:-23.990247817710042,
          lng:-46.28491482697427},

          {lat:-23.990256618708372,
          lng:-46.2848649546504},

          {lat:-23.990265587344766,
          lng:-46.28481608815491},

          {lat:-23.99027463980019,
          lng:-46.28476705402136},

          {lat:-23.990282686427236,
          lng:-46.28471684642136},

          {lat:-23.99029073305428,
          lng:-46.284666219726205},

          {lat:-23.99029894731939,
          lng:-46.28461676649749},

          {lat:-23.990306993946433,
          lng:-46.28456764854491},

          {lat:-23.990314453840256,
          lng:-46.28451836295426},

          {lat:-23.990322751924396,
          lng:-46.28446941263974},

          {lat:-23.990331050008535,
          lng:-46.28442079760134},

          {lat:-23.99033901281655,
          lng:-46.28437243402004},

          {lat:-23.990347227081656,
          lng:-46.28432432189584},

          {lat:-23.990355525165796,
          lng:-46.28427562303841},

          {lat:-23.990363404154778,
          lng:-46.2842261698097},

          {lat:-23.990371618419886,
          lng:-46.2841759622097},

          {lat:-23.990380503237247,
          lng:-46.284126257523894},

          {lat:-23.990388801321387,
          lng:-46.28407957032323},

          {lat:-23.990395590662956,
          lng:-46.28403665497899},

          {lat:-23.990401457995176,
          lng:-46.28400161862373},

          {lat:-23.990406738594174,
          lng:-46.283977227285504},

          {lat:-23.990410761907697,
          lng:-46.283957194536924},

          {lat:-23.9904157910496,
          lng:-46.28393556922674},

          {lat:-23.99042165838182,
          lng:-46.28390816040337},

          {lat:-23.990427777171135,
          lng:-46.28387161530554},

          {lat:-23.99043540470302,
          lng:-46.283827777951956},

          {lat:-23.990443367511034,
          lng:-46.283781845122576},

          {lat:-23.990449318662286,
          lng:-46.28373557701707},

          {lat:-23.99045485071838,
          lng:-46.28368738107383},

          {lat:-23.99046180769801,
          lng:-46.28363792784512},

          {lat:-23.99046909995377,
          lng:-46.28358654677868},

          {lat:-23.990476559847593,
          lng:-46.283533573150635},

          {lat:-23.990484522655606,
          lng:-46.28347900696099},

          {lat:-23.990493156015873,
          lng:-46.283422680571675},

          {lat:-23.99050229229033,
          lng:-46.283365013077855},

          {lat:-23.990511680021882,
          lng:-46.283306339755654},

          {lat:-23.990521067753434,
          lng:-46.28324599005282},

          {lat:-23.990531293675303,
          lng:-46.28318446688354},

          {lat:-23.990542022511363,
          lng:-46.28312177024782},

          {lat:-23.990552416071296,
          lng:-46.28305790014565},

          {lat:-23.990562139078975,
          lng:-46.282993610948324},

          {lat:-23.99057219736278,
          lng:-46.282929154112935},

          {lat:-23.990582758560777,
          lng:-46.28286494873464},

          {lat:-23.990593906491995,
          lng:-46.28280149772763},

          {lat:-23.990604216232896,
          lng:-46.28273980692029},

          {lat:-23.990614023059607,
          lng:-46.28267778083682},

          {lat:-23.990623243153095,
          lng:-46.28261533565819},

          {lat:-23.99063321761787,
          lng:-46.28255280666053},

          {lat:-23.990643275901675,
          lng:-46.28249069675803},

          {lat:-23.990651993080974,
          lng:-46.28242816776037},

          {lat:-23.990660374984145,
          lng:-46.28236706368625},

          {lat:-23.99067034944892,
          lng:-46.282305624336004},

          {lat:-23.9906800724566,
          lng:-46.28224435262382},

          {lat:-23.990690046921372,
          lng:-46.28218215890229},

          {lat:-23.99070018902421,
          lng:-46.28211921080947},

          {lat:-23.990711336955428,
          lng:-46.28205752000213},

          {lat:-23.99072173051536,
          lng:-46.28199608065188},

          {lat:-23.990731788799167,
          lng:-46.28193388693035},

          {lat:-23.990741930902004,
          lng:-46.28187152557075},

          {lat:-23.99075148627162,
          lng:-46.28180899657309},

          {lat:-23.990761879831553,
          lng:-46.2817463837564},

          {lat:-23.990772273391485,
          lng:-46.28168351948261},

          {lat:-23.99078174494207,
          lng:-46.281619649380445},

          {lat:-23.990789791569114,
          lng:-46.28155603073537},

          {lat:-23.990799179300666,
          lng:-46.28149433992803},

          {lat:-23.990809740498662,
          lng:-46.28143239766359},

          {lat:-23.990820217877626,
          lng:-46.28137028776109},

          {lat:-23.990830527618527,
          lng:-46.28130893222988},

          {lat:-23.9908389095217,
          lng:-46.281249672174454},

          {lat:-23.990848129615188,
          lng:-46.28118949010968},

          {lat:-23.99085843935609,
          lng:-46.281128972768784},

          {lat:-23.990868162363768,
          lng:-46.281069377437234},

          {lat:-23.99087897501886,
          lng:-46.28100793808699},

          {lat:-23.99088978767395,
          lng:-46.28094490617514},

          {lat:-23.99090001359582,
          lng:-46.280881371349096},

          {lat:-23.990909233689308,
          lng:-46.28081800416112},

          {lat:-23.99091803468764,
          lng:-46.280753798782825},

          {lat:-23.99092650040984,
          lng:-46.28068917430937},

          {lat:-23.990935971960425,
          lng:-46.28062387928367},

          {lat:-23.990945694968104,
          lng:-46.28055824898183},

          {lat:-23.990955837070942,
          lng:-46.28049203194678},

          {lat:-23.99096597917378,
          lng:-46.28042615018785},

          {lat:-23.990976875647902,
          lng:-46.280359430238605},

          {lat:-23.990988107398152,
          lng:-46.280292961746454},

          {lat:-23.99099917151034,
          lng:-46.280226577073336},

          {lat:-23.991009397432208,
          lng:-46.280161114409566},

          {lat:-23.991020126268268,
          lng:-46.280096573755145},

          {lat:-23.991030352190137,
          lng:-46.28003178164363},

          {lat:-23.991040075197816,
          lng:-46.279968498274684},

          {lat:-23.991050217300653,
          lng:-46.27990588545799},

          {lat:-23.9910598564893,
          lng:-46.279842937365174},

          {lat:-23.991069411858916,
          lng:-46.27977923490107},

          {lat:-23.99107938632369,
          lng:-46.27971553243697},

          {lat:-23.991090366616845,
          lng:-46.27965300343931},

          {lat:-23.99110134691,
          lng:-46.279592234641314},

          {lat:-23.991110483184457,
          lng:-46.27953096292913},

          {lat:-23.991119619458914,
          lng:-46.2794687692076},

          {lat:-23.99112967774272,
          lng:-46.27940649166703},

          {lat:-23.991139736026525,
          lng:-46.27934438176453},

          {lat:-23.9911497104913,
          lng:-46.279282020404935},

          {lat:-23.991159852594137,
          lng:-46.27921965904534},

          {lat:-23.99116974323988,
          lng:-46.279157465323806},

          {lat:-23.991178460419178,
          lng:-46.27909644506872},

          {lat:-23.991186590865254,
          lng:-46.27903643064201},

          {lat:-23.99119413457811,
          lng:-46.27897742204368},

          {lat:-23.99120201356709,
          lng:-46.27891967073083},

          {lat:-23.991210563108325,
          lng:-46.278862841427326},

          {lat:-23.9912186935544,
          lng:-46.27880601212382},

          {lat:-23.991226656362414,
          lng:-46.278747422620654},

          {lat:-23.991236966103315,
          lng:-46.27868707291782},

          {lat:-23.991249119862914,
          lng:-46.27862605266273},

          {lat:-23.99126110598445,
          lng:-46.278563775122166},

          {lat:-23.991272756829858,
          lng:-46.27850032411516},

          {lat:-23.99128407239914,
          lng:-46.278436202555895},

          {lat:-23.991294968873262,
          lng:-46.2783719971776},

          {lat:-23.99130502715707,
          lng:-46.27830787561834},

          {lat:-23.991315001621842,
          lng:-46.27824526280165},

          {lat:-23.991326233372092,
          lng:-46.27818399108946},

          {lat:-23.991339057683945,
          lng:-46.278123054653406},

          {lat:-23.991351379081607,
          lng:-46.27806111238897},

          {lat:-23.99136177264154,
          lng:-46.27799808047712},

          {lat:-23.991372250020504,
          lng:-46.2779351323843},

          {lat:-23.991382643580437,
          lng:-46.27787193283439},

          {lat:-23.991392198950052,
          lng:-46.27780890092254},

          {lat:-23.991402257233858,
          lng:-46.27774452790618},

          {lat:-23.991412231698632,
          lng:-46.277680741623044},

          {lat:-23.99142279289663,
          lng:-46.277615865692496},

          {lat:-23.99143402464688,
          lng:-46.277551241219044},

          {lat:-23.99144483730197,
          lng:-46.277487287297845},

          {lat:-23.991455733776093,
          lng:-46.27742459066212},

          {lat:-23.991468641906977,
          lng:-46.27736147493124},

          {lat:-23.991481382399797,
          lng:-46.2772979401052},

          {lat:-23.991491524502635,
          lng:-46.27723331563175},

          {lat:-23.991500409319997,
          lng:-46.277167685329914},

          {lat:-23.991508707404137,
          lng:-46.27710197120905},

          {lat:-23.991518011316657,
          lng:-46.2770373467356},

          {lat:-23.991527231410146,
          lng:-46.27697364427149},

          {lat:-23.991537038236856,
          lng:-46.276909774169326},

          {lat:-23.9915469288826,
          lng:-46.276846155524254},

          {lat:-23.991556484252214,
          lng:-46.27678211778402},

          {lat:-23.991566207259893,
          lng:-46.27671808004379},

          {lat:-23.991576014086604,
          lng:-46.27665404230356},

          {lat:-23.99158615618944,
          lng:-46.276589669287205},

          {lat:-23.99159680120647,
          lng:-46.27652529627085},

          {lat:-23.991608200594783,
          lng:-46.276461593806744},

          {lat:-23.991619516164064,
          lng:-46.276398142799735},

          {lat:-23.99162999354303,
          lng:-46.27633452415466},

          {lat:-23.99164080619812,
          lng:-46.27627048641443},

          {lat:-23.99165153503418,
          lng:-46.27620628103614},

          {lat:-23.991661928594112,
          lng:-46.27614190801978},

          {lat:-23.991672322154045,
          lng:-46.27607820555568},

          {lat:-23.9916833024472,
          lng:-46.276015089824796},

          {lat:-23.9916936121881,
          lng:-46.275951974093914},

          {lat:-23.99170341901481,
          lng:-46.27588919363916},

          {lat:-23.99171305820346,
          lng:-46.27582876011729},

          {lat:-23.991724122315645,
          lng:-46.27576891332865},

          {lat:-23.991734851151705,
          lng:-46.27570780925453},

          {lat:-23.991744574159384,
          lng:-46.27564502879977},

          {lat:-23.99175421334803,
          lng:-46.27558082342148},

          {lat:-23.991764774546027,
          lng:-46.27551603130996},

          {lat:-23.991775335744023,
          lng:-46.27544989809394},

          {lat:-23.991785226389766,
          lng:-46.27538301050663},

          {lat:-23.991795536130667,
          lng:-46.27531603910029},

          {lat:-23.991805594414473,
          lng:-46.2752497382462},

          {lat:-23.99181665852666,
          lng:-46.275184862315655},

          {lat:-23.991828644648194,
          lng:-46.27511973492801},

          {lat:-23.991839038208127,
          lng:-46.275053434073925},

          {lat:-23.991849347949028,
          lng:-46.27498688176274},

          {lat:-23.991859825327992,
          lng:-46.27492074854672},

          {lat:-23.991870554164052,
          lng:-46.27485587261617},

          {lat:-23.991881031543016,
          lng:-46.27479183487594},

          {lat:-23.991891760379076,
          lng:-46.27472938969731},

          {lat:-23.991901902481914,
          lng:-46.27466945908964},

          {lat:-23.991911122575402,
          lng:-46.27461212687194},

          {lat:-23.991920175030828,
          lng:-46.27455563284457},

          {lat:-23.991929478943348,
          lng:-46.27449804916978},

          {lat:-23.99193786084652,
          lng:-46.274438789114356},

          {lat:-23.9919475838542,
          lng:-46.274377182126045},

          {lat:-23.991959653794765,
          lng:-46.27431406639516},

          {lat:-23.991972729563713,
          lng:-46.27424986101687},

          {lat:-23.991984883323312,
          lng:-46.27418498508632},

          {lat:-23.99199603125453,
          lng:-46.274120612069964},

          {lat:-23.992005418986082,
          lng:-46.27405791543424},

          {lat:-23.99201505817473,
          lng:-46.27399194985628},

          {lat:-23.9920252840966,
          lng:-46.273925229907036},

          {lat:-23.992035510018468,
          lng:-46.27385750412941},

          {lat:-23.992045735940337,
          lng:-46.27378927543759},

          {lat:-23.992055458948016,
          lng:-46.273721382021904},

          {lat:-23.99206501431763,
          lng:-46.27365508116782},

          {lat:-23.992075072601438,
          lng:-46.273591462522745},

          {lat:-23.992086555808783,
          lng:-46.27353010699153},

          {lat:-23.992094602435827,
          lng:-46.2734695058316},

          {lat:-23.992099044844508,
          lng:-46.27340982668102},

          {lat:-23.992104828357697,
          lng:-46.27335115335882},

          {lat:-23.992114886641502,
          lng:-46.27329172566533},

          {lat:-23.992127208039165,
          lng:-46.27323053777218},

          {lat:-23.99213776923716,
          lng:-46.27316851168871},

          {lat:-23.992148246616125,
          lng:-46.27310539595783},

          {lat:-23.99215931072831,
          lng:-46.27304144203663},

          {lat:-23.99216953665018,
          lng:-46.272976314648986},

          {lat:-23.992179427295923,
          lng:-46.27291068434715},

          {lat:-23.992189904674888,
          lng:-46.272843377664685},

          {lat:-23.992201471701264,
          lng:-46.272775484248996},

          {lat:-23.992211697623134,
          lng:-46.27270666882396},

          {lat:-23.99221982806921,
          lng:-46.272637182846665},

          {lat:-23.992226952686906,
          lng:-46.27256903797388},

          {lat:-23.9922340773046,
          lng:-46.27250315621495},

          {lat:-23.9922393579036,
          lng:-46.27243886701763},

          {lat:-23.992242543026805,
          lng:-46.27237390726805},

          {lat:-23.992244470864534,
          lng:-46.27230794169009},

          {lat:-23.992244889959693,
          lng:-46.27224113792181},

          {lat:-23.992243381217122,
          lng:-46.272175339981914},

          {lat:-23.992240531370044,
          lng:-46.2721105478704},

          {lat:-23.99223701097071,
          lng:-46.27204609103501},

          {lat:-23.992232317104936,
          lng:-46.2719810474664},

          {lat:-23.992226868867874,
          lng:-46.27191533334553},

          {lat:-23.992219660431147,
          lng:-46.27184987068176},

          {lat:-23.99221052415669,
          lng:-46.27178524620831},

          {lat:-23.99220021441579,
          lng:-46.2717217952013},

          {lat:-23.992188731208444,
          lng:-46.2716615293175},

          {lat:-23.992178002372384,
          lng:-46.27160654403269},

          {lat:-23.992166938260198,
          lng:-46.271556252613664},

          {lat:-23.992155622690916,
          lng:-46.271508475765586},

          {lat:-23.99214355275035,
          lng:-46.271462040022016},

          {lat:-23.992131063714623,
          lng:-46.271415101364255},

          {lat:-23.992119412869215,
          lng:-46.271369503811},

          {lat:-23.992108097299933,
          lng:-46.27132558263838},

          {lat:-23.99209477007389,
          lng:-46.27128157764673},

          {lat:-23.992079682648182,
          lng:-46.271234722808},

          {lat:-23.99206400848925,
          lng:-46.27118560485542},

          {lat:-23.99204732850194,
          lng:-46.27113573253155},

          {lat:-23.992030816152692,
          lng:-46.271085273474455},

          {lat:-23.992014387622476,
          lng:-46.27103364095092},

          {lat:-23.991998210549355,
          lng:-46.270981170237064},

          {lat:-23.991981698200107,
          lng:-46.27092811278999},

          {lat:-23.99196426384151,
          lng:-46.27087446860969},

          {lat:-23.991946829482913,
          lng:-46.27081965096295},

          {lat:-23.991929311305285,
          lng:-46.27076365984976},

          {lat:-23.991911374032497,
          lng:-46.270707082003355},

          {lat:-23.991894023492932,
          lng:-46.27064916305244},

          {lat:-23.99187633767724,
          lng:-46.27059040591121},

          {lat:-23.991858819499612,
          lng:-46.270531145855784},

          {lat:-23.991840798407793,
          lng:-46.270470544695854},

          {lat:-23.99182252585888,
          lng:-46.270409021526575},

          {lat:-23.991804169490933,
          lng:-46.27034774981439},

          {lat:-23.991785561665893,
          lng:-46.27028647810221},

          {lat:-23.991767121478915,
          lng:-46.27022545784712},

          {lat:-23.991749603301287,
          lng:-46.27016460523009},

          {lat:-23.991732001304626,
          lng:-46.27010450698435},

          {lat:-23.991714399307966,
          lng:-46.270044995471835},

          {lat:-23.99169646203518,
          lng:-46.26998573541641},

          {lat:-23.991678608581424,
          lng:-46.26992563717067},

          {lat:-23.991661006584764,
          lng:-46.26986579038203},

          {lat:-23.991643823683262,
          lng:-46.26980661414564},

          {lat:-23.99162613786757,
          lng:-46.26974710263312},

          {lat:-23.99160702712834,
          lng:-46.26968742348254},

          {lat:-23.991588335484266,
          lng:-46.269626654684544},

          {lat:-23.991571068763733,
          lng:-46.26956488005817},

          {lat:-23.991553215309978,
          lng:-46.26950327306986},

          {lat:-23.991534942761064,
          lng:-46.26944082789123},

          {lat:-23.991516502574086,
          lng:-46.26937813125551},

          {lat:-23.991499403491616,
          lng:-46.269314931705594},

          {lat:-23.991481214761734,
          lng:-46.26925206743181},

          {lat:-23.99146386422217,
          lng:-46.269189454615116},

          {lat:-23.99144777096808,
          lng:-46.269125416874886},

          {lat:-23.9914311747998,
          lng:-46.269060960039496},

          {lat:-23.99141306988895,
          lng:-46.2689970061183},

          {lat:-23.99139454588294,
          lng:-46.26893347129226},

          {lat:-23.991376692429185,
          lng:-46.26887043938041},

          {lat:-23.991359006613493,
          lng:-46.2688088323921},

          {lat:-23.991341656073928,
          lng:-46.26874890178442},

          {lat:-23.991323970258236,
          lng:-46.26868980936706},

          {lat:-23.991306954994798,
          lng:-46.26863205805421},

          {lat:-23.991292789578438,
          lng:-46.26857430674136},

          {lat:-23.991275690495968,
          lng:-46.26851672306657},

          {lat:-23.991257082670927,
          lng:-46.26845704391599},

          {lat:-23.991233948618174,
          lng:-46.26839426346123},

          {lat:-23.991217352449894,
          lng:-46.26832712441683},

          {lat:-23.991200672462583,
          lng:-46.26826317049563},

          {lat:-23.991182735189795,
          lng:-46.26820013858378},

          {lat:-23.991159684956074,
          lng:-46.26814004033804},

          {lat:-23.991137808188796,
          lng:-46.26807952299714},

          {lat:-23.99111702106893,
          lng:-46.26801657490432},

          {lat:-23.991095814853907,
          lng:-46.267954213544726},

          {lat:-23.99107351899147,
          lng:-46.26789185218513},

          {lat:-23.991053067147732,
          lng:-46.26782823354006},

          {lat:-23.99103286676109,
          lng:-46.26776528544724},

          {lat:-23.991013756021857,
          lng:-46.26770267263055},

          {lat:-23.990994561463594,
          lng:-46.267638467252254},

          {lat:-23.990975953638554,
          lng:-46.26757333986461}];

          for(var i = 0; i < nussa.lenght;i++){
                var myLatlng = new      google.maps.LatLng(nussa[i].lat,nussa[i].lng);          
          }

  var mapOptions = {
    zoom: 16,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("map"),
    mapOptions);


}
  • 1

    All right, what’s the problem?

  • I need to make a route with this data and I can’t!

  • Right and what happens so you can’t? Put more information in your question, she yet is too vague

  • First I found nothing in the documentation that resembles what I am trying to do, another by doing so not of any error but the map n appears, I tried otherwise and the error says that it is not valid to the entries of lat and long.

  • I don’t know if I’m doing it the right way and the first time I touch the google maps api, if there are other ways and such!

1 answer

0

Your Russian variable has become positionArray... when making a code, from intuitive names to variables, especially if someone reads, a simple matter of good practice

var mapOptions = {
    zoom: 16,
    center: new google.maps.LatLng(-25.363882,131.044922),
    mapTypeId: google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map(document.getElementById("map"), mapOptions);

positionArray.forEach((position) => {
    var marker = new google.maps.Marker({
        position: new google.maps.LatLng(position.lat, position.lng),
        map: map
    });
    marker.setMap(map);
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.