Как исправить перегруженность прямых линий Google Maps Polyline? - PullRequest
0 голосов
/ 25 марта 2020

Я использую полилинию карт Google, чтобы нарисовать путь над картой. Все хорошо, но кажется, что в некоторых местах он показывает несколько прямых линий. Проверьте изображение в приложении.

Я не могу прикрепить изображение из-за меньшей репутации. пожалуйста, нажмите, чтобы увидеть.

Вы можете видеть на изображении, что маркеры размещены точно, но не знаете, что происходит с полилиниями.

Я ссылался на эти решения, но никогда не получал никакой помощи.

  1. Нарисована необъяснимая дополнительная полилиния - API Карт Google v3
  2. Проблема с полилинией карты Google
  3. Удалите прямую линию в пути Google Map, используя javascript

Ниже приведен код:

    //Initializing map
    var locations = [
        ["Start point at Bopal Lake City Travels (Pick up By Auto/Van) (04:30 PM) [23.0161,72.5928]", "23.0161", "72.5928"],
        ["End point at Station road polo victory\t (09:20 AM) [26.9214,75.7974]", "26.9214", "75.7974"],
        ["Point at ISKCON Cross Road, Iskcon BRTS Bus Stop.(Pick Up By Auto/Van) (16:45:00 PM) [23.0273,72.5085]", "23.0273", "72.5085", "http://maps.google.com/mapfiles/ms/icons/orange-dot.png"],
        ["Point at Patel Travels, Ratnamani Complex, Satellite Road (Pick Up By Auto) (16:55:00 PM) [23.0263,72.5252]", "23.0263", "72.5252", "http://maps.google.com/mapfiles/ms/icons/orange-dot.png"],
        ["Point at Jhansi ki Rani BRTS Corridor, Opp. Nehru Nagar Bus Stand, Ahmedabad (17:10:00 PM) [23.0231,72.5363]", "23.0231", "72.5363", "http://maps.google.com/mapfiles/ms/icons/orange-dot.png"],
        ["Point at IntrCity SmartBus Lounge Paldi (17:30:00 PM) [23.0153,72.5632]", "23.0153", "72.5632", "http://maps.google.com/mapfiles/ms/icons/orange-dot.png"],
        ["Point at ST Shri Jain Travels (Pick Up By Auto/Van) (17:40:00 PM) [23.0201,72.5938]", "23.0201", "72.5938", "http://maps.google.com/mapfiles/ms/icons/orange-dot.png"],
        ["Point at Sahibaugh namaste circle (18:30:00 PM) [23.0431,72.5894]", "23.0431", "72.5894", "http://maps.google.com/mapfiles/ms/icons/orange-dot.png"],
        ["Point at Memco Ranawat Travels (18:15:00 PM) [23.0549,72.631]", "23.0549", "72.631", "http://maps.google.com/mapfiles/ms/icons/orange-dot.png"],
        ["Point at Gurukripa Travels, Nr. Naroda Patiya Circle, Opp. S.T Workshop, Naroda, Ahmedabad (18:25:00 PM) [23.0655,72.6427]", "23.0655", "72.6427", "http://maps.google.com/mapfiles/ms/icons/orange-dot.png"],
        ["Point at  Naroda Bethak Gulsan Travels (18:30:00 PM) [23.0722,72.6485]", "23.0722", "72.6485", "http://maps.google.com/mapfiles/ms/icons/orange-dot.png"],
        ["Point at Nana Chiloda Keshav Tours & Travels (18:40:00 PM) [23.1121,72.6736]", "23.1121", "72.6736", "http://maps.google.com/mapfiles/ms/icons/orange-dot.png"]....
    var map = new google.maps.Map(document.getElementById('map'), {
        zoom: 16,
        center: new google.maps.LatLng(locations[0][1], locations[0][2]),
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        zoomControl: 1,
        panControl: !1,
        disableDoubleClickZoom: true,
        scaleControl: !0,
        scaleControlOptions: {position: google.maps.ControlPosition.BOTTOM_LEFT},
        zoomControlOptions: {position: google.maps.ControlPosition.TOP_RIGHT},
        streetViewControl: !1
      });

      // Placing markers
      var infowindow = new google.maps.InfoWindow();
      var marker, i;
      for (i = 0; i < locations.length; i++) {
        marker = new google.maps.Marker({
          position: new google.maps.LatLng(locations[i][1], locations[i][2]),
          icon: locations[i][3],
          map: map
        });
        google.maps.event.addListener(marker, 'mouseover', (function(marker, i) {
          return function() {
            infowindow.setContent(locations[i][0]);
            infowindow.open(map, marker);
          }
        })(marker, i));
        google.maps.event.addListener(marker, 'mouseout', (function(marker, i) {
          return function() {
            infowindow.close(map, marker);
          }
        })(marker, i));
      }

      //Polyline Code
      var flightPlanCoordinates = [{"lat":23.68178368,"lng":73.3649292},{"lat":23.68178368,"lng":73.3649292},{"lat":23.68211174,"lng":73.36606598},{"lat":23.68241882,"lng":73.36714172},{"lat":23.68241882,"lng":73.36714172},{"lat":23.6826725,"lng":73.3680954},{"lat":23.68301582,"lng":73.3693161},{"lat":23.68344498,"lng":73.37083435},{"lat":23.68344498,"lng":73.37084198},{"lat":23.68371582,"lng":73.37143707},{"lat":23.68387413,"lng":73.37171936},{"lat":23.68423271,"lng":73.37225342},{"lat":23.68522453,"lng":73.37348175},{"lat":23.68522644,"lng":73.37348175},{"lat":23.68622971,"lng":73.37474823},{"lat":23.68709373,"lng":73.37572479},{"lat":23.68709373,"lng":73.37572479},{"lat":23.68791771,"lng":73.37660217},{"lat":23.68807602,"lng":73.37683868},{"lat":23.68820953,"lng":73.37711334},{"lat":23.68831253,"lng":73.37739563},{"lat":23.68842506,"lng":73.37791443},{"lat":23.68843269,"lng":73.37811279},{"lat":23.68850136,"lng":73.37839508},{"lat":23.68850136,"lng":73.37839508},{"lat":23.68861198,"lng":73.37859344},{"lat":23.68872833,"lng":73.37875366},{"lat":23.68881416,"lng":73.37884521},{"lat":23.68890381,"lng":73.37895966},{"lat":23.68899155,"lng":73.37911987},{"lat":23.68909454,"lng":73.3792572},{"lat":23.68909454,"lng":73.3792572},{"lat":23.68931389,"lng":73.37970734},{"lat":23.68934441,"lng":73.37981415},{"lat":23.68941689,"lng":73.37993622},{"lat":23.68944359,"lng":73.38013458},{"lat":23.68945312,"lng":73.38030243},{"lat":23.68942451,"lng":73.38047028},{"lat":23.68944359,"lng":73.38063049},{"lat":23.68944359,"lng":73.38063049},{"lat":23.68943024,"lng":73.38078308},{"lat":23.68939018,"lng":73.38092804},{"lat":23.6893692,"lng":73.38106537},{"lat":23.68934059,"lng":73.3812027},{"lat":23.68927956,"lng":73.38140869},{"lat":23.68927956,"lng":73.38140869},{"lat":23.68897247,"lng":73.38247681},{"lat":23.68897247,"lng":73.38247681},{"lat":23.68868637,"lng":73.3835144},{"lat":23.68855095,"lng":73.38401794},{"lat":23.68836403,"lng":73.38489532},{"lat":23.68838882,"lng":73.38507843},{"lat":23.68842888,"lng":73.38526917},{"lat":23.68842888,"lng":73.38526917},{"lat":23.6884861,"lng":73.38544464},{"lat":23.68863869,"lng":73.38578033},{"lat":23.68874741,"lng":73.38592529},{"lat":23.68885994,"lng":73.38603973},{"lat":23.6891098,"lng":73.38620758},{"lat":23.68925858,"lng":73.3862381},{"lat":23.68941689,"lng":73.38626099},{"lat":23.68941689,"lng":73.38626099},{"lat":23.69036102,"lng":73.38641357},{"lat":23.690588,"lng":73.38643646},{"lat":23.6905899,"lng":73.38643646},{"lat":23.74006844,"lng":73.42392731},{"lat":23.74006844,"lng":73.42392731},{"lat":23.73686981,"lng":73.41983032},{"lat":23.73789406,"lng":73.42114258},{"lat":23.73898125,"lng":73.42253876},{"lat":23.74006844,"lng":73.42392731},{"lat":23.74072266,"lng":73.42477417},{"lat":23.74072266,"lng":73.42477417},{"lat":23.68344498,"lng":73.37083435},{"lat":23.68371582,"lng":73.37143707},{"lat":23.68387413,"lng":73.37171936},{"lat":23.68423271,"lng":73.37225342},{"lat":23.68522453,"lng":73.37348175},{"lat":23.68622971,"lng":73.37474823},{"lat":23.68709373,"lng":73.37572479},{"lat":23.68791771,"lng":73.37660217},{"lat":23.74147797,"lng":73.42572021},{"lat":23.74196243,"lng":73.426651},{"lat":23.74204063,"lng":73.42706299},{"lat":23.74147797,"lng":73.42572021},{"lat":23.74172592,"lng":73.42608643},{"lat":23.7419014,"lng":73.42645264},{"lat":23.74196243,"lng":73.426651},{"lat":23.74204063,"lng":73.42706299},{"lat":23.74206543,"lng":73.42773438},{"lat":23.74203682,"lng":73.42796326},{"lat":23.74198532,"lng":73.42819214},{"lat":23.74111557,"lng":73.43011475},{"lat":23.74067307,"lng":73.4310379},{"lat":23.74047661,"lng":73.43149567},{"lat":23.74047661,"lng":73.43149567},{"lat":23.7404213,"lng":73.43172455},{"lat":23.74040222,"lng":73.4319458},{"lat":23.74040604,"lng":73.43215179},{"lat":23.68807602,"lng":73.37683868},{"lat":23.68820953,"lng":73.37711334},{"lat":23.68831253,"lng":73.37739563},{"lat":23.68842506,"lng":73.37791443},{"lat":23.68843269,"lng":73.37811279},{"lat":23.68850136,"lng":73.37839508},{"lat":23.68861198,"lng":73.37859344},{"lat":23.68872833,"lng":73.37875366},{"lat":23.7404747,"lng":73.43264008},{"lat":23.74053001,"lng":73.43276215},{"lat":23.74061584,"lng":73.4328537},{"lat":23.74071693,"lng":73.43292999},{"lat":23.74093246,"lng":73.43310547},{"lat":23.74093437,"lng":73.43310547},{"lat":23.68881416,"lng":73.37884521},{"lat":23.68890381,"lng":73.37895966},{"lat":23.68899155,"lng":73.37911987},{"lat":23.68909454,"lng":73.3792572},{"lat":23.68931389,"lng":73.37970734},{"lat":23.68934441,"lng":73.37981415},{"lat":23.68941689,"lng":73.37993622},{"lat":23.68944359,"lng":73.38013458},{"lat":23.74116325,"lng":73.43328857},{"lat":23.74129486,"lng":73.4333725},{"lat":23.74217796,"lng":73.433815},{"lat":23.68945312,"lng":73.38030243},{"lat":23.68942451,"lng":73.38047028},{"lat":23.68944359,"lng":73.38063049},{"lat":23.68943024,"lng":73.38078308},{"lat":23.68939018,"lng":73.38092804},{"lat":23.6893692,"lng":73.38106537},{"lat":23.68934059,"lng":73.3812027},{"lat":23.68927956,"lng":73.38140869},{"lat":23.74217796,"lng":73.433815},{"lat":23.7430439,"lng":73.43425751},{"lat":23.68897247,"lng":73.38247681},{"lat":23.68868637,"lng":73.3835144},{"lat":23.68855095,"lng":73.38401794},{"lat":23.68836403,"lng":73.38489532},{"lat":23.68838882,"lng":73.38507843},{"lat":23.68842888,"lng":73.38526917},{"lat":23.6884861,"lng":73.38544464},{"lat":23.68863869,"lng":73.38578033},{"lat":23.68874741,"lng":73.38592529},{"lat":23.68885994,"lng":73.38603973},{"lat":23.6891098,"lng":73.38620758},{"lat":23.68925858,"lng":73.3862381},{"lat":23.68941689,"lng":73.38626099},{"lat":23.69036102,"lng":73.38641357},{"lat":23.690588,"lng":73.38643646},{"lat":23.69151306,"lng":73.38653564},{"lat":23.74384308,"lng":73.43467712},{"lat":23.74384308,"lng":73.43467712},{"lat":23.69247246,"lng":73.38671875},{"lat":23.69293785,"lng":73.38677979},{"lat":23.69301605,"lng":73.38677216},{"lat":23.69343758,"lng":73.38677216},{"lat":23.69444275,"lng":73.38690948},{"lat":23.69530678,"lng":73.38705444},{"lat":23.69578552,"lng":73.38716888},{"lat":23.69628716,"lng":73.38735962},{"lat":23.74443245,"lng":73.4349823},{"lat":23.74455261,"lng":73.43508148},{"lat":23.74467468,"lng":73.43518829},{"lat":23.74482727,"lng":73.43528748},{"lat":23.69678307,"lng":73.38761902},{"lat":23.6980896,"lng":73.3884964},{"lat":23.69956017,"lng":73.38946533},{"lat":23.70085144,"lng":73.39022064},{"lat":23.70154762,"lng":73.39052582},{"lat":23.70227242,"lng":73.39074707},{"lat":23.70301628,"lng":73.3908844},{"lat":23.70376015,"lng":73.39093018},{"lat":23.74517822,"lng":73.43547058},{"lat":23.74517822,"lng":73.43547058},{"lat":23.74627686,"lng":73.43605042},{"lat":23.70512962,"lng":73.39086914},{"lat":23.70664215,"lng":73.39073944},{"lat":23.70817757,"lng":73.39058685},{"lat":23.70967484,"lng":73.39045715},{"lat":23.71029091,"lng":73.39046478},{"lat":23.7109108,"lng":73.39056396},{"lat":23.71248055,"lng":73.39098358},{"lat":23.71399498,"lng":73.39144897},{"lat":23.74757004,"lng":73.43674469},{"lat":23.71427155,"lng":73.39160156},{"lat":23.71453094,"lng":73.39178467},{"lat":23.71567345,"lng":73.39277649},{"lat":23.71662903,"lng":73.39360809},{"lat":23.71755409,"lng":73.39439392},{"lat":23.71852684,"lng":73.3952713},{"lat":23.71945953,"lng":73.39608002},{"lat":23.72032928,"lng":73.39683533},{"lat":23.74757004,"lng":73.43675232},{"lat":23.7490139,"lng":73.43751526},{"lat":23.72120094,"lng":73.39763641},{"lat":23.72187805,"lng":73.39823151},{"lat":23.72197151,"lng":73.39826965},{"lat":23.72205162,"lng":73.39827728},{"lat":23.72210884,"lng":73.39826965},{"lat":23.72212601,"lng":73.39826202},{"lat":23.72223091,"lng":73.39821625},{"lat":23.72230721,"lng":73.39813995},{"lat":23.75060654,"lng":73.43832397},{"lat":23.75060844,"lng":73.43832397},{"lat":23.7223587,"lng":73.3980484},{"lat":23.72232246,"lng":73.39807129},{"lat":23.72327423,"lng":73.39954376},{"lat":23.72395897,"lng":73.40013885},{"lat":23.72500229,"lng":73.40097809},{"lat":23.72584534,"lng":73.40168762},{"lat":23.72676659,"lng":73.40254974},{"lat":23.72746849,"lng":73.40312195},{"lat":23.75218582,"lng":73.43911743},{"lat":23.72817802,"lng":73.40377808},{"lat":23.72842216,"lng":73.40407562},{"lat":23.72868156,"lng":73.40444183},{"lat":23.72876358,"lng":73.40457916},{"lat":23.72889709,"lng":73.40481567},{"lat":23.72906685,"lng":73.40518188},{"lat":23.72920418,"lng":73.40555573},{"lat":23.72959137,"lng":73.40657043},{"lat":23.75349236,"lng":73.4397583},{"lat":23.75349426,"lng":73.4397583},{"lat":23.73003197,"lng":73.40763092},{"lat":23.73023796,"lng":73.40827942},{"lat":23.7303257,"lng":73.40871429},{"lat":23.73056984,"lng":73.40936279},{"lat":23.7310009,"lng":73.41044617},{"lat":23.7313633,"lng":73.41136932},{"lat":23.73171425,"lng":73.41223145},{"lat":23.73192406,"lng":73.41252899},{"lat":23.75437164,"lng":73.4401474},{"lat":23.73197746,"lng":73.41255951},{"lat":23.73232651,"lng":73.41336823},{"lat":23.73266029,"lng":73.41426086},{"lat":23.73283195,"lng":73.41464233},{"lat":23.73295021,"lng":73.41483307},{"lat":23.73323631,"lng":73.41521454},{"lat":23.73403931,"lng":73.41622925},{"lat":23.73497009,"lng":73.41738892},{"lat":23.75531387,"lng":73.44050598},{"lat":23.75531387,"lng":73.44051361},{"lat":23.73589897,"lng":73.4185791},{"lat":23.74184418,"lng":73.42860413},{"lat":23.7414608,"lng":73.42940521},{"lat":23.74111557,"lng":73.43011475},{"lat":23.75584602,"lng":73.44069672},{"lat":23.75596428,"lng":73.44071198},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.7562809,"lng":73.44078827},{"lat":23.75663948,"lng":73.44098663},{"lat":23.75675392,"lng":73.44104004},{"lat":23.75709534,"lng":73.44117737},{"lat":23.75709534,"lng":73.44117737},{"lat":23.75732231,"lng":73.4413147},{"lat":23.75786591,"lng":73.44166565},{"lat":23.75855064,"lng":73.44197083},{"lat":23.75855064,"lng":73.44197083},{"lat":23.7592926,"lng":73.44241333},{"lat":23.75946045,"lng":73.44250488},{"lat":23.76015282,"lng":73.44298553},{"lat":23.76015472,"lng":73.44298553},{"lat":23.76028061,"lng":73.44309998},{"lat":23.76033592,"lng":73.44313049},{"lat":23.76065826,"lng":73.44326782},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.7608242,"lng":73.44337463},{"lat":23.76147842,"lng":73.44379425},{"lat":23.76163292,"lng":73.44390106},{"lat":23.76163292,"lng":73.44390106},{"lat":23.76170921,"lng":73.44394684},{"lat":23.76192093,"lng":73.4440918},{"lat":23.76196098,"lng":73.44412231},{"lat":23.76206779,"lng":73.44415283},{"lat":23.76215172,"lng":73.4442215},{"lat":23.76215363,"lng":73.4442215},{"lat":23.76253128,"lng":73.44450378},{"lat":23.7626133,"lng":73.44458771},{"lat":23.7626133,"lng":73.44458771},{"lat":23.76315117,"lng":73.44509888},{"lat":23.76315117,"lng":73.44509888},{"lat":23.76351738,"lng":73.44541931},{"lat":23.76361465,"lng":73.44558716},{"lat":23.76369095,"lng":73.44577026},{"lat":23.76374817,"lng":73.44602966},{"lat":23.76376724,"lng":73.44629669},{"lat":23.76372719,"lng":73.44660187},{"lat":23.76365089,"lng":73.44685364},{"lat":23.76353455,"lng":73.44706726},{"lat":23.76336098,"lng":73.44723511},{"lat":23.7631588,"lng":73.44737244},{"lat":23.7631588,"lng":73.44737244},{"lat":23.76293755,"lng":73.44747925}.......
      var flightPath = new google.maps.Polyline({
        path: flightPlanCoordinates,
        geodesic: true,
        strokeColor: '#2f6682',
        strokeOpacity: 1.0,
        strokeWeight: 4,
        icons: [{
          icon: lineSymbol,
          offset: '100%'
        }]
      });
      flightPath.setMap(map);


  [1]: https://i.stack.imgur.com/a4gtf.png
...