MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Route with maps in java web app

This is a discussion on Route with maps in java web app within the MapPoint Web Service and Virtual Earth forums, part of the Map Forums category; Hello all, I am trying to develop a typical hotel type app where the user can enter an address and ...


Go Back   MapPoint Forums > Map Forums > MapPoint Web Service and Virtual Earth

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-08-2006
Junior Member
White Belt
 
Join Date: May 2006
Posts: 4
Route with maps in java web app

Hello all,

I am trying to develop a typical hotel type app where the user can enter an address and get directions to the hotel. If they click another link they can get the directions with turn by turn maps. I have this working but it is slow. If you check out the results on the Marriott site it takes about 4-6 seconds to get the directions with maps. It takes my app around 10-18 seconds. About 4-5 seconds is used getting the directions and the main route map, the rest of this time is spent making the calls to get the urls for the images on the jsp page.

This is the code I use to get my route. fromLocation and toLocation are Location objects.

Code:
        
SegmentSpecification[] routeSegmentSpec = new SegmentSpecification[2];
        routeSegmentSpec[0] = new SegmentSpecification();
        Waypoint startWP = new Waypoint();
        startWP.setLocation(fromLocation);
        startWP.setName("Start");
        startWP.setSnap(SnapType.Normal);
        routeSegmentSpec[0].setWaypoint(startWP);

        routeSegmentSpec[1] = new SegmentSpecification();
        Waypoint endWP = new Waypoint();
        endWP.setLocation(toLocation);
        endWP.setName("End");
        endWP.setSnap(SnapType.Normal);
        routeSegmentSpec[1].setWaypoint(endWP);

        SegmentOptions routeOptions = new SegmentOptions();
        routeOptions.setCalculateDirectionMapView(Boolean.TRUE);//FALSE
        routeOptions.setCalculateSegmentMapView(Boolean.FALSE);//FALSE
        routeOptions.setPreference(SegmentPreference.Quickest);
        routeSegmentSpec[0].setOptions(routeOptions);
        routeSegmentSpec[1].setOptions(routeOptions);

        RouteSpecification routeSpec = new RouteSpecification();
        routeSpec.setDataSourceName(dsname);
        ArrayOfSegmentSpecification segmentSpecArr = new ArrayOfSegmentSpecification();
        segmentSpecArr.setSegmentSpecification(routeSegmentSpec);
        routeSpec.setSegments(segmentSpecArr); 

        Route route = routeService.calculateRoute(routeSpec);
Here is the code where I get the array of Direction objects:
Code:
            Direction[] directions = route.getItinerary().getSegments().getSegment(0).getDirections().getDirection();

            ImageFormat format = new ImageFormat();
            format.setHeight(new Integer(routeToVO.getMapImageHeight()));
            format.setWidth(new Integer(routeToVO.getMapImageWidth()));         


            MapOptions mapOptions = new MapOptions();
            mapOptions.setIsOverviewMap(new Boolean(routeToVO.getIsOverviewMap()));
            mapOptions.setStyle(MapStyle.fromString(routeToVO.getDefaultMapStyle()));
            mapOptions.setFontSize(MapFontSize.fromString(routeToVO.getFontSize()));
            mapOptions.setRouteHighlightColor(RouteHighlightColor.fromString(routeToVO.getRouteHighlightColor()));
            mapOptions.setConstructionDelayHighlightColor(RouteHighlightColor.fromString(routeToVO.getConstructionDelayHighlightColor()));
            mapOptions.setConstructionClosureHighlightColor(RouteHighlightColor.fromString(routeToVO.getConstructionClosureHighlightColor()));         
            mapOptions.setReturnType(MapReturnType.ReturnUrl);        

            mapOptions.setFormat(format);


            MapSpecification mapSpec = new MapSpecification();
            mapSpec.setRoute(route); 
            mapSpec.setDataSourceName(dsname);
            mapSpec.setOptions(mapOptions);

            ArrayOfMapImage mapImages = new ArrayOfMapImage();        
            mapImages.setMapImage(renderService.getMap(mapSpec).getMapImage());

            MapImage[] myMapImages = mapImages.getMapImage();

            String mapurl = mapImages.getMapImage(0).getUrl();         

            HashMap dirs = new HashMap();
            dirs.put("mapurl", mapurl);
            dirs.put("directions",  directions);
            dirs.put("route", route);
This is where I get the map urls on the jsp. I originally did it in the previous code but am currently testing on the jsp. I am looping through an ArrayList containing the Direction array. x is what would be the index of the Direction array through the loop.

Code:
            MapView[] mapView = new MapView[1];
            mapView[0] = route.getItinerary().getSegments().getSegment(0).getDirections().getDirection(x).getView().getByHeightWidth();
            ArrayOfMapView mapViewArray = new ArrayOfMapView();
            mapViewArray.setMapView(mapView);
  
            spec.setViews(mapViewArray);
  
            MapImage[] mapImages = renderService.getMap(spec).getMapImage();           
            for(int i = 0; i < mapImages.length; i++){
                MapImage mapImage = mapImages[i];
                map = mapImage.getUrl();               
            }
Any suggestions as to how I can optimize this to get the segment maps more quickly?

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
app, java, maps, route, web


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Using MapPoint 2003 with Java Anonymous MapPoint 2006/2009 Discussion 3 09-19-2008 12:46 PM
java issue Anonymous MapPoint 2006/2009 Discussion 1 03-01-2005 06:11 PM
compatibility java and asp Anonymous MapPoint 2006/2009 Discussion 3 04-19-2004 12:03 PM
Java - Tomcat is working Anonymous MapPoint 2006/2009 Discussion 1 01-30-2003 08:22 AM
something like mappoint, but for java... Joeba MapPoint 2006/2009 Discussion 2 12-03-2002 10:14 AM


All times are GMT -5. The time now is 12:23 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55