gpt4 book ai didi

android - 每秒更新当前位置后如何停止放大谷歌地图?

转载 作者:行者123 更新时间:2023-11-29 00:21:13 34 4
gpt4 key购买 nike

<分区>

我开发了一个 Android 应用程序,可以每秒获取用户当前位置。但是在每秒更新一次位置时,每次更新时它都会放大 2x 所以请帮我设置恒定的缩放级别,它不会在每秒更新后缩放

//code to get and send location information

// create class obj

gps = new GPSTracker(MainActivity.this);

// check if GPS enabled
if (gps.canGetLocation()) {

latitude = gps.getLatitude();
longitude = gps.getLongitude();


// marker options
position = new LatLng(latitude, longitude);

// Instantiating MarkerOptions class
options = new MarkerOptions();

// Setting position for the MarkerOptions
options.position(position);

// Setting title for the MarkerOptions
options.title("Position");

// Setting snippet for the MarkerOptions
options.snippet("Latitude:" + latitude + ",Longitude:"
+ longitude);

// mapppppppppppp
try {
// Loading map
initilizeMap();

// moving to lat long location

// Adding Marker on the Google Map
googleMap.addMarker(options);

// Creating CameraUpdate object for position
CameraUpdate updatePosition = CameraUpdateFactory
.newLatLng(position);

// Creating CameraUpdate object for zoom
CameraUpdate updateZoom = CameraUpdateFactory.zoomBy(2);

// 2 is zoomlevel on every update it is going zoom in and in
// latitude and longitude
googleMap.moveCamera(updatePosition);

// Applying zoom to the marker position
googleMap.animateCamera(updateZoom);

} catch (Exception e) {
e.printStackTrace();
}

// \n is for new line
Toast.makeText(
getApplicationContext(),
"Your Location is - \nLat: " + crsp
+ "\nLong: " + longitude,
Toast.LENGTH_LONG).show();

} else {
// can't get location
// GPS or Network is not enabled
// Ask user to enable GPS/network in settings
gps.showSettingsAlert();
}

// new sendLocation().execute();

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