I want to show directions from my current location to an address in my app.
I can successfully open the directions by using:
Get directions
But once open I cannot return to my app. Is there a way to close the map again?
*note I appreciate this will only work correctly on iOS, I will handle android separately.
you should be able to do it with comgooglemaps-x-callback:
https://developers.google.com/maps/documentation/ios/urlscheme#specify_a_callback_url
this example opens Google Maps on iOS with a call back to chrome:
comgooglemapsurl://maps.google.com/maps?f=d&daddr=Tokyo+Tower,+Tokyo,+Japan&sll=35.6586,139.7454&sspn=0.2,0.1&nav=1&x-source=Chrome&x-success=googlechrome://?resume=true
Related
I'm working on an iOS app where I need to open Google Maps to navigate to a location. I'm using the Scheme for iOS comgooglemaps:\\
Here is my code :
guard let url = URL(string: "comgooglemaps://?saddr=&daddr=\(latitude),\(longitude)&directionsmode=\(travelMode)"), UIApplication.shared.canOpenURL(url) else {
return
}
UIApplication.shared.open(url)
But the problem is, once on Google Maps, the route is not showing on the map and Google Maps is loading forever if Google Maps wasn't already started. I'm using iOS 14.4.1.
This happen using the current user location and I need it
Edit for Universal Link: That's an idea too and I forgot to precise that I test it but there is a bug too. When the user doesn't accept location on Google Maps, instead of asking to complete the form for the origin point and set the destination, Google Maps return a totally blank form. On Android, the destination is set.
As per documentation, you can also use https:// links, as Maps support universal links. This seems to work fine, even while the comgooglemaps:// url fails to load directions. Check docs for information on individual parameters. Here's an example matching your query:
https://www.google.com/maps/dir/?api=1&destination=\(latitude),\(longitude)&travelmode=\(travelMode)
I have been trying just about every tutorial I can find but I have no luck rendering the google map tiles behind the map in the view. I have double checked google console etc. But I have no luck
As you can see I can get the location to load up correctly, but the actual map behind it doesn't work at all. I have run out of ideas :(
try
check it on real device
double check that API Key of google maps correct and you enable google maps form google console
self.view = mapView in didLayoutSubView Method
Im calling google maps directions from my app and im leaving the saddr as directed by google so it will locate the user's location asthe starting point and give directions to the daddr specified.
The problem is....
The first time u use it and some other times.. Google maps doesnt locate well and give wrong directions asif you where located someplacr else. How can i keep this from happening ?????????
What i have tried is leaving the saddr and guide by google url scheme so google maps will autolocate the user starting point and give the directions to the destination point. Its got it completly wrong
My Iphone app needs to open the google maps application to use the StreetView and the directions mode.
All works fine,But my question is, is there any way of adding a button or something to go back to my app?. I have seen that with UIWebViews maybe thats the only solution..
Thanks in advance
My answer comes from this documentation: Google Maps SDK for iOS, Google Maps URL Scheme
You may add a back button if you register a custom URL scheme for your app and use the comgooglemaps-x-callback:// url scheme to launch the Google Maps iOS app.
Here is a great tutorial for iOS Custom URL Schemes.
The following string would open Google Maps with directions to JFK airport and would add a button in Google Maps with the title "AirApp".
Touching that button would call the custom url scheme sourceapp:// which you would set up by following the tutorial I linked to above.
#"comgooglemaps-x-callback://?daddr=John+F.+Kennedy+International+Airport,+Van+Wyck+Expressway,+Jamaica,+New+York&x-success=sourceapp://?resume=true&x-source=AirApp"
I have a google map that I created with KML:
Here is a link to the map:
http://goo.gl/maps/dkfjU
Here is the complete KML file:
https://dl.dropbox.com/u/94943007/02bb39645a3c9d95afeed5cb9bd5d07c040d8ca8a4ee56b9fb367d38.kml
When browsing this map with my IPAD using safari, for some reason when I tap anywhere on the map, it creates a point there on the map.
How do I disable point creation on the map so that IPAD users are not able to do this?
I checked the link as well and Marcelo seems to be correct. To have a maps with the ability to turn on and off layers you will need to build your own site and perhaps use Javascript and the Google-maps API to build it. Maybe start here: https://developers.google.com/maps/documentation/javascript/tutorial
You cannot disable adding a place mark if you are browsing the map in safari
You can control it if you use map kit iOS API of the iOS SDK.
For importing KML-Data into that SDK, you can use Sample Code from
Apple:
http://developer.apple.com/library/ios/#samplecode/KMLViewer/Introduction/Intro.html
But there is no built-in KML Import in iOS SDK. You can use other
frameworks as mapbox/Simple-KML here
https://github.com/mapbox/Simple-KML
If you want to do this in safari, then you're lost, unless you can manipulate that using JavaScript!!!