2

I am trying to add markers to Google Maps from data in my Web Service. Now how to show Marker that only in "specific radius distance". I'm trying but didn't have a logic on how to implement that in Objective-C.

Bista
  • 7,869
  • 3
  • 27
  • 55

1 Answers1

1

It works for me.Please try it.

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:(sourceValue.latValue + destinationValue.latValue)/2
                                                                        longitude:(sourceValue.lngValue + destinationValue.lngValue)/2
                                                                             zoom:7.5];

                mapview = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
                [self.view addSubview:mapview];
                GMSMarker *marker = [[GMSMarker alloc] init];
                marker.position = CLLocationCoordinate2DMake(sourceValue.latValue, sourceValue.lngValue);
                marker.map = mapview;

                //Place source mark of destination

                GMSMarker *marker2 = [[GMSMarker alloc] init];
                marker2.position = CLLocationCoordinate2DMake(destinationValue.latValue, destinationValue.lngValue);
                marker2.map = mapview;

Change your lat, lang value according to your requirements.Thanks

Sanjukta
  • 1,057
  • 6
  • 16
  • Thanks dude, it's actually noted in google maps iOS sdk documentation, my fault i didn't notice it.. now, how can i make the markers shown up only in spesific radius that i defined (e.g 50m from current location) thanks for helping :) – Indra Palijama Nov 28 '16 at 05:11
  • In addition to @Krishna's answer on how to make the markers show up only in specific radius, you can refer with these SO threads: http://stackoverflow.com/questions/24750037 and http://stackoverflow.com/questions/9056451. The [zoom](https://developers.google.com/maps/documentation/ios-sdk/views#zoom) level of the camera determines the scale of the map. You may also check this [tutorial](https://codedump.io/share/d9mqeYIVn6ua/1/how-can-i-draw-a-radius-around-a-map-marker-using-google-maps-sdk-swiftios). – abielita Nov 30 '16 at 15:43