In one of my application I need to move marker on drag and drop, once user drop the pin I need to get the dropped pin location.
This is very basic feature of map but I am surprised that there is no such option in the library.
In native map there is property called "Draggable", is there any equivalent property in the Arcgis ?
With the help of ARCGIS community support, I was able to find the answer for this question.
We have to implement the method mapView:didMoveTapAndHoldAtPoint:mapPoint:features: on AGSMapViewTouchDelegate.
The delegate method gets called every time the user moves his finger while taping and holding the map view. The method also provides the array of features at that location. So in the method you can update the geometry of the features to the new mapPoint.
You can use this sample as a reference. The sample adds a marker if you tap and hold and changes the location of that marker when you move while taping and holding.
Related
using target 8.0 MapKit, I would like to define an MKAnnotation (such as a pin, or a custom one) that remains fixed on the center of the map view as the user moves the map around. Once the user stops moving the map, I would like to be able to read the new coordinates of the annotation. How can I do this? This in swift, thank you soo much
You can follow this link to accomplish this task.They are doing something very similar to your requirement. Its quite descriptive. Link
I'm making an iOS app (using Swift) that has a map in the Mapbox iOS SDK. I've gotten to the point of displaying several markers on the map. Now, I want the user to be able to select a marker from the list, panning to that marker (easy), which also makes the marker's callout bubble appear automatically without the user having to touch it (not so easy).
It's this last task I'm having trouble with. While I've found the RMMarker class's showLabel() method, I can't seem to directly access a RMAnnotation's associated RMMarker object, so I'm not sure where or how to call this method.
Does anyone know how this is done?
Ignore the showLabel() API — this is not the callout in use, but rather a text label that's possible directly on the annotation.
You probably want -[RMMapView selectAnnotation:animated:] with a NO in the animated argument.
I just started using SKMap library on IOS recently.
One behavior of the function didSelectAnnotation (from the SKMapViewDelegate Protocol), is that whenever an annotation got selected, the center of the map's visible region will move to the location of that annotation.
Is there any way that I can disable this?
It's actually not a feature of didSelectAnnotationfunction, but rather of showCalloutForAnnotation function. Just set parameter animated in the function to NO.
Ok so I have a map loaded with pins from a remote JSON feed which is loaded into the app. This all works fine.
Now from initial experimenting regionDidChangeAnimated gets called multiple times and so I moved my post request to a method that uses a drag map gesture recogniser which then performs a post request to get data from a JSON feed and reload my map pins after removing them. This also works perfectly.
Now the only issue I have left is if I select an annotation that is close to the edge of the screen the map moves slightly to accommodate the display of the annotation callout. The problem is regionDidChangeAnimated gets called when this happens however my post request doesn't as I call it using the gesture recogniser and so the map was not moved by user intervention but the OS. I don't want to move my Post request to the regionDidChangeAnimated as this gets called multiple times but I would like to know if there is a way to do a test if user caused map to move or it did it its-self to accommodate the callout as explained above. The regionDidChangeAnimated from the research I have looked at may get called more times than necessary so some guidance would be good on how to prevent that or detect user interaction vs OS moving the map.
I have a similar problem: I want do distinguish if the displayed part of a map has been changed by program or by user interaction. Apparently, MKMapView objects do not tell me so, i.e. regionDidChangeAnimated is called in both cases without an indication why.
But since MKMapView is a subclass of UIView, and this one of UIResponder, one can implement the methods touchesBegan:withEvent: and touchesEnded:withEvent: to find out, if the map has been touched during the change of the displayed region.
If so, one can assume that the change in the displayed region was caused by user interaction. Of course you can be more specific if you investigate the set of touches and the event type of these methods more precisely.
I am such a plank sometimes writing problems can help. I simply removed the regionDidChangeAnimated as I have no need for it and the code that was present there I moved to my gesture which was to removeAnnotations before re-adding them doh!
I'm making an iOS app, where I want users to mark locations on a regular basis on a map. The default way to mark location in iOS is to drop a pin either at the center of the map or where the user holds a touch (using the gesture recognizer).
Then to mark the pin to the desired location ACCURATELY, the user holds the pin and can drop it again. If you have done this on an iOS maps app, you will know it is hard to mark a location ACCURATELY, in this manner. It looks cool, but takes some trial and error in my opinion.
If I can help it, I want to make this process smoother and more obvious is my app.
So is there any other way for the user to mark a location on a map, without doing the default pin drag-drop? Any Suggestions welcome :-)
Just an idea... instead of moving the pin, you could move the map with the finger, and keep the pin always in the middle of the mapView (maybe marked with a crosshair or something). Then you can get the coordinates of the Pin using the "center" method of the mapView. That way you don't cover the pin / crosshair with your finger.
I recommend you have a look at the Maps app again. When you hold down your finger on a dropped pin, notice the location of bottom of the pin on the map. The pin actually drops in this exact location, after doing a quick bounce. The pin also sits about 20 above the users finger.
While it's not the most obvious, it's very accurate in my opinion. Enough to query the Geocoder API for an address, or just get coordinates. Keep in mind the GPS has an accuracy of 5-10 meters at the most. Zooming in will allow the user to go even more accurate.
But if this solutions isn't what you want, I'd overlay a point in the centre of the map and make sure it doesn't respond to touches, making it possible to move around the map underneath this point. When touched end, then drop a pin in the middle of the map where the point is. If touches begin again, pop out the pin from the map. I don't think a pin that's already on the map staying in place while the map moves independently will look good.