LiamHarries
LiamHarries

Reputation: 580

Adding a waypoint to HERE javascript api with positions values from a variable

I have a little web app and im trying to show a navigation from the users position to the university. It all work if I hard code the longitude and latitude of the two navigation points but when I replace the number values for the first waypoint I get a routing request failed message. I have alerted the values just before declaring the waypoints so I know the variables contain the correct data.

Any help is much appreciated.

Below is the code I have

`var lat;
if (navigator.geolocation)
{
    navigator.geolocation.getCurrentPosition(function (position)
      {
          try
          {
              lat=position.coords.latitude;
              lon=position.coords.longitude;
              alert(lon+"  "+lat);

                              //THE API IS INSERTED HERE -- WAYPOINTS SECTION OF API

                              // Create waypoints
                              alert(lon+"__"+lat);
                              var waypoints = new nokia.maps.routing.WaypointParameterList();
                              waypoints.addCoordinate(new nokia.maps.geo.Coordinate(lon, lat));
                              waypoints.addCoordinate(new nokia.maps.geo.Coordinate(52.51717584105763, 13.395129026281722));

}catch(err){alert(err);}
      });
}else{alert("GPS not active");}

Upvotes: 0

Views: 262

Answers (1)

Jason Fox
Jason Fox

Reputation: 5300

When you are creating the Coordinate, you should specify the latitude first i.e Coordinate(lat,long) not Coordinate(long,lat). Since two thirds of the surface of the globe is covered in water it is likely that your rogue coordinate is not on dry land, and hence can't successfully be used for routing. As far as I know HERE haven't released a ship navigation mode into the routing API yet.

Upvotes: 1

Related Questions