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.
Related
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.
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 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 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.
I know that I can use didTapAtCoordinate that will deselect the marker when I tap else where on the map.
But If there are multiple marker and I tap another one (Ex. MarkerA -> MarkerB), Is there any call back when the previous marker DidDeselect?.
I look around in GMSMapView the but can't find any thing I can use.
I want to change the marker color or image when it being selected and change it back when another marker select or the marker deselect.
Thank you.
The doco for selectedMarker says:
The marker that is selected. Setting this property selects a
particular marker, showing an info window on it. If this property is
non-nil, setting it to nil deselects the marker, hiding the info
window. This property is observable using KVO.
So, you could use Key Value Observing to be notified of changes to selectedMarker. If you use NSKeyValueObservingOptionOld when setting up KVO (described in more detail here), you will be notified of the old value, ie the marker which was deselected.