Google Maps API错误位置管理器

时间:2015-06-02 15:44:47

标签: java google-maps maps

我今天第一次使用谷歌地图API开始玩,但我已经收到错误,我不知道如何修复它。

我不知道为什么locationManager会出现此错误:cannot resolve symbol 'locationManager'

提前致谢,

有关完整代码,请转到:http://pastebin.com/7Cy8GYyF

以下是代码的一部分:

private void setUpMap() {
    mMap.addMarker(new MarkerOptions().position(new LatLng(52.279413, 5.194046)).title("l"));

    // Enable MyLocation layer of Google Map
    mMap.setMyLocationEnabled(true);

    // Get LocationManager object from System Service LOCATION_SERVICE
    LocationManager locationmanager = (LocationManager) getSystemService(LOCATION_SERVICE);

    //Create a criteria object to retrieve provider
    Criteria criteria = new Criteria();

    //get the name of the best provider
    String provider = locationManager.getBestProvider(criteria, true);

    //Get Current Location
    Location myLocation = locationManager.getLastKnownLoacation(provider);

    //set map type
    mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);


    //get latitude of the current location
    double latitude = myLocation.getLatitude();

    //get longitude of the current location
    double longitude = myLocation.getLongitude();

    //create a latlng object for current location
    LatLng latLng = new LatLng(latitude, longitude);

    //show the current location in Google Map
    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

    //zoom in the google map
    mMap.animateCamera(CameraUpdateFactory.zoomTo(20));
    mMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title("You are here"));
}

1 个答案:

答案 0 :(得分:0)

Java是大小写敏感的。您已将变量声明为“locationmanager”,并尝试将其作为“locationManager”进行访问。注意'M'的情况。