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.
Solved! Go to Solution.
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.
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
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.
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
Also, what version of the Runtime SDK for iOS are you using?
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.
Excellent, I'm glad you found the issue! If you have any more questions, please let us know!
Mark