开发者

Is possible to add waypoints to Google Maps API without using JSON?

开发者 https://www.devze.com 2023-01-09 04:11 出处:网络
I\'m on ASP.NET MVC and I\'m using Google Maps API with Javascript.I send a Model to the View with one or more waypoints to add to the route.

I'm on ASP.NET MVC and I'm using Google Maps API with Javascript. I send a Model to the View with one or more waypoints to add to the route.

        function calcRoute() {
        initialize();
        var start = "<%= Model.StartAddress %>";
        var end = "<%= Model.ClientAddress %>";

        var waypts = [];

        waypts.push({
            location: "<%= Model.PickupAddress[0] %>",
            stopover:true
        });

        var request = {
            origin: start,
            des开发者_StackOverflowtination: end,
            waypoints: waypts,
            travelMode: google.maps.DirectionsTravelMode.DRIVING
        };

        directionsService.route(request, function (response, status) {
            if (status == google.maps.DirectionsStatus.OK) {
                directionsDisplay.setDirections(response);
            }
        });
    }

Is it possible to add waypoints this way with the addresses in Model.PickupAddress array? I have seen examples code by using JSON (for markers), but if I can do it directly in this Javascript code, that's fine for me.

0

精彩评论

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