views:

669

answers:

1

Hi,

I have a working mapview application in which I can hit a service and show GPoints on the map as overlay.

What I want to do next is show an encoded Gpolyline as an overlay on my mapView. When I try to instantiate a GPolyline poline object in my main activity, eclipse doesnt recognize the class. Is there a library import I am missing?

A quick example of adding a GPolyline to the mapView in an android application will be a great help.

Thanks, Prachi Gupta

+2  A: 

I think the problem you're having is that there aren't GPolyline's in Android's version of Google Maps, they're Javascript/AJAX specific. What you want to do is draw out the lines manually in an Overlay or OverlayItem. See this answer, for more details on specifically how to do this.

The Hello, MapView tutorial has a short example on drawing to an Overlay and the com.google.android.maps package docs should show you what's available in Android's version of Google Maps.

fiXedd
Thank you for your response. Did you ever get rid of the sluggishness of the map when trying to add large overlays with lots of points on them?
Prachi
I could add an overlay to my map with the polyline in it with your comments. The problem now is that the overlay is obviously not anchored to the map, so when I pan the map, the overlay does not move with the map. I tried to implement an overlay item instead so that I could anchor it to a point on the map, but then I have to convert my polyline into an image and it doesnt get anchored to the right spot. Any suggestion?
Prachi