开发者

Drawing multiple route on GMAP V3 API and also more than 10 points on map?

I have tried to add multiple route on GMAP v3 API but not displaying all routes. I have put alert before $directionsDisplay.setDirections(response) and then all route are displayed......

Also I want to add more than 10 point in routes.

Source Code

function drawRouteMap()
    {
            var route_id = $(".route_detail").val();    
    $.ajax({  
                                        url: '<?php echo ROOTURL."module/tp2/Main.php?do=tp_gmap_ajax&no_doc_type=1"?>',  
                                       dataType: 'json',  
                                       type: 'POST',
                                       data: {all_stop_lat_log:'all_stop_lat_log',route_id:route_id},  
                                       async: false,  
                                       success:function(data){                                              
            if(data) {  
                var subroute_route_arr = [];
                var subroute_arr_count = 0;
                var no_of_point_in_subroute =8 ;

                var total_subroute_count = Math.ceil(parseFloat(data.length/no_of_point_in_subroute));

                    for(subroute_arr_count ; subroute_arr_count < total_subroute_count ; subroute_arr_count++)
                    {
                            var waypts = [] ;
                            var loop_count_start = subroute_arr_count * no_of_point_in_subroute  ;


                            var loop_count_end = loop_count_start+no_of_point_in_subroute;
                            var loop_count_start_val =  loop_count_start +1;
                                var loop_count_end_val = loop_count_start;                          


                            for(loop_count_start_val; loop_count_start_val<=loop_count_end; loop_count_start_val++)
                            {   
                                if(data[loop_count_start_val] != undefined){
                                    var loop_rec_latt = data[loop_count_start_val].stop_latt;
                                    var loop_rec_lang = data[loop_count_start_val].stop_lang;
                                    loop_count_end_val++;
                                    waypts.push({location:new google.maps.LatLng(loop_rec_latt,loop_rec_lang),stopover:true});  
                              开发者_运维技巧  } else {  
                                    break;
                                }

                            } 


                        alert('hi...'); //// **if this alert is removed then correct routes not displayed , by keeping the alert box only correct route is displayed,even by keeping some sort of delay instead of alert..then the correct route is not displayed....**


                    var origin_point_latt = data[loop_count_start].stop_latt;
                    var origin_point_lang = data[loop_count_start].stop_lang;

                    var destination_point_latt = data[loop_count_end_val].stop_latt;
                    var destination_point_lang = data[loop_count_end_val].stop_lang;


                                var request = {
    origin: new google.maps.LatLng(origin_point_latt,origin_point_lang), 
    destination: new google.maps.LatLng(destination_point_latt,destination_point_lang),
                                waypoints: waypts,
                                optimizeWaypoints:false,
                                travelMode: google.maps.DirectionsTravelMode.DRIVING
                            }; 

                             $directionsService_arr[subroute_arr_count].route(request, function(response, status) {
                              if (status == google.maps.DirectionsStatus.OK) {
                                $directionsDisplay_arr[subroute_arr_count].setDirections(response); 

                                }
                            }); 

                    }       


                                            } 
                                        removeAllMarkerEvent();                                                     
                                        setAllMarkerEvent();
                                        }
                                });




    }


in google maps routes you can only have 8 waypoints and 1 start and end point. when you want more than you must pay for it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜