Google Maps API: Bézier curve polyline wrap

后端 未结 1 495
暗喜
暗喜 2021-01-07 10:40

By using the Bezier curve polyline draw function provided by nicoabie I was able to draw a curved line from one point on the map to another. The problem is that this functio

相关标签:
1条回答
  • 2021-01-07 11:23

    Use the option third "nowrap" argument of the google.maps.LatLng class to force all the relevant points to have the same sign (set it to true, it defaults to false).

    gmarkers[10].setPosition(new google.maps.LatLng(35.689488,139.69170)); // Tokyo
    gmarkers[0].setPosition(new google.maps.LatLng(47.60621,(360-122.332071),true)); // Seattle
    boundsCenter.setPosition(new google.maps.LatLng(36.096756,(360-178.986565),true)); // control point 1
    gmarkers[6].setPosition(new google.maps.LatLng(48.511996,180)); // control point 2
    
    var curvedLine = new GmapsCubicBezier(gmarkers[0].getPosition().lat(), gmarkers[0].getPosition().lng(), boundsCenter.getPosition().lat(), boundsCenter.getPosition().lng(), gmarkers[6].getPosition().lat(), gmarkers[6].getPosition().lng(), gmarkers[10].getPosition().lat(), gmarkers[10].getPosition().lng(), 0.01, map);
    

    working fiddle

    0 讨论(0)
提交回复
热议问题