Android Map Center仅在某个半径范围内

时间:2015-05-07 12:37:06

标签: java android google-maps

我正在开发一个农贸市场应用程序。我在设置恰到好处的地图时遇到了一些麻烦。我想要地图

  • 如果用户不在市场,则缩放到某个区域
  • 当用户在市场上时,缩放到他们的位置

现在看来它的工作方式是,每次打开应用程序时它总是缩放到同一个位置。即使我在市场上。

任何建议都将受到赞赏。

我已经从我项目中的maps.java文件附加了我的locationmanager。如果有帮助,我可以发布整个java文件。



LocationManager locationManager = (LocationManager)getSystemService
                (Context.LOCATION_SERVICE);
        Location location = locationManager.getLastKnownLocation
                (LocationManager.PASSIVE_PROVIDER);
        Location centLocation = new Location("");
        centLocation.setLongitude(43.074691);
        centLocation.setLatitude(-89.384152);
        if(location != null) {
            if (location.distanceTo(centLocation) < 250)
                moveToLocation(new LatLng(location.getLatitude(), location.getLongitude()), 20, 1);
            else
                moveToLocation(new LatLng(43.0746443789058, -89.3860458564343), 20, 1);
        }
        else
        {
            moveToLocation(new LatLng(43.0746443789058, -89.3860458564343), 20, 1);
            AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
&#13;
&#13;
&#13;

0 个答案:

没有答案