I am developing iPhone app and using google map. I used UIView for drawing region. Now I have implemented the touch event methods so how can i get longitude and latitude by view coordinates where user click on view??
As I understand your question You need to create MKMapView that will give you the map property.
https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html
Have you tried with - (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view.
It converts the specified points to coordinates point.
CLLocationCoordinate2D touchCoords = [self convertPoint:TOUCH_POINT toCoordinateFromView:YOUR_VIEW];
Related
I have a region of of a CLPlacemark declared by
let placeRegion = placemark?.region
According to the Apple docs this is
The geographic region associated with the placemark.
Is it possible to display this region on a map view?
I am not actually sure what a region of a placemark is. Does anyone know if it is just a circular region with a fixed radius around the placemark, or is the region shape sometimes tailored to match the real-life area of the place, for example, the shape of the building of the place?
Thanks
I think it would depend on the origin of the CLPlacemark. While most will come back as CLCircularRegion, you could define a custom CLRegion class that fits a different shape with multiple coordinates and map coordinates from the custom CLRegion to MKPolygon to display the region on the map view.
i am using Google Map Sdk for ios.
i want fixed the Marker at 3/4th position of screen on google map.
Now if i move(or scroll) the google map how i will get the location of fixed marker.
same like Ola Cab implementation.
Thanks in advance.
This is perfect answer for you. You see me answer...
Here you need to fix the marker position at 3/4 on maps...
Please open this link.
- (void) mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position { }
In this function we can get latitude and longitude on centre of the map.
How to move marker on the Google Map like Ola app
I'm trying to achieve as follows:
User should always be at the center of the screen on MKMapView.
Route is drawn on the map as user will move.
I know, i can calculate the region to cover all the tracked points on the screen.
But here's my problem:
When i calculate the MKCoordinateRegion and setting it, it just fits the region that is best fitting to the screen but as soon as i'm trying to place user at center, a part of the line drawn on the MKMapView goes out of the screen.
Can anybody face this problem or any suggestions to handle this specific case, any help will be highly appreciated.
Thanks in advance.
I have accomplished it as follows:
Calculate the distance of farthest point from the user's current location (or any point you want to keep at the center).
Calculate the region, with your center point(user's current location in my case) and double the distance calculated above and make a region using te following code:
CLLocationCoordinate2D loc = [myLocation coordinate];
MKCoordinateRegion region =
MKCoordinateRegionMakeWithDistance(loc, distance * 2, distance * 2);
Set the region on the MapView and the trail will be shown inside the screen keeping user's location at the center.
Thanks.
I have to set my offline map that has been constructed with tilemill centralized on a custom point. Although i did not find a method like setRegion for MKMapView to make this job for me. Is there any way to set region to a rmmapview map?
no, regions like in ios are not available in route-map. you can set constraints, so that the user cant scroll out of your map:
// Constrain our map so the user can only browse through our exported map tiles
[self.mapView setConstraintsSW:CLLocationCoordinate2DMake(self.mapSrc.bottomRightOfCoverage.latitude, self.mapSrc.topLeftOfCoverage.longitude)
NE:CLLocationCoordinate2DMake(self.mapSrc.topLeftOfCoverage.latitude, self.mapSrc.bottomRightOfCoverage.longitude)];
and of course scrolling to specific position:
[self.mapView moveToLatLong:self.currentPosition.coordinate];
I solve my issue with the code below:
CLLocationCoordinate2D centerOfMap = CLLocationCoordinate2DMake(latitude, longitude);
[mapView setCenterCoordinate:centerOfMap];
With this way i have every time my map centralized to the point that i want.
Also,someone can adjust the zoom of the map and reach the result that he wants.
I'm using Google maps sdk in ios.
I want to restrict the user from viewing other states than the states he is allowed to view. The allowed region to view on the map is given as coordinates (FarRight Latitude and Longitude), (Near Left Latitude and Longitude) and the (Center latitude and Longitude).
------X
---X---
X------
X marks the allowed map coordinates on the big map.
When the user pans the map to a coordinate outside this boundary then it has to be panned back to the old location.
But the problem is, In google maps SDK,
- (void)mapView:(GMSMapView*)mapView didChangeCameraPosition:(GMSCameraPosition*)position
The above method gives the position of the visible map coordinate. From the property "Position" we can get only the target center coordinate not the boundar coordinate. How to solve this issue ?
Thanks.