我正在尝试在地图上放置一个标记,然后显示标记。我很难过。如果我使用此代码,则首先显示标记,然后替换为以美国为中心的地图。
public void showOnMap(Coord location) {
Form mapDemo = new Form("Maps", new LayeredLayout());
if (BrowserComponent.isNativeBrowserSupported()) {
System.out.println("Browser Component Supported");
MapContainer mc = new MapContainer(MAPS_KEY);
mapDemo.add(mc);
Container markers = new Container();
markers.setLayout(new MapLayout(mc, markers));
mapDemo.add(markers);
Coord moscone = new Coord(37.7831, -122.401558);
//Coord moscone = new Coord(location);
Button mosconeButton = new Button("");
mosconeButton.setUIID("Label");
FontImage.setMaterialIcon(mosconeButton, FontImage.MATERIAL_PLACE);
markers.add(moscone, mosconeButton);
mc.zoom(moscone, 5);
mc.setCameraPosition(moscone);
//mc.setShowMyLocation(true);
} else {
// iOS Screenshot process...
mapDemo.add(new Label("Loading, please wait...."));
}
mapDemo.show();
}
答案 0 :(得分:0)
这对我有用,我希望能为你效劳。
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 10);
map.animateCamera(cameraUpdate);