I am writing an application that requires me to show routes between a
list of cities. I have been facing difficulties with polylines for a
long time now. I am unable to see any polylines on my map. The
corresponding code for map is listed below.

map = new MapWidget();
map.setHeight("500px");
map.setWidth("600px");
map.addControl(new LargeMapControl());
map.setContinuousZoom(true);
map.setScrollWheelZoomEnabled(true);
map.setSize("100%", "100%");

and

private void drawMap2() {

        map.setUIToDefault();
        map.addMapType(MapType.getHybridMap());
        map.setCurrentMapType(MapType.getHybridMap());

   }

I use the Directions API to generate results using waypoints. This is
just a test run of the code. I had earlier tried drawing Polylines
using Polyline(LatLng path) but i faced a similar issue, i.e., no line
on display on map.


public void direct(){

       map.clearOverlays();
       final Waypoint[] wPoints = new Waypoint[2];
       wPoints[0] = new Waypoint("Bangalore");
       wPoints[1] = new Waypoint("Mysore");


        Timer t1 = new Timer(){

            @Override
            public void run() {
                DirectionQueryOptions opts = new
DirectionQueryOptions(map);
                Directions.loadFromWaypoints(wPoints,
opts,visualiseCallBack);
                this.cancel();
            }
        };

        t1.schedule(400);
      }
DirectionsCallback visualiseCallBack = new DirectionsCallback(){

        @Override
        public void onFailure(int statusCode) {
            Window.alert(""+statusCode);
        }

        @Override
        public void onSuccess(DirectionResults result) {
            PolyStyleOptions style = PolyStyleOptions.getInstance();
            style.setColor("#00FF00");
            result.getPolyline().setStrokeStyle(style);
            result.getPolyline().setVisible(true);
            System.out.println(result.getPolyline().getLength()/1000);
        }

    };

So basically markers appear on the map after adding that as overlay
but I haven't managed to make the polyline work between two points.
Can you please help me with what I have missed? Does it work in
Development mode? Could I have missed something in the css or html
file?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API V2" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en.

Reply via email to