I tried to add the simple marker on the location with the latitude and longitude. However, the marker is not showing up on the map. The following is the code to display marker.
func addSimpleMarkerSymbol() {
let symbol = AGSSimpleMarkerSymbol(style: .diamond, color: .red, size: 28)
let point = AGSPoint(x: Double(self.longitude), y: Double(self.latitude), spatialReference: .wgs84())
let graphic = AGSGraphic(geometry: point, symbol: symbol, attributes: nil)
self.graphicsOverlay.graphics.add(graphic)
self.graphicsOverlays.add(self.graphicsOverlay)
}
Solved! Go to Solution.
A few things worth checking:
mapView.graphicsOverlays.add(graphicsOverlay)
and avoid adding the graphicsOverlay multiple times.
---
Making slight change to your code and it works for me.
let point = AGSPoint(x: -118.41612, y: 33.37432, spatialReference: .wgs84())
let symbol = AGSSimpleMarkerSymbol(style: .diamond, color: .red, size: 28)
let graphic = AGSGraphic(geometry: point, symbol: symbol)
self.graphicsOverlay.graphics.add(graphic)
// Only add once for each graphics overlay.
self.mapView.graphicsOverlays.add(self.graphicsOverlay)
Are you adding the graphics overlays to the mapview?
Ryan,
Yes, the self is a mapview.
So that the self.graphicsOverlays.add(self.graphicsOverlay)
it add the graphicsOverlay variable to the mapview graphicsOverlays
A few things worth checking:
mapView.graphicsOverlays.add(graphicsOverlay)
and avoid adding the graphicsOverlay multiple times.
---
Making slight change to your code and it works for me.
let point = AGSPoint(x: -118.41612, y: 33.37432, spatialReference: .wgs84())
let symbol = AGSSimpleMarkerSymbol(style: .diamond, color: .red, size: 28)
let graphic = AGSGraphic(geometry: point, symbol: symbol)
self.graphicsOverlay.graphics.add(graphic)
// Only add once for each graphics overlay.
self.mapView.graphicsOverlays.add(self.graphicsOverlay)