0

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")));
TootsieRockNRoll
  • 3,218
  • 2
  • 25
  • 50
  • 1
    You simply can create a line between two points. – AndroidHacker Jan 29 '14 at 12:29
  • how can I do it, the line I know is Polyline wich is not working correctly – TootsieRockNRoll Jan 29 '14 at 12:29
  • Also check out my post over here .. http://stackoverflow.com/questions/20901141/how-to-draw-free-hand-polygon-in-google-map-v2-in-android/20901610#20901610 and http://stackoverflow.com/questions/21034636/implementing-google-places-api/21036171#21036171 – AndroidHacker Jan 29 '14 at 12:31
  • Also check out my post over here .. http://stackoverflow.com/questions/20901141/how-to-draw-free-hand-polygon-in-google-map-v2-in-android/20901610#20901610 and http://stackoverflow.com/questions/21034636/implementing-google-places-api/21036171#21036171 – AndroidHacker Jan 29 '14 at 12:32
  • If your code does not work, you should post it – Martin Golpashin Jan 29 '14 at 12:38

2 Answers2

2

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));
Martin Golpashin
  • 1,032
  • 9
  • 28
1

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?

Community
  • 1
  • 1
Subhalaxmi
  • 5,687
  • 3
  • 26
  • 42