热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

使用Swift在Mapbox中为弹出窗口(SpeechBubble)创建按钮

如何解决《使用Swift在Mapbox中为弹出窗口(SpeechBubble)创建按钮》经验,请问有没有懂的朋友?

我用相同的代码发布了另一个问题,但这个问题有所不同.

我想在显示的语音气泡的右下角添加按钮

Hello World! 
Welcome to my marker!

我想知道如何将按钮放在那里,但是如果你想知道按钮会做什么,其中一个会跟踪其他用户泡泡获得多少赞成,另一个会向另一个用户发送请求.

此外,我发现这个示例看起来像是实现了一个可能更好使用的不同版本的语音气泡(弹出窗口)

import Mapbox

class ViewController: UIViewController, MGLMapViewDelegate {
    override func viewDidLoad() {
        super.viewDidLoad()

        let mapView = MGLMapView(frame: view.bounds)
        mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

        // Set the map’s center coordinate and zoom level.
        mapView.setCenter(CLLocationCoordinate2D(latitude: 40.7326808, longitude: -73.9843407), zoomLevel: 12, animated: false)
        view.addSubview(mapView)

        // Set the delegate property of our map view to `self` after instantiating it.
        mapView.delegate = self

        // Declare the marker `hello` and set its coordinates, title, and subtitle.
        let hello = MGLPointAnnotation()
        hello.coordinate = CLLocationCoordinate2D(latitude: 40.7326808, longitude: -73.9843407)
        hello.title = "Hello world!"
        hello.subtitle = "Welcome to my marker"

        // Add marker `hello` to the map.
        mapView.addAnnotation(hello)
    }

    // Use the default marker. See also: our view annotation or custom marker examples.
    func mapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView? {
        return nil
    }

    // Allow callout view to appear when an annotation is tapped.
    func mapView(_ mapView: MGLMapView, annotationCanShowCallout annotation: MGLAnnotation) -> Bool {
        return true
    }
}

下面是我希望我的预期输出看起来像近似

在此输入图像描述


推荐阅读
author-avatar
o.o
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有