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
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
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
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"
how can i use bing maps to draw a route line between two points. i can do that by calling url like:
http://www.bing.com/maps/default.aspx?v=2&lvl=10&dir=0&sty=r&rtp=pos.16.955542_54.73933~pos.17.002046_54.049973
but those urls are not accessible from iphone uiwebview. bing is showing its main page instead.
i tried the bing ios sdk but could not find the way to do this.
If you're still going down the webview route - I'd suggest trying it again, as support for redirecting desktop URLs to mobile equivalents might have been added since.
As long as the right user agent is associated with the request to identify the device as an iPhone, the URL above should get rewritten to something like:
http://m.bing.com/maps/default.aspx?v=2&lvl=10&dir=0&sty=r&rtp=pos.16.955542_54.73933~pos.17.002046_54.049973&mid=10006
and load the mobile directions experience.
Alternatively, go to m.bing.com and follow the directions link and retrieve the mobile-specific URL pattern you're interested in, which doesn't rely on redirecting desktop URLs ... example:
http://m.bing.com/directions#/Maps?w=a.seattle~a.san%20francisco&ul=47.60336588,-122.02145731&mode=1