×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    38

    Route Map is not working...

    Hi,

    For this below code, Previously it was working fine... Just today, It is not working. Is it the problem from API ? or any changes need to do for this code...?

    Please resolve the problem.



    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    	<title>Route - Nokia Maps API Example</title>	
      </head>
      <body>
    	<div id="map" style="width:800px; height:600px;"></div>
    <script src="http://api.maps.nokia.com/2.1.1/jsl.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">   
                var searchManager = new nokia.maps.search.Manager();
                searchManager.addObserver("state", function (observedManager, key, value) {
                        // If the search  has finished we can process the results
                        if (value == "finished") {
                                // We check that at least one location has been found
                                if (observedManager.locations.length == 1) {
                                       // alert (observedManager.locations[0].displayPosition); 
                                    var lat = observedManager.locations[0].displayPosition.latitude;
                                    var lon = observedManager.locations[0].displayPosition.longitude;
                                    doRouting(lat, lon);  // This is a function Call
                                } else {
                                    var lat = observedManager.locations[0].displayPosition.latitude;
                                    var lon = observedManager.locations[0].displayPosition.longitude; 
                                   // mylat = lat;
                                   doRouting(lat, lon);  // This is a function Call
                                }
                        } else if (value == "failed") {
                                alert("The search request failed.");
                        }
                });
                var proximity = {
                               // center: new nokia.maps.geo.Coordinate(28.51434, 77.01219),
                                radius: 1500 // search radius defined in meters
                        };
    
                var searchTerm = "Akdeniz";
                searchManager.geocode(searchTerm, proximity);            
         
    var map = new nokia.maps.map.Display(
    	document.getElementById("map"), {
    		components: [new nokia.maps.map.component.Behavior()],
    		zoomLevel: 11,
    		center: [38.4188500, 27.1287200]
    	}
    );
    
    function doRouting(lat, lon) {
            // Create waypoints
             var infoBubbles = new nokia.maps.map.component.InfoBubbles();
             map.addComponent( infoBubbles);
            //map.removeComponent(map.getComponentById("zoom.MouseWheel"));
            // Create a route controller
            var router = new nokia.maps.routing.Manager() 
            // Create waypoints
           // alert(lat);
           // alert(lon);
            var waypoints = new nokia.maps.routing.WaypointParameterList();
            waypoints.addCoordinate(
                    new nokia.maps.geo.Coordinate(lat,lon)
            );
            waypoints.addCoordinate(
                    new nokia.maps.geo.Coordinate(38.4188500, 27.1287200)
            );
            var modes = [{
                    type: "shortest",
                    transportModes: ["car"],
                    options: "avoidTollroad",
                    trafficMode: "default"
            }];
    
            var onRouteCalculated = function (observedRouter, key, value) {
                    if (value == "finished") {
                            var routes = observedRouter.getRoutes();
                            // Create the default map representation of a route
                            var mapRoute = new nokia.maps.routing.component.RouteResultSet(routes[0]).container; 
                            
                            mapRoute.objects.get(1).html = "\"The time has come\", the walrus said";
                            mapRoute.objects.get(1).addListener("click" , function(evt) {
                            infoBubbles.addBubble(evt.target.html, evt.target.coordinate);
                            }, false);
    
                            mapRoute.objects.get(2).html = "\"To talk of many things:";
                            mapRoute.objects.get(2).addListener("click" , function(evt) {
                            infoBubbles.addBubble(evt.target.html, evt.target.coordinate);
                            }, false);
                            
                            map.objects.add(mapRoute);                        
                            // Zoom to the bounding box of the route
                            map.zoomTo(mapRoute.getBoundingBox(), false, "default");
                    } else if (value == "failed") { 
                            alert("The routing request failed.");
                    }
            };
            // Add the observer function to the router's "state" property
            router.addObserver("state", onRouteCalculated);
            // Calculate the route (and call onRouteCalculated afterwards)
            router.calculateRoute(waypoints, modes);
    }
    </script>
            
      </body>
    </html>
    Last edited by jasfox; 2012-03-20 at 09:05. Reason: formatting.

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

    Re: Route Map is not working...

    I would suggest that you would try FireFox browser, and install the Firebug on it, then when you run the code, you could see if any parts of it is failing. Would basically enable you to pinpoint the actual problem there.

  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    38

    Re: Route Map is not working...

    If you open the page for route map, directly it is giving alert message "The search request failed". I already installed firebug and please check the previous sent code...

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

    Re: Route Map is not working...

    it actually works for me just fine, just tested with my firefox and it does give nice route reply in couple of seconds.

  5. #5
    Registered User
    Join Date
    Feb 2012
    Posts
    38

    Re: Route Map is not working...

    Here I tested in all browsers and checked in my friend system also. It is not working. what may be the reasons for this problem...?
    Last edited by Ulala; 2012-03-19 at 16:11.

  6. #6
    Registered User
    Join Date
    Feb 2012
    Posts
    38

    Re: Route Map is not working...

    Please I need answer for this issue. Here I tested in all browsers and checked in my friend system also. It is not working. what may be the reasons for this problem...

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

    Re: Route Map is not working...

    I have now tried it with two different computers, and with very different configurations for network, and it is working for me without anyn problems, thus I would not know what could be going wrong with your machine.

Similar Threads

  1. Nokia MAP : Route distance
    By binooetomo in forum [Archived] Maps API for Javascript
    Replies: 5
    Last Post: 2011-12-21, 06:44
  2. Socket route problem
    By Mikchel in forum [Archived] Qt Mobility Project
    Replies: 0
    Last Post: 2011-03-18, 08:11
  3. route and record route on 3rd edition
    By jcaradec in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2007-04-16, 19:07
  4. Record-Route and Route at SIP
    By mhappenhofer in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-11-30, 09:22

Posting Permissions

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