Why is my google map view showing questionmarks instead of letters:
My code for implementing the map view:
let camera = GMSCameraPosition.cameraWithLatitude(-33.86,
longitude: 151.20, zoom: 6)
let mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
mapView.myLocationEnabled = true
self.view = mapView
let marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20)
marker.title = "Sydney"
marker.snippet = "Australia"
marker.map = mapView
v1.8.0 (May 2014) has an update regarding an issue raised similar to you. The ticket raised suggests it may have something to do with the language settings. So, you can check out if the language setting was changed and hopefully it solves the issue. Also check if you're using the latest version of the Maps iOS SDK.
Related
I want to display Gunshot information on the Maps app. A gunshot has 2 main properties:
location - point from which the shot was fired
direction/angle - relative to Compass North
Using the following code snippet, I can open the Maps app with a specific place-mark.
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(gps_lat.doubleValue, gps_long.doubleValue);
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:nil];
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
[mapItem setName:self.pUnit.unitLabel];
[mapItem openInMapsWithLaunchOptions:nil];
Is it possible to add angle/direction information along with the place mark? Basically the place-mark should rotate along with the map so as to clearly depict the direction of the gunshot.
you can achieve rotation of marker using google maps and rotation property of marker.
though you want obj-c code, my swift code will be helpful to understand you what I meant.
replace MARKER_IMAGE_NAME with your image
1) setup google map
let camera = GMSCameraPosition.camera(withLatitude: firstPoint.latitude,
longitude: firstPoint.longitude, zoom: 14)
let navHeight = (self.navigationController?.navigationBar.frame.size.height)! + 20
let frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height - navHeight)
let GMapView = GMSMapView.map(withFrame: frame, camera: camera)
self.view.addSubview(GMapView)
2) prepare marker
let bearing:Double = 90
var marker = GMSMarker()
marker.icon = UIImage(named: MARKER_IMAGE_NAME)
marker.appearAnimation = GMSMarkerAnimation.pop
3) apply rotation
marker.rotation = bearing
4) add marker to google map
marker.map = GMapView
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)
I am using Google Map service GMSMapview in my iOS Application. In that I have two CLLocationCoordinates. One is Current Location and other is Destination Location. I am trying to fit the map within those two places.
But the camera position is not set within those two points. I tried with the following code,
CLLocationCoordinate2D start = CLLocationCoordinate2DMake(newLoc.coordinate.latitude, newLoc.coordinate.longitude);
CLLocationCoordinate2D end = CLLocationCoordinate2DMake(_retailerVO.R_Latitude, _retailerVO.R_Longitude);
GMSCoordinateBounds *gBounds =
[[GMSCoordinateBounds alloc] initWithCoordinate:start coordinate:end];
GMSCameraPosition *gCamera = [mapView_ cameraForBounds:gBounds insets:UIEdgeInsetsZero];
mapView_.camera = gCamera;
Is there any way to achieve what I am looking for? All suggestions are appreciated.
In Swift
let bounds = GMSCoordinateBounds(coordinate: sourcePosition, coordinate: endPosition)
let camera: GMSCameraUpdate = GMSCameraUpdate.fit(bounds)
// let cameraWithPadding: GMSCameraUpdate = GMSCameraUpdate.fit(bounds, withPadding: 100.0) (will put inset the bounding box from the view's edge)
self.mapView.animate(with: camera)
Add padding with bounds, it works for me, hope it helps you,
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:start coordinate:end];
[self.viewMapView animateWithCameraUpdate:[GMSCameraUpdate fitBounds:bounds withPadding:100.0f]];
I add GMSMapView into my screen but I only can see my position icon and the marker i added. Why i cant see the road, building, etc?
Here is my code :
let camera = GMSCameraPosition.cameraWithLatitude(latitude,
longitude: longitude, zoom: 11.5)
let mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
mapView.myLocationEnabled = true
mapView.settings.myLocationButton = true
self.view = mapView
var marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(location.latitude, location.longitude)
marker.title = location.name
marker.snippet = location.address
marker.map = mapView
Any suggestion?
One of the main reason to have a blank map is that the key is not set properly
Did you set the API key correctly.
[GMSServices provideAPIKey:yourAPIKey];
I had the same issue and API key was correct. The reason was in this lines of code
[[NSUserDefaults standardUserDefaults] setValue:#"ru" forKey:#"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
I am showing google map in my app using Google Maps iOS API. I am able to show a map by giving the longitude & latitude of the place.I am using following code to show the google map.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.view = mapView_;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = #"Sydney";
marker.snippet = #"Australia";
marker.map = mapView_;
Now i want to show the map for the custom address.Please tell me how to do that?
Refer below link, implement in your code and try it. It may help to solve your problem.
https://developers.google.com/maps/documentation/geocoding/intro
You have to use "Reverse GeoCoding".
The term geocoding generally refers to translating a human-readable address into a location on a map. The process of doing the opposite, translating a location on the map into a human-readable address, is known as reverse geocoding.
All you need to do is send lat and long and get the readable address.
https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=API_KEY
for more info on "Reverse geo coding" read here.