最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

swift - How to attach an image to exact four coordinates in Google Maps iOS (GMSOverlay)? - Stack Overflow

programmeradmin3浏览0评论

I am trying to overlay an image on Google Maps in my iOS app using the Google Maps SDK (GMSOverlay). Instead of placing an image at a single coordinate (like with GMSMarker), I need to position an image using four exact corner coordinates, so that it scales and rotates correctly based on the map's zoom and rotation.

I found that GMSGroundOverlay allows placing an image on a map, but it seems to only support setting a center coordinate and a bounds size, which doesn’t give full control over four custom corners.

I used GMSGroundOverlay, but it only allows setting a north-east and south-west bound, not four custom points:

let southWest = CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194)
let northEast = CLLocationCoordinate2D(latitude: 37.7849, longitude: -122.4094)
let overlayBounds = GMSCoordinateBounds(coordinate: southWest, coordinate: northEast)

let overlay = GMSGroundOverlay(bounds: overlayBounds, icon: UIImage(named: "myOverlay"))
overlay.map = googleMapView

This works but doesn’t let me precisely align the image to four corner coordinates.

How can I overlay an image on Google Maps in iOS using four exact coordinates (e.g., top-left, top-right, bottom-left, bottom-right)? Is there a way to use GMSOverlay or another Google Maps API method to achieve this?

Any suggestions or workarounds would be appreciated. Thanks!

Current Result -

Expected -

I want to replace the Polygon with image that's it.

发布评论

评论列表(0)

  1. 暂无评论