Drawing area at Google Map

[亡魂溺海] 提交于 2019-12-06 07:36:34

问题


Please see the image :

alt text http://img.skitch.com/20091211-bybjj3qtasrgr1dfaf4c42p39b.jpg

Any idea how to do that? drawing an area.


回答1:


The toolkit that allows users to draw polygons on MyMaps has been made available as the GeometryControls utility library




回答2:


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




回答3:


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



回答4:


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



来源:https://stackoverflow.com/questions/1879566/drawing-area-at-google-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!