简体   繁体   English

如何获取谷歌地图的可滚动和可缩放图像视图

[英]how to get scrollable and zoomable image view of google maps

I am trying to obtain a scrollable image view of google maps. 我正在尝试获取谷歌地图的可滚动图像视图。 Secondary requirements are- 次要要求是-

  1. zoom options 缩放选项
  2. Being able to put a marker on co-ordinates of my choice. 能够在我选择的坐标上标记。

    Creating a fragment containing only this image view will help me in my app. 创建仅包含此图像视图的片段将对我的应用程序有帮助。 How can this be achieved? 如何做到这一点?

Thanks 谢谢

You can use the built-in zoom controls that Maps API provides. 您可以使用Maps API提供的内置缩放控件。 These are disabled by default. 这些默认情况下是禁用的。 You can enable these by calling UiSettings.setZoomControlsEnabled(true) 您可以通过调用UiSettings.setZoomControlsEnabled(true)启用它们

For the markers, you can use the object Marker. 对于标记,可以使用对象标记。 Markers are objects of type Marker, and are added to the map with the GoogleMap.addMarker(markerOptions) method. 标记是标记类型的对象,并通过GoogleMap.addMarker(markerOptions)方法添加到地图中。 They are designed to be interactive and can be customized via the API. 它们被设计为交互式的,可以通过API进行自定义。

Below is a sample implementation of adding marker wherein a marker is created at coordinates 10,10 and displays 'Hello world" in info window when the marker is clicked. 以下是添加标记的示例实现,其中,在坐标10,10处创建了一个标记,并在单击该标记时在信息窗口中显示“ Hello world”。

@Override
public void onMapReady(GoogleMap map) {
    map.addMarker(new MarkerOptions()
        .position(new LatLng(10, 10))
        .title("Hello world"));
}

Other helpful links: 其他有用的链接:

Code snippets: https://developers.google.com/maps/documentation/android-api/map 代码段: https : //developers.google.com/maps/documentation/android-api/map
Demos and Sample Code: https://developers.google.com/maps/documentation/android-api/ (Demos and sample code section) 演示和示例代码: https : //developers.google.com/maps/documentation/android-api/ (“演示和示例代码”部分)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM