Please see the image :
alt text http://img.skitch.com/20091211-bybjj3qtasrgr1dfaf4c42p39b.jpg
Any idea how开发者_开发技巧 to do that? drawing an area.
The toolkit that allows users to draw polygons on MyMaps has been made available as the GeometryControls utility library
If you're looking to use Google Maps API, check the documentation about Polylines (should be what that is) : http://code.google.com/intl/pt-PT/apis/maps/documentation/overlays.html#Polylines_Overview
You need to instantiate a GPolygon object and add that (using the addOverlay method) to your GMap2 object:
var polygon = new GPolygon([new GLatLng(48.922499263758255,-94.921875),
new GLatLng(49.03786794532641,-128.671875),
new GLatLng(38.95940879245423,-126.38671875),
new GLatLng(31.95216223802497,-118.30078125),
new GLatLng(24.686952411999155,-96.50390625),
new GLatLng(28.149503211544566,-87.1875),
new GLatLng(23.725011735951796,-79.62890625),
new GLatLng(44.59046718130883,-59.765625)], "#ff0000", 5, 1, "#0000ff", 0.2);
map.addOverlay (polygon);
The first parameter is an array of points (that make up your polygon), then the stroke (that is the outline)color, weight (thickness) and opacity (how transparent), then the fill color and opacity.
Here is a cut down example:
- GPolygon example
- GPolygon source
Try this code : This really helped me
PolygonOptions rectOptions = new PolygonOptions()
.add(new LatLng(34.578289, 36.277231),
new LatLng(34.580568, 36.262041),
new LatLng(34.549016, 36.287584),
new LatLng(34.560977, 36.282660),
new LatLng(34.578289, 36.277231));
// Get back the mutable Polygon
Polygon polygon = mMap.addPolygon(rectOptions.strokeColor(Color.RED)
.fillColor(Color.BLUE));
Reference : https://developers.google.com/maps/documentation/android/shapes#customizing_appearances
where mMap is GoogleMap mMap; and add : import com.google.android.gms.maps.model.PolygonOptions;
Hope this will help you
精彩评论