我的问题是,有没有人知道如何设置谷歌地图,打开我的位置和放大视图?
目前,主视图向非洲开放,一路缩小.
所以我一直在寻找几天,我能找到的是:
1)你不能在一个谷歌地图中动画两件事(比如放大并转到我的位置)?因此,如果我可以在设置动画之前弄清楚如何设置缩放,那么这个问题就可以解决了.这往往是问题,你可以改变一个,但不能两者兼而有之.
2)我发现其他可能有用的类,但是如何设置代码没有任何帮助,因此类可以操纵谷歌地图.
这是迄今为止我一直坚持的代码,有些是作品,有些则不然.我认为有些可能会在以后有用.
package com.MYWEBSITE.www;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import android.content.Context;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class MainActivity extends FragmentActivity {
private GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_layout);
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
map.setMyLocationEnabled(true);
//LocationSource a = (LocationSource) getSystemService(Context.LOCATION_SERVICE);
//LocationManager b = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
//map.setLocationSource(a);
Criteria criteria = new Criteria();
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
String provider = locationManager.getBestProvider(criteria, false);
Location location …
Run Code Online (Sandbox Code Playgroud)