我正在加载Google地图,地图加载正常,但所有内容都没有缩放到位置,出于某种原因我的自动完成功能停止了工作。
我已将活动转换为片段以用于记忆目的,任何人都有任何想法,为什么它不会放大?这是我在地图片段中的代码:
async void AutoCompleteOption_Click(object sender, AdapterView.ItemClickEventArgs e)
{
//to soft keyboard hide
InputMethodManager inputManager = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService);
inputManager.HideSoftInputFromWindow(txtSearch.WindowToken, HideSoftInputFlags.NotAlways);
map.Clear();
if (txtSearch.Text != string.Empty)
{
var builtString = new StringBuilder();
builtString.Append(strGeoCodingUrl);
builtString.Append("?address=").Append(txtSearch.Text);
string stringResult = await fnDownloadString(builtString.ToString());
if (stringResult == "Exception")
{
Toast.MakeText(Activity, "Unable to connect to server!!!", ToastLength.Short).Show();
}
objGeoCodeJSONClass = JsonConvert.DeserializeObject<GeoCodeJSONClass>(stringResult);
LatLng Position = new LatLng(objGeoCodeJSONClass.results[0].geometry.location.lat, objGeoCodeJSONClass.results[0].geometry.location.lng);
updateCameraPosition(Position);
MarkOnMap("MyLocation", Position);
}
}
public void OnMapReady(GoogleMap googleMap)
{
map = googleMap;
var locationManager = Activity.GetSystemService(Context.LocationService) as LocationManager;
if (locationManager.AllProviders.Contains(LocationManager.NetworkProvider)
&& locationManager.IsProviderEnabled(LocationManager.NetworkProvider))
{
locationManager.RequestLocationUpdates(LocationManager.NetworkProvider, 2000, 1, this);
}
else
{
Toast.MakeText(Activity, "The Network Provider does not exist or is not enabled!", ToastLength.Long).Show();
}
map.MapType = GoogleMap.MapTypeNormal;
map.MyLocationEnabled = true;
}
答案 0 :(得分:0)
//放大,为相机设置动画。
map.animateCamera(CameraUpdateFactory.zoomIn());