swift - How to add an UIImageView in Google street view sdk for ios -


@iboutlet weak var getout: uibutton! @iboutlet weak var legstreet: uiimageview! @iboutlet weak var viewstreett: gmspanoramaview! var panoramanear: cllocationcoordinate2d! override func viewdidload() {     super.viewdidload()     panoramanear = cllocationcoordinate2dmake(30.274262, -97.752371)     //var panoramanear = self.tmpstring     var panoview = gmspanoramaview.panoramawithframe(cgrectzero,         nearcoordinate:panoramanear)             self.viewstreett = panoview     // additional setup after loading view. } 

when write this, street view can't show. , have revise self.viewstreett = panoview self.view = panoview. @ time uiimageview disappear. question how add uiimageview streetview , don't disturb use of street view.

your viewstreet loading gmspanoramaview, because has no coordinate. can not make loading gmspanoramaview equals panoview(viewstreet = panoview wont work).

instead, can change type of viewstreet uiview, behavior container view of panoview. can viewstreet.addsubview(panoview) add panoview container.

sample code:

    @iboutlet weak var viewstreet: uiview!     @iboutlet weak var sampleimageview: uiimageview!     var panoview: gmspanoramaview!      override func viewdidload() {         super.viewdidload()          let panoramanear = cllocationcoordinate2dmake(30.274262, -97.752371)          panoview = gmspanoramaview.panoramawithframe(cgrectzero,             nearcoordinate:panoramanear)          viewstreet.addsubview(panoview)         viewstreet.sendsubviewtoback(panoview)          let equalwidth = nslayoutconstraint(item: panoview, attribute: .width, relatedby: .equal, toitem: viewstreet, attribute: .width, multiplier: 1.0, constant: 0)         let equalheight = nslayoutconstraint(item: panoview, attribute: .height, relatedby: .equal, toitem: viewstreet, attribute: .height, multiplier: 1.0, constant: 0)         let top = nslayoutconstraint(item: panoview, attribute: .top, relatedby: .equal, toitem: viewstreet, attribute: .top, multiplier: 1.0, constant: 0)         let left = nslayoutconstraint(item: panoview, attribute: .left, relatedby: .equal, toitem: viewstreet, attribute: .left, multiplier: 1.0, constant: 0)          panoview.settranslatesautoresizingmaskintoconstraints(false)         nslayoutconstraint.activateconstraints([equalwidth, equalheight, top, left])     } 

if using autolayout in app, should add width, height, top , left constraints panoview.

you can view sample app in this github page.

in simulator screenshot below, add marker image on top of panoview. enter image description here


Comments