【发布时间】:2019-07-04 15:26:45
【问题描述】:
很遗憾,我使用了一个 7 年前的 Google Map 代码,该代码仍在使用 V1 Map API。我计划至少将代码更改为 V2(目前)。所以我在 StackOF 的任何地方都发现了这个 -
在下面转换 -
com.google.android.maps.MapActivity --> android.support.v4.app.FragmentActivity
com.google.android.maps.MapView --> com.google.android.gms.maps.SupportMapFragment
MapView.getController() 和 MapView.getProjection() 等----> com.google.android.gms.maps.GoogleMap 对象
现在看看我的代码设计 -
下面是我的 XML 文件 -
<com.my.own.package.GoogleMapView
android:id="@+id/googleMapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:apiKey="XXXXX">
</com.my.own.package.GoogleMapView>
我的 GoogleMapView 类如下所示 -
public class GoogleMapView extends MapHelperGoogleMapView implements ViewContextMenuHandler {}
MapHelperGoogleMapView 如下所示 -
公共类 MapHelperGoogleMapView 扩展 SupportMapFragment {}
而 Activity 如下所示 -
public class GPSInfoTabActivity extends MapBridgeMapActivity
{
GoogleMap myMap;
GoogleMapView googleMapView = (GoogleMapView) getSupportFragmentManager().findFragmentById(R.id.googleMapView); // Question 1: Is this Casting correct ? Will this be properly casted ?
googleMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
gMap = googleMap; // Question 2: I want to use this gMap object to modify Map like markers, to be used in My GoogleMapView and MapHelperGoogleMapView both of class
}
});
//registerForContextMenu( googleMapView ); Question 3: This Peice of code Needed ? It came from V1 code.
}
使用了很多覆盖、绘图和 lof GeoPoints,只有当我可以访问 GoogleMap 对象到我的自定义类中时,我才能移动这部分。但目前没有任何工作。有人可以指导我吗。如果您有任何疑问以了解我的问题,请发表评论。预先感谢。
【问题讨论】:
标签: android google-maps