×

Discussion Board

Results 1 to 14 of 14

Hybrid View

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    6

    Question Doubt using RouteSummary() method

    Hi,

    i'm developing a webapp and i'm having some troble with the use of the method RouteSummary() and to clear a route already routed. My code is:


    <script type="text/javascript">
    var way;
    function val(what) {
    way = what.value;
    load();
    }

    var locat = null;
    var end = null;
    var container = null;
    var map;
    var MyinfoBubbles;
    var router;
    var waypoints;
    var resum;

    //if(getUrlVars()['maps']=='nokia'||getUrlVars()['maps']=='false') {
    nokia.Settings.set( "appId", "MYKEY");
    nokia.Settings.set( "authenticationToken", "MYKEY");
    $(document).ready(function () {

    map = new nokia.maps.map.Display(document.getElementById("mapContainer"), {
    'center': [-22.9069, -47.0613],
    'zoomLevel': 17,
    components: [ new nokia.maps.map.component.Behavior() ]
    });
    load();
    });

    function load() {
    var timeoutVal = 10 ;
    navigator.geolocation.getCurrentPosition(success, error,
    { enableHighAccuracy: false, timeout: timeoutVal, maximumAge: 0 });
    }
    function error(msg) {
    switch(msg.code)
    {
    case msg.PERMISSION_DENIED:
    //alert("User denied the request for Geolocation.");
    alert("Para utilizar o CLOG é necessário aceitar o compartilhamento de sua localização.");

    break;
    case msg.POSITION_UNAVAILABLE:
    alert("O nao conseguiu obter sua localização.");

    break;
    case msg.TIMEOUT:
    //alert("The request to get user location timed out.");
    alert("O tempo maximo de busca de sua localização foi excedido.");

    break;
    case msg.UNKNOWN_ERROR:
    alert("An unknown error occurred.");

    break;
    }

    }
    function success(position) {
    var lat = position.coords.latitude;
    var lon = position.coords.longitude;
    locat = new nokia.maps.geo.Coordinate(lat, lon);
    nokia.places.search.manager.reverseGeoCode({
    latitude: lat,
    longitude: lon
    });


    var waypoints = new nokia.maps.routing.WaypointParameterList();
    waypoints.addCoordinate(locat);
    waypoints.addCoordinate(new nokia.maps.geo.Coordinate(-29.915393,-49.051036));

    var modes = [{
    type: "shortest",
    transportModes: [way],
    options: "",
    trafficMode: "default"
    }];

    router = new nokia.maps.routing.Manager();
    var onRouteCalculated = function (observedRouter, key, value) {
    if (value == "finished") {
    //map.set(null);
    var routes = observedRouter.getRoutes();
    mapRoute = new nokia.maps.routing.component.RouteResultSet(routes[0]).container;
    map.objects.add(mapRoute);
    map.zoomTo(mapRoute.getBoundingBox(), false, "default");
    } else if (value == "failed") {
    alert("The routing request failed.");
    }
    };
    router.addObserver("state", onRouteCalculated);
    router.calculateRoute(waypoints, modes.slice(0));
    //router.calculateRoute(waypoints, modes);

    }
    //}


    </script>
    <style type="text/css">
    #mapContainer {

    position:absolute;
    top:35px;
    left:0;
    display:block;
    height: 94%;
    width: 100%;

    }

    #up{
    width: 106%;
    height: 40px;
    margin-left:-10px;
    margin-top: -10px;
    text-align: center;
    letter-spacing: 30%;
    white-space: nowrap;
    overflow: hidden;
    background-color:#000;
    color:#FFF;


    }

    a:visited {color: #ffffff;}
    a:link {color: #ffffff;}
    a:bover {color: #000000;}
    a:active {color: #000000;}
    </style>

    </head>
    <body>
    <div id="up">

    <input class="button" type="button" value="pedestrian" onClick="val(this)">
    <input class="button" type="button" value="publicTransport" onClick="val(this)">
    <input class="button" type="button" value="car" onClick="val(this)">

    <div id="mapContainer"></div>

    </div>

    So, when the user clicks on the button pedestrian, publicTransport or Car, the app will trace another route with the selected option, but in my case, it traces as many as the user click, so i need to update the new route to not show the older anymore.

    In the RouteSummary() method, i want to show the average time to the user reach his destination, but i can do this because i don't know how to use it.

    Thanks a lot

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: Doubt using RouteSummary() method

    Not certain if I understood correctly, but if you want to show only one route, then you could indeed add code which would remove any old routes before you start adding new ones..

  3. #3
    Registered User
    Join Date
    Aug 2012
    Posts
    6

    Re: Doubt using RouteSummary() method

    Thats it, but in my code the old route remain even if i trace a new route. That's why i've sended my code, so anyone can show what am I doing wrong.

    Thanks a lot for the reply

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: Doubt using RouteSummary() method

    Basically things don't happen magically. Can you point our in where you are removing old content ? I can see you only adding new one with map.objects.add, but never removing anything really.

  5. #5
    Registered User
    Join Date
    Aug 2012
    Posts
    6

    Re: Doubt using RouteSummary() method

    i actually add the line "map.objects.remove(mapRoute);" just before the map.objects.add and does not work at all. I've tried the "map.update(-1)" too, but, does not work either. Can you tell my why? Is the currect way to do this ?

  6. #6
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: Doubt using RouteSummary() method

    map.objects.remove(mapRoute) you would actually use as the mapRoute, the original mapRoute one, not teh one you just constructed, thus of course that does not work. Either try checking whether there is function to clear all objects, or simply loop the objects array and remove them one-by-one (start from last to first, as usual)

  7. #7
    Registered User
    Join Date
    Aug 2012
    Posts
    1

    Re: Doubt using RouteSummary() method

    Thanks a lot

Similar Threads

  1. Doubt in destroyApp() method?
    By jayesh_nokia in forum Mobile Java General
    Replies: 2
    Last Post: 2010-08-09, 20:35
  2. Doubt on the format and downloading method
    By harinrd in forum [Archived] Flash Lite on Nokia Devices
    Replies: 2
    Last Post: 2009-06-24, 19:54
  3. Draw Method ... Basic Doubt
    By Vignesh.M in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-02-13, 12:31
  4. Replies: 0
    Last Post: 2006-01-20, 06:53
  5. passing method as parameter to another method
    By neilcoxhead in forum Mobile Java General
    Replies: 1
    Last Post: 2003-03-10, 13:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×