【发布时间】:2021-08-09 19:45:21
【问题描述】:
我正在尝试显示折线,但我无法让地图的标记适合我的手机屏幕。
我在 GoogleMap 中有 2 个标记。
如果两个标记距离不是很远,一切正常,两个标记在屏幕上可见。
但是如果这两个标记距离很远,那么这两个标记在屏幕上是不可见的。
下面是我的代码:
static final LatLng HAMBURG = new LatLng(46.227638, 2.213749); // for example
static final LatLng HAMBURG_2 = new LatLng(-44.339565,147.637862); // for example
MapView map;
map = findViewById(R.id.mapView);
map.onCreate(null);
map.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(final GoogleMap googleMap) {
googleMap.addMarker(new MarkerOptions()
.position(HAMBURG)
.title("First Pit Stop")
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
googleMap.addMarker(new MarkerOptions()
.position(HAMBURG_2)
.title("Wrong Turn!")
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
PolylineOptions options = new PolylineOptions().width(5).color(Color.BLACK);
options.add(pos_1, pos_2);
googleMap.addPolyline(options);
}
});
map.onResume();
}
});
如何让所有的制造商在屏幕上可见?
如何让所有的制造商都适合屏幕?
我该怎么办?
谢谢。
【问题讨论】:
标签: java google-maps google-maps-android-api-2