`

The method setBuiltInZoomControls(boolean) is undefined for the type MapView

阅读更多
package com.googlemaps;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

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


public class MainActivity extends MapActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    MapView view= (MapView) findViewById(R.id.map);
     view.setBuiltInZoomControls(true);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}
}
Activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:name="com.google.android.gms.maps.MapFragment"
      />

 

 

解决方案:

由于我的项目在创建时的“Project Build Target"选项指定成了“Android"而没有指定为“Googlg APIs"造成的,改过来之后就解决了!

 

要新建一个target是googleAPI的模拟器

 

分享到:
评论

相关推荐

    android mapview

    mapView.setBuiltInZoomControls(true); } @Override protected boolean isRouteDisplayed() { return false; } } ``` 这里,我们继承了`MapActivity`基类,它提供了与地图交互所需的基本方法。`onCreate()`...

    Eclipse 开发 Android, Hello, MapView (学习5)

    mapView.setBuiltInZoomControls(true); mapView.onCreate(null); GoogleMap googleMap = mapView.getMap(); ``` 这里可以根据需求进一步定制地图,比如添加标记、设置初始位置等。 7. **运行与调试**:最后,...

    android WebView设置setBuiltInZoomControls(true)同时隐藏缩放按钮

    WebView设置setBuiltInZoomControls(true)后,隐藏缩放按钮的控件在webView的源码里是通过: private ZoomButtonsController mZoomButtonsController; 这个私有控件控制的,而且也没有public方法可以获得此...

    android开发培训实现GPS定位服务.docx

    public void draw(Canvas canvas, MapView mapView, boolean shadow) { super.draw(canvas, mapView, shadow); if (!shadow) { GeoPoint point = new GeoPoint(3979992, 11632923); // 示例坐标 int width = ...

    Android 百度地图 SDK v3_3_0 (一) --- 基本地图

    mapView.setMapType(BaiduMap.MAP_TYPE_NORMAL); // 设置为普通地图 setContentView(mapView); ``` 3. **BaiduMap对象的获取与配置** 通过MapView的getBaiduMap方法获取到BaiduMap对象,然后可以设置各种属性,...

    MyApplication.zip

    mapView.setBuiltInZoomControls(true); mapView.setMultiTouchControls(true); ``` 这里`TileSourceFactory.MAPNIK`是默认的在线地图源,你可以根据需要替换为其他源。 4. **处理地图事件**:你可以监听地图的...

    Google map 开发密钥

    mapView.setBuiltInZoomControls(true); // 显示内置缩放控件 mapView.setSatellite(false); // 设置卫星视图 mapView.setStreetView(false); // 设置街景模式 mapView.setTraffic(false); // 显示交通流量信息 ...

    android 连接Google map

    mapView.setMapType(MapView.MAP_TYPE_NORMAL); ``` 这将启用内置的缩放控件,并设置地图类型为普通道路视图。 此外,为了获取用户的当前位置,我们需要使用LocationManager和LocationListener。在MainActivity中...

    调用百度地图

    mapView.setBuiltInZoomControls(true); mapView.setMapType(BaiduMap.MAP_TYPE_NORMAL); // 添加到父视图 parentView.addView(mapView); ``` 地图定位是另一个常用功能。我们可以使用`BDLocation`对象来获取当前...

    com.google.android.maps.jar

    mapView.setBuiltInZoomControls(true); mapView.setMapType(GoogleMap.MAP_TYPE_NORMAL); ``` 此外,Google Maps API还允许我们添加标记(Markers)、覆盖物(Overlays)、路径(Polylines)等,以实现更丰富的...

    Android百度地图API开发[归纳].pdf

    mapView.setBuiltInZoomControls(true); // 显示缩放按钮 mapView.setZoomControlsVisibility(View.VISIBLE); // 控制默认隐藏 } // 自定义的通用事件监听器 private class MyGeneralListener implements ...

    basicuicomponents.zip

    mapView.setBuiltInZoomControls(true); mapView.setZoom(15); // 设置初始缩放级别 ``` 这里,`MyGeneralListener`是一个实现`IGeneralListener`接口的类,用于处理初始化过程中的事件。 为了在地图上显示标记、...

    BaiduMapApiDemo

    mapView.setBuiltInZoomControls(true); mapView.setTrafficEnabled(true); setContentView(mapView); ``` 四、获取定位权限 在Android 6.0及以上版本,需要动态申请定位权限。在AndroidManifest.xml中添加权限声明...

    高德android api 开发指南.docx

    mMapView.setBuiltInZoomControls(true); mMapController = mMapView.getController(); point = new GeoPoint((int) (39.982378 * 1E6), (int) (116.304923 * 1E6)); mMapController.setCenter(point); ...

    Android-基于百度地图API实现定位功能

    mapView.setBuiltInZoomControls(false); mapView.setMapType(BMapType.NORMAL); } } }); ``` 4. **开启定位服务**:要实现定位功能,需要开启百度地图的定位服务。这涉及到申请权限、创建定位管理器和监听器...

    百度地图之一百度地图搭建开发环境

    mapView.setBuiltInZoomControls(true); mapView.setZoomControlsEnabled(false); BMapManager manager = BMapManager.getInstance(this); manager.init(this, new BDInitializer()); ``` 六、使用百度地图API 1. ...

    android使用baidu map api

    public boolean onMapPoiClick(MapPoi mapPoi) { // 处理地图上的POI点击事件 return false; } @Override public void onMapClick(LatLng latLng) { // 处理地图上的空白区域点击事件 } }); ``` 以上...

    Android Map 开发之高德地图.docx

    mMapView.setBuiltInZoomControls(true); // 启用内置缩放控件 mMapController = mMapView.getController(); point = new GeoPoint((int) (39.982378 * 1E6), (int) (116.304923 * 1E6)); // 经纬度转换为微度 ...

    高德androidapi开发指引.pdf

    mMapView.setBuiltInZoomControls(true); // 更多初始化操作... } } ``` 此外,MapController是控制地图视图的重要工具,它可以用来改变地图的中心点和缩放级别。开发者还可以通过GeoPoint类来表示地图上的位置...

    迷你浏览器

    android 内嵌浏览器webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setSupportZoom(true); webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new ...

Global site tag (gtag.js) - Google Analytics