AGSPictureMarkerSymbol is moving from its plotted position while zooming in/out.

675
6
Jump to solution
04-04-2022 08:07 PM
Tarak-Kar
New Contributor III

Hello, I am using AGSMapView and plotting to show Picture Marker Symbols. Here is my code to create online map and plot picture symbols,

      

     IBOutlet private weak var mapView: AGSMapView!

     private let graphicsOverlay = AGSGraphicsOverlay()

 

     // Loading online map

     let portalItem = AGSPortalItem(portal: portal, itemID: Constants.portalItemIdentifier)

     let onlineMap = AGSMap(item: portalItem)

     mapView.map = onlineMap

    // Adding picture marker symbol

   

     let pinSymbol = AGSPictureMarkerSymbol(image: dislayImage)      

      pinSymbol.width = 40

      pinSymbol.height = 40

            // change offsets, so the symbol aligns properly to the point

            pinSymbol.offsetY = pinSymbol.image!.size.height / 2

            

            // location for pin

            guard let latitude = mapObj.latitude, let longitude = mapObj.longitude else {

                continue

            }

            loc = CLLocationCoordinate2DMake(latitude.doubleValue(), longitude.doubleValue())

            let pinPoint = AGSPoint(clLocationCoordinate2D: loc!)

            

            // graphic for pin

            let graphic = AGSGraphic(geometry: pinPoint, symbol: pinSymbol, attributes: nil)

            // add the graphic to the overlay

            self.graphicsOverlay.graphics.add(graphic)           

           self.mapView.graphicsOverlays.add(self.graphicsOverlay)

 

 

I have also attached a short video to explain the issue.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Tarak-Kar
New Contributor III

I managed to fix this issue 🙂

This issue happened due to the high image dimension. I have resized the image, then it is working as expected.

Thanks.

View solution in original post

0 Kudos
6 Replies
MarkDostal
Esri Contributor

Hello, thank you for your question!  I suspect the problem lies with how you are creating the point geometry.  You don't have to create an intermediate CLLocation, but instead you can create the point using your lat/long values directly.  See the AGSPointMakeWGS84 method.  The important thing is that the spatial reference of the coordinates you are using and the SpatialReference of the point created match.  If they do, you shouldn't see the "movement" of your graphic in the overlay.

Please let us know if that doesn't work for you.  Good luck!

Mark

Tarak-Kar
New Contributor III

Hello MarkDostal, thanks for your answer. As u suggested I have changed my code as given below,

 

let pinPoint = AGSPointMakeWGS84(latitude.doubleValue(), longitude.doubleValue())

let graphic = AGSGraphic(geometry: pinPoint, symbol: pinSymbol, attributes: ["index": i])

But still, I am facing the same issue. 

Thanks.

0 Kudos
MarkDostal
Esri Contributor

Sorry to hear that didn't resolve your problem.  Can you send some sample lat/long values that you are using as inputs when initializing the "AGSPoint" and also any specifics of the basemap in your map (Are you using an AGOL basemap? What's the basemap's Spatial Reference?).

Thanks,

Mark

0 Kudos
MarkDostal
Esri Contributor

Also, what version of the Runtime SDK for iOS are you using?

0 Kudos
Tarak-Kar
New Contributor III

I managed to fix this issue 🙂

This issue happened due to the high image dimension. I have resized the image, then it is working as expected.

Thanks.

0 Kudos
MarkDostal
Esri Contributor

Excellent, I'm glad you found the issue!  If you have any more questions, please let us know!

Mark

0 Kudos