用于文字叠加的自定义标记Google Maps Street View Xcode

问题描述 投票:0回答:1

是否可以在Xcode的Google Maps Street View(GMSPanoramaView)中进行自定义标记?我可以找到在常规mapView中进行自定义标记的教程,但找不到在街景视图中进行自定义标记的方法。这可能吗?

我需要在特定位置覆盖文本,据我所知,没有办法在街景视图中自动显示摘要,因此我要使用一个自定义标记,其中标记图标将是文字标签。还有其他方法可以使文字叠加在位置效果上吗?我正在使用iOS和Xcode(Swift)的Maps SDK。

如果您能提供任何见解,我将非常感谢!!非常感谢。 (顺便说一下,我在编码方面还是一个相对较新的人,所以请在建议中具体说明!)

swift xcode google-maps-markers google-maps-sdk-ios google-street-view
1个回答
0
投票

首先,如果要使用iOS版Maps SDK中的街景视图,则必须阅读有关服务的Google Maps Platform documentation,以了解更多信息。

这是我在StreetView Panorama中创建标记的代码示例片段:

import UIKit
import GoogleMaps

class ViewController: UIViewController, GMSMapViewDelegate {

 override func loadView() {
    let panoView = GMSPanoramaView(frame: .zero)
    self.view = panoView

    panoView.moveNearCoordinate(CLLocationCoordinate2D(latitude: 48.858, longitude: 2.294))
    panoView.camera = GMSPanoramaCamera(heading: 200, pitch: -10, zoom: 1)

    let position = CLLocationCoordinate2D(latitude: 48.858, longitude: 2.294)
    let marker = GMSMarker(position: position)

    // Add the marker to a GMSPanoramaView object named panoView
    marker.panoramaView = panoView
    marker.icon = UIImage(named: "marker_image")
 }
}

您会注意到marker.icon = UIImage(named: "marker_image")行,这是您在其中放置要用作标记的图像名称的地方。就我而言,我在Assets中制作了一个New Image Set,然后将要用作自定义标记的图像放入其中。

希望这会有所帮助!

© www.soinside.com 2019 - 2024. All rights reserved.