При уменьшении масштаба маркер меняет положение в Swift 4 - PullRequest
0 голосов
/ 30 октября 2018

Я также пробовал накладывать грунт, но он не работает

Я не нашел решения, пожалуйста, помогите. Кто-нибудь знает решение этой проблемы?

for state in self.asset {

    let state_marker = GMSMarker()

    self.appTitle = state.appName    
    if state.appName == "AssetHistory"{
        path.add(CLLocationCoordinate2D(latitude: CLLocationDegrees(state.Latitude), longitude: CLLocationDegrees(state.Longitude)))
        bounds = GMSCoordinateBounds(path: path)
        if self.asset.first?.Latitude as CGFloat! == state.Latitude && self.asset.first?.Longitude as CGFloat! == state.Longitude
        {
            state_marker.position = CLLocationCoordinate2D(latitude: CLLocationDegrees(state.Latitude), longitude: CLLocationDegrees(state.Longitude))
            state_marker.icon = UIImage(named: "arrow_blue")
            state_marker.title = "Start"
            bounds = bounds.includingCoordinate(state_marker.position)
        }
        if self.asset.last?.Latitude as CGFloat! == state.Latitude && self.asset.last?.Longitude as CGFloat! == state.Longitude
        {
            state_marker.position = CLLocationCoordinate2D(latitude: CLLocationDegrees(state.Latitude), longitude: CLLocationDegrees(state.Longitude))            
            state_marker.icon = UIImage(named: "arrow_red")
            state_marker.title = "End"
            bounds = bounds.includingCoordinate(state_marker.position)
        }
    }else{
        path.removeAllCoordinates()
        state_marker.position = CLLocationCoordinate2D(latitude: CLLocationDegrees(state.Latitude), longitude: CLLocationDegrees(state.Longitude))
        let im = UIImage(named: state.Direction)
        state_marker.icon = self.imageWithImage(image: im!, scaledToSize: CGSize(width: 100.0, height: 100.0))
        state_marker.title = "\(state.AssetName)"
        bounds = bounds.includingCoordinate(state_marker.position)
    }
    state_marker.infoWindowAnchor = CGPoint(x: 0.5, y: 0.5)
    state_marker.tracksViewChanges = true
    state_marker.map = self.mapView
    state_marker.userData = state_marker.title    
}

marker are not in position

1 Ответ

0 голосов
/ 30 октября 2018

Simple. Просто установите координаты state_marker после увеличения или уменьшения. state_marker.position = CLLocationCoordinate2D(latitude: CLLocationDegrees(state.Latitude), longitude: CLLocationDegrees(state.Longitude))

...