i am implementing an iOS application, and i want to set the user location programmatically. i have tried mapView.
mapView.userLocation.location.coordinate=CLLocationCoordinate2DMake(latFloat, longFloat);
it tells that this is assigned to readonly property.
so how to assign the user location programmatically? aiming to show the blue point at a custom location.
As far as I know you can’t. That property is for the user location, not an arbitrary point. You should use MKAnnotation and it’s associated classes for such a thing. If you wanted to do a kind of point with a pulsing circle similar to the user location you may find an custom MKOverlay more suitable. Be warned though multiple MKOverlays will crash your application in which case you want to draw the many things in one MKOverlayView using an MKOverlayPathView.
** As an aside, for testing in the simulator you can pass in an arbitrary list of points to the simulator that it will feed into the app as the userlocation. This is solely for testing various map related code though and won’t actually help or work in ‘the real world’**
Something like, assuming ‘annotations’ is an NSMutableArray containing your annotations.
I’m not currently in a position to test this but will do later.