Google Maps iOS SDK - Stop deselecting marker on map tap - ios

I am adding a simple marker to my mapView, like so:
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(40.763981, -73.971647);
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.map = self.mapView;
marker.snippet = #"My Marker";
self.mapView.selectedMarker = marker;
As you can see I select the marker upon placement, however I want to keep this marker selected, showing the infoview, at all times it is on the map.
Currently, if I tap elsewhere on the map, the infoview is hidden (but the marker stays)

Related

Centering custom marker GMSMapView

I am trying to position my custom marker in iOS(Objective-C) with Google Maps.
Map view is all showing up fine with marker, however, moving the map will take the marker with it as its fetching current location. What I am looking for is the have it set to center of the map container, which will then fetch coordinates of map pin and display in search bar.
I am thinking I am doing this in reverse? I added the customer marker as a UIImage of the map container however it still does not show. Should I be getting the location from the position of the map marker, and then reverse geocoding address from there.
- (void)addPins:(float)lat andLng:(float)lng andName:(NSString*)strName withAddress:(NSString*)strAddr
{
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(currentUserLocation.coordinate.latitude, currentUserLocation.coordinate.longitude);
NSLog(#"lat : %f, lng : %f", lat, lng);
marker.icon = [UIImage imageNamed:#"map_pin"];
marker.title = strName;
marker.snippet = strAddr;
marker.appearAnimation = kGMSMarkerAnimationPop;
marker.map = mapView;
}
The user needs to be able to search and set their address, besides their current location.
Thanks
Use your mapView delegate and use the responder to re-center your pin and re-fire your geocoordinate lookup.
- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
Edit: If GMS Maps does not have these delegates, the approach may work with using whatever [mapView didUpdate]callback they have documented.
You can set GMSCameraPosition for centering your marker
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:"YOUR LATITUDE"
longitude:"YOUR LONGITUDE"
zoom:centerZoom];
"YOUT GMSMAPVIEW" = [GMSMapView mapWithFrame:"YOUR VIEW".bounds camera:camera];

Search places in Google Maps

How can I plot markers on Google Maps of all the nearby McDonald's branch (for example) wherein the user won't need to type "McDonald's", the app will automatically plot all the branches near him
Add a marker
To add a marker you create a GMSMarker object that includes a position, title and set its map.
The below example demonstrates how to add a marker to an existing GMSMapView object. The marker is created at coordinates 10,10, and displays the string "Hello world" in an info window when clicked.
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(10, 10);
GMSMarker *marker = [GMSMarker markerWithPosition:position];
marker.title = #"Hello World";
marker.map = mapView_;
you need to give coordinated to make markers or else you need find all McDonald's coordinates and use that to plot markers
http://www.distancesfrom.com/Mcdonalds-latitude-latitude-Mcdonalds-latitude-Mcdonalds-longitude/LatLongHistory/368517.aspx
Use the above link to find Mcdonalds latitude and latitude values

The distance to the marker list of google maps

I use for placing markers on the map here is a code
CLLocationCoordinate2D position2 = CLLocationCoordinate2DMake(59.957069, 30.323013);
GMSMarker *london2 = [GMSMarker markerWithPosition:position2];
london2.title = #"Офис";
london2.snippet = #"Центральный офис";
london2.map = mapView_;
Saw the application of VTB and really want to do the same - ie Whatever view one had a map and in the second list Sarker and distance to them. How do I display a list of markers and the distance of them? For example:

How to show Blinking gms marker on gmsmap view?

I am using google map , and I have used GMS Map view.In map view I have created one GMS marker for current location and it is updating every one second with current latitude and longitude value.I used this code:
mMapView = [[GMSMapView alloc]init];
mMapView.delegate = self;
mMapView.myLocationEnabled = YES;
mMapView.frame = CGRectMake(0, 95, self.view.frame.size.width,self.view.frame.size.height -205);
GMSMarker *disMarker = [GMSMarker markerWithPosition:coordinateEndLocation];
disMarker.snippet = #"current Location";
disMarker.animated = YES;
disMarker.map = mMapView;
But I want that this marker should be blinking in every second and this one in not blinking.Any Suggestions?
GMSMarker doesn't by default provides a blinking marker.. you have to create 1 by yourself.. You can try blinking marker by using a timer and changing the opacity property of your marker between 0 and 1.. - (float) opacity [read, write, assign] have a look on this property of your GMSMarker

get specific marker using his coordinates in google maps for ios

I am using Google Maps in my app for IOS. I have added several markers in a map and now I need to get a specific one using its coordinates.
I used:
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(51.5, -0.127);
GMSMarker *marker = [GMSMarker markerWithPosition:position];
but I think I need to create a new marker, not to get one created before.
One way to do this is to have an NSMutableArray of the markers and search throughout
them.
for (GMSMarker *marker in arrayOfMarkers){
if(marker.position.latitude == coordinate.latitude && marker.position.longitude == coordinate.longitude){
return marker;
}
NB this assumes that there is only one marker at this location.

Resources