我实现了Android手机上的谷歌地图API V2,我得到了地图显示,并且还使用此代码显示的多边形:
public class MainActivity extends FragmentActivity {
Polygon polygon;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GoogleMap googleMap;
googleMap = ((SupportMapFragment)(getSupportFragmentManager().findFragmentById(R.id.map))).getMap();
LatLng latLng = new LatLng(35.20418,-90.08342);
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.addMarker(new MarkerOptions()
.position(latLng)
.title("My Spot")
.snippet("This is my spot!")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
googleMap.getUiSettings().setCompassEnabled(true);
googleMap.getUiSettings().setZoomControlsEnabled(true);
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 10));
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if(status == ConnectionResult.SUCCESS) {
//Success! Do what you want
Log.i("service", "Google play available");
}
else{
Log.i("service", "No Google play available");
}
PolygonOptions rectOptions = new PolygonOptions()
.add(new LatLng(35.25010,-90.08342),
new LatLng(35.25010,-90.04175),
new LatLng(35.29177,-90.04175),
new LatLng(35.29177,-90.08342),
new LatLng(35.25010,-90.08342));
//Set the rectangle's stroke color to red
rectOptions.strokeColor(Color.BLUE);
//Set the rectangle's fill to blue
rectOptions.fillColor(Color.CYAN);
rectOptions.strokeWidth(2);
//Get back the mutable Polygon
polygon = googleMap.addPolygon(rectOptions);
}
}
在谷歌地图API V1的onTap
方法用于与多边形的交互。 我的问题是什么让事件的onTap在版本2的最佳方式? 我读过的谷歌文档,除非我错过了,我没有看到任何东西。