gpt4 book ai didi

java - 叠加层在 Google MapView 教程 Android 中不起作用

转载 作者:行者123 更新时间:2023-12-02 08:34:41 25 4
gpt4 key购买 nike

当我要集成叠加层时,按照 MapView 教程遇到了一些错误。

TravelBuddy.java

package com.jappapps.android.travelbuddy;
import java.util.List;

import android.graphics.drawable.Drawable;
import android.os.Bundle;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class TravelBuddy extends MapActivity {
List<Overlay> mapOverlays;
Drawable drawable;
Overlays itemizedOverlay;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); // changed to lowercase
MapView mapView = (MapView) findViewById(R.id.mapview); // match id in main.xml
mapView.setBuiltInZoomControls(true);
mapOverlays = mapView.getOverlays();
drawable = this.getResources().getDrawable(R.drawable.androidmarker);
itemizedOverlay = new Overlays(drawable);
}

@Override
protected boolean isRouteDisplayed() {
return false;
}
}

Overlays.java

 package com.jappapps.android.travelbuddy;

import java.util.ArrayList;

import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class Overlays extends ItemizedOverlay {
public Overlays(Drawable arg0) {
super(arg0);
Object overlayitem;
ItemizedOverlay.addOverlay(overlayitem);
Object itemizedoverlay;
ArrayList<OverlayItem> mapOverlays;
mapoverlays.add(itemizedOverlay);
}
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
super(boundCenterBottom(defaultMarker));
public void addOverlay(OverlayItem overlay) {
mOverlays.add(overlay);
populate();}
@Override
protected OverlayItem createItem(int i) {
return mOverlays.get(i);

}
@Override
public int size() {
return 0;
}
}

抱歉,如果我看起来像个新手,但我正在努力学习,并且我得到了一个很棒的应用程序创意,需要 map View 、 WebView 、叠加层和选项卡。

最佳答案

@覆盖 公共(public) int 大小() { 返回 mOverlays.size(); }

关于java - 叠加层在 Google MapView 教程 Android 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2274910/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com