I am using google maps in my app. I am using a single marker. I want two things
When I tap on any location on map, My marker should animated to that position automatically. I am successful in this.
When I Long tap on the marker, it should animate up and move with my touch. when i release the touch, it should drag there.
I am having problem in the 2nd case. I have set the draggable property of the marker to true. Nothing else code is written . When i long tap on it, instead of the marker, whole map along with map moved up and then marker move acc to my touch. When i release the touch whole map along with marker move down slightly.
Any Suggestions Please?
In GMSMapDelegate, these are the methods related to dragging.
- (void)mapView:(GMSMapView *)mapView didBeginDraggingMarker:(GMSMarker *)marker;
- (void)mapView:(GMSMapView *)mapView didEndDraggingMarker:(GMSMarker *)marker;
- (void)mapView:(GMSMapView *)mapView didDragMarker:(GMSMarker *)marker;
But you need to set marker draggable. By default, marker is not draggable.
marker.draggable=YES;
You have to press-and-hold on the marker before it will begin dragging.
I had also implemented this feature of dragable marker in google maps.
Now, according to your 2 point in question above, the up-down movement of map with marker on longpress and release, this is inbuilt feature of google maps library.
I think up-down movement of map along marker is to clearly show full marker to users when they long press o marker.
sometimes, marker icons are small which can be hidden by our fingers while long press and we can't see the marker to drag and place to another position.
To avoid this type of issue, google maps had added this feature.
Related
I have successfully managed to implement draggable annotations by using this link https://docs.mapbox.com/ios/maps/examples/draggable-views/. However, these annotations become draggable only after long pressing on them. I am looking for a solution wherein the annotations become draggable as soon as they are added to the map. Thanks a lot for helping :)
Ended up coming up with my own implementation to suit my needs. Heres how I went about it:-
Add the UIPanGestureRecognizer on the annotation view of the annotation that needs to be dragged.
In the gesture recognizer, convert the in-screen gesture location to real-world coordinates using the mapView.convert(point, mapView) method. Use these coordinates to update the location of the dragged coordinate
Use the started and the ended state property of the gesture recognizer to determine the start and end of the drag gesture.
I am implementing Google maps in my ios application where there are multiple Markers on it when a user taps I want to get the marker id so that I can take the data to the next screen. How can I achieve it
I have tried my luck in userdata and accessabilitylabel but when i tap on the same marker the id changes like first it prints 1 and then 2 if i tap on it again.
I want to get that Particular marker id am using array to show multiple markers.
Thanks in advance
when you tap on any marker
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(nonnull GMSMarker *)marker;
This Method called at that time.
You can get marker on Tap, you can check Position (marker.position.latitude,marker.position.longitude)
with your array and find the solution.
I'm working on an app (iOS 7) which is using Google Maps (v1.8.1). I'm trying to implement a feature, where You would have a polygon in the map, and when you double tap it - it zooms to the polygon. I've read around that I could disable zooming gestures in the map, via googleMapView.settings.zoomGestures = NO;, but I don't want to lose zoomGestures at all (You can zoom in using double tap (when not double tapping on the polygon) or pinch to zoom). I've tried adding a GestureRecognizer, but the method for the recognizer gets called after the zoom happens (GMSMapViewDelegate method willMove gets called first). How would I go about this?
I have many markers in GMSMapView. I want to know which marker is tapped.
I know that there is - (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker delegate. But my problem is when i tap any marker, i will show different information for every marker in infoWindow. So, i must know which marker is tapped.How can i do this?
When you create the marker, set its userData property to an instance of your own class which stores data about the marker.
Then in didTapMarker, you can get out the userData property, cast it to your own type, and then extract the details you need.
You can set the accessibilityLabel property of marker during its creation from your data.
For example you are creating the markers from an array of objects then set the marker.accessibilityLabel of each marker as its position in your array so when user is going to tap on any marker, just find its accessibilityLabel and so find the data from array at this position.
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.