在我的应用程序中,我使用的是Google Maps卫星视图,但没有像Google Maps Application中那样显示我镇上的所有标签。这是我的应用程序和Google Maps Application的屏幕截图:
我的应用程序:我的应用程序截图
Google Maps Application:Google Maps Application屏幕截图
这是我的代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_location_route);
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());
if (status != ConnectionResult.SUCCESS) {
int requestCode = 10;
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
dialog.show();
}
else{
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
try {
mGoogleMap = googleMap;
mGoogleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
mGoogleMap.setMyLocationEnabled(true);
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, true);
Location location = locationManager.getLastKnownLocation(provider);
if (location != null) {
onLocationChanged(location);
}
drawYourMarker(yourLocation);
drawPharmacyMarker(pharmacyLocation);
// Checks, whether start and end locations are captured
if (yourLocation != null && pharmacyLocation != null) {
String url = getDirectionsUrl(yourLocation, pharmacyLocation);
DownloadTask downloadTask = new DownloadTask();
downloadTask.execute(url);
}
} catch (SecurityException e) {
e.printStackTrace();
}
}
有什么方法可以使我的应用程序显示更多标签,例如在Google Maps应用程序中?
这是因为Google Maps应用程序使用了Google提供的所有可用API。您要查找的API是获取所有标签的Google Places API。
您必须在Google API控制台上将其打开,然后按照本教程的操作将其放置在地图上。
希望对您有所帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句