我也尝试过地面覆盖,但是它不起作用
我没有找到任何解决方案,请帮忙。 有人知道解决方案吗?
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
}
答案 0 :(得分:0)
简单。放大或缩小后,只需重新设置state_marker的坐标即可。
state_marker.position = CLLocationCoordinate2D(latitude: CLLocationDegrees(state.Latitude), longitude: CLLocationDegrees(state.Longitude))
答案 1 :(得分:0)
问题出在您的标记groundAnchor上,地图正确绘制了标记,但是您应该根据其图像设置每个标记groundAnchor。
地锚指定图标图像中的点 锚定到地球表面上标记的位置。这点 在连续空间[0.0,1.0] x [0.0,1.0]中指定, 其中(0,0)是图像的左上角,而(1,1)是图像的左上角 右下角。如果图片的alignmentRectInsets不为零, 上面提到的左上和右下指的是插图 图片的一部分。