Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7580991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:05:15+00:00 2026-05-30T18:05:15+00:00

This code was written for me and used to work, but now the multiple

  • 0

This code was written for me and used to work, but now the multiple waypoints are not working.
The waypoints are stored as |51.105166,-1.695971|51.105166,-1.695971| in the database.
With only 1 waypoint the maps work, but with more than one they do not show up at all.

Does anybody have any suggestions?

It can be viewed at the link here.
http://www.ridersguide.co.uk/2012/Ride_234

var directionDisplay;
var geocoder;
var directionsService = new google.maps.DirectionsService();
var latlng = new google.maps.LatLng(54.559322587438636, -4.1748046875);
function load() {
   geocoder = new google.maps.Geocoder();
   directionsDisplay = new google.maps.DirectionsRenderer();
  var myOptions = {
  zoom: 6,
  mapTypeId: google.maps.MapTypeId.ROADMAP,
 center: latlng,
  mapTypeControl: true,
  mapTypeControlOptions: {
  style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
  position: google.maps.ControlPosition.TOP_RIGHT
  },      

navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.ZOOM_PAN,
position: google.maps.ControlPosition.TOP_LEFT}
  };
    var map = new google.maps.Map(document.getElementById('map'), myOptions);
    directionsDisplay.setMap(map);
    directionsDisplay.setPanel(document.getElementById("directionsPanel"));

var directionRendererOptions ={
    suppressMarkers: true,
    polylineOptions:{
        strokeColor: "#FF0000",
        strokeOpacity: 1,
        strokeWeight: 3
        }
    };

directionsDisplay.setOptions(directionRendererOptions);


            var start = '<?php echo $start; ?>';
            var end = '<?php echo $end; ?>';
            <?php
            if($via != null){
            echo "var points = [";
            foreach($via as $point){
            if($point != ""){
            echo "{location:";
            echo " '".$point."'";
            echo "}";
            }   
            }
            echo "];\n";
            }
            ?>

            var request = {
                origin:start,
                waypoints: points,
                destination:end,
                travelMode: google.maps.DirectionsTravelMode.DRIVING
            };
            directionsService.route(request, function(response, status) {
                if (status == google.maps.DirectionsStatus.OK) {
                    directionsDisplay.setDirections(response);

                }

            });

        geocoder.geocode( { 'address': start}, function(results, status) {
         var routeStart = new google.maps.Marker({
        map: map, 
        position: results[0].geometry.location,
        icon: './images/motorcycling.png',
        shadow: './images/motorcycling.shadow.png'
    });

});
    geocoder.geocode( { 'address': end}, function(results, status) {
         var routeEnd = new google.maps.Marker({
        map: map, 
        position: results[0].geometry.location,
        icon: './images/motorcyclingend.png',
        shadow: './images/motorcycling.shadow.png'
    });

}); 
<?php`
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:05:17+00:00Added an answer on May 30, 2026 at 6:05 pm

    It appears there’s a comma missing in your array.

    var points = [{location: '51.105166,-1.695971'}{location: '51.105166,-1.695971'}];
    

    should be

    var points = [{location: '51.105166,-1.695971'},{location: '51.105166,-1.695971'}];
    

    One way of doing that is to construct that string entirely in php rather than output it piecemeal, and then remove the initial comma you don’t need. I’ve edited this code following the comments received, so just the locations between the [ ] are constructed and the comma removed:

    <?php
                if($via != null){
                $pointstring='';
                foreach($via as $point){
                if($point != ""){
                $pointstring.= ",{location:";
                $pointstring.= " '".$point."'";
                $pointstring.= "}";
                }   
                }
                echo "var points = [".substr($pointstring,1)."];\n";
                }
                ?>
    

    (Code not tested)

    There are other ways of outputting the locations piecemeal as you had, but the requirement to have commas between them and not at the end makes it more complex than simply removing one you don’t need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written this sample code to print the length of x. But for some
My eclipse used to work fine but now I am no longer the administrator
This originally was a problem I ran into at work, but is now something
I have this code written in .NET 4.0 using VS2010 Ultimate Beta 2: smtpClient.Send(mailMsg);
I've written this code to try and send a url as a post value
I have written this code to join ArrayList elements: Can it be optimized more?
I have written this code to convert string in such format 0(532) 222 22
I've sometimes seen code written like this : public class B1 { } public
I have this code in my ASP.NET application written in C# that is trying
i'm wondering about this possibility. Is it possible to make our code written in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.