文件说,航点限制是8分.但我必须从超过50个航路点找到最佳航路点订单列表.怎么做?
我可以通过使用开始+目的地+ 8个航点找到航点订单但是我需要超过50个航点的帮助
我正在使用此示例来设置包含8个以上标记的路径.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Google Maps JavaScript API v3 Example: Directions Waypoints</title>
<style>
#map{
width: 100%;
height: 450px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
jQuery(function() {
var stops = [
{"Geometry":{"Latitude":52.1615470947258,"Longitude":20.80514430999756}},
{"Geometry":{"Latitude":52.15991486090931,"Longitude":20.804049968719482}},
{"Geometry":{"Latitude":52.15772967999426,"Longitude":20.805788040161133}},
{"Geometry":{"Latitude":52.15586034371232,"Longitude":20.80460786819458}},
{"Geometry":{"Latitude":52.15923693975469,"Longitude":20.80113172531128}},
{"Geometry":{"Latitude":52.159849043774074, "Longitude":20.791990756988525}},
{"Geometry":{"Latitude":52.15986220720892,"Longitude":20.790467262268066}},
{"Geometry":{"Latitude":52.16202095784738,"Longitude":20.7806396484375}},
{"Geometry":{"Latitude":52.16088894313116,"Longitude":20.77737808227539}},
{"Geometry":{"Latitude":52.15255590234335,"Longitude":20.784244537353516}},
{"Geometry":{"Latitude":52.14747369312591,"Longitude":20.791218280792236}},
{"Geometry":{"Latitude":52.14963304460396,"Longitude":20.79387903213501}}
] ;
var map = new window.google.maps.Map(document.getElementById("map"));
// new up complex objects before passing them around
var directionsDisplay = new window.google.maps.DirectionsRenderer();
var directionsService = new window.google.maps.DirectionsService();
Tour_startUp(stops);
window.tour.loadMap(map, directionsDisplay); …Run Code Online (Sandbox Code Playgroud) 我们有json.在json有10纬度和10经度google.maps.DirectionsResult.MAX_WAYPOINTS_EXCEEDED.我们尝试在这些点之间绘制线.但是我们得到了状态代码.所以在删除了两个点之后.现在我们试图画出8点之间的线,它工作得很好.但是在json中,有一段时间经过50到100纬度和经度.我们试过这样的
var aa=waypts[0].location.k;
var bb=waypts[0].location.D;
var cc=waypts[waypts.length-1].location.k
var dd=waypts[waypts.length-1].location.D;
var start1= new google.maps.LatLng(aa,bb);
var end1=new google.maps.LatLng(cc, dd);
var request = {
origin: start1,
destination: end1,
waypoints: waypts,
optimizeWaypoints: true,
travelMode: google.maps.TravelMode.DRIVING
};
debugger;
directionsService.route(request, function(response, status) {
debugger;
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
var route = response.routes[0];
}
});
Run Code Online (Sandbox Code Playgroud)
首先告诉我如何在8点以上划线.请指导我
我需要在地图方向上填充以下数据
dataset 1
[
[lat, lon],
[lat, lon],
[lat, lon],
],
dataset 2
[
[lat, lon],
[lat, lon],
[lat, lon],
],
So On ...
Run Code Online (Sandbox Code Playgroud)
所有数据集都应具有具有唯一颜色的路线,并且任何数据集都可以超过 8 个航点限制。我能够通过遵循https://lemonharpy.wordpress.com/2011/12/15/working-around-8-waypoint-limit-in-google-maps-directions-api/等在线教程来修复 8 个路点限制在 Google 地图 v3 中绘制超过 8 个航点。
但我发现没有办法为每个数据集获取不同颜色的路线。
这是我的代码
<style>
#map {
height: 1080px;
width: 100%;
border: 1px solid #000;
}
</style>
<div id="map"></div>
<script>
function initMap() {
//console.log("sdsfsd");
map = new google.maps.Map(document.getElementById('map'), {
zoom: 14,
center: {lat: 28.6247, lng: 77.3731},
disableDefaultUI:true,
//28.6247375!4d77.3731819
});
var directionsService = new …Run Code Online (Sandbox Code Playgroud)