TootsieRockNRoll
TootsieRockNRoll

Reputation: 3298

Android map v2 draw custom rectangle

I'm new to the google maps v2, I need to draw a rectangle from point1 to point2, with a custom color and width, I tried to use a Polyline, but all the labels (city name, country name ..) are still visible, so how can I do this ?

thank you

this is what I tried

mMapView.addPolyline(new PolylineOptions()
.add(new LatLng(xx,xx), new LatLng(xx,xx))
.width(50)
.color(Color.parseColor("#f4f3f0")));

Upvotes: 0

Views: 2433

Answers (2)

Subhalaxmi
Subhalaxmi

Reputation: 5707

Use

public class My_Map extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map_activity);
    GoogleMap map = ((MapFragment) getFragmentManager()
            .findFragmentById(R.id.map)).getMap();

    map.moveCamera(CameraUpdateFactory.newLatLngZoom(
            new LatLng(-18.142, 178.431), 2));

    // Polylines are useful for marking paths and routes on the map.
    map.addPolyline(new PolylineOptions().geodesic(true)
            .add(new LatLng(-33.866, 151.195))  
            .add(new LatLng(-18.142, 178.431)) 
            .add(new LatLng(21.291, -157.821))  
            .add(new LatLng(37.423, -122.091))  
    );
}
}

For more details just check How to draw free hand polygon in Google map V2 in Android?

Upvotes: 1

Martin Golpashin
Martin Golpashin

Reputation: 1062

Just read the Documentation

Example

GoogleMap map;
// ... get a map.
// Add a thin red line from London to New York.
Polyline line = map.addPolyline(new PolylineOptions()
   .add(new LatLng(51.5, -0.1), new LatLng(40.7, -74.0))
   .width(5)
   .color(Color.RED));

Upvotes: 2

Related Questions