I have a html page that shows the directions from the current location to a certain address.
I would like to do the same but use the map app instead of showing it in a browser.
When I use :
<script>
document.location = "geo:0,0?q=myaddress";
</script>
That works fine but does not show me the route.
What I read from this : Android Google Directions Service usable natively? with wrapper framework? Public transit/biking directions available?
It should be possible using this code :
String url = "http://maps.google.com/maps?saddr=some+address&daddr=another+Address"
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
Can I do the same just using javascript ?
Android is capable of detecting links to Google Maps in the browser and redirect the Intent to the native Google Maps app, if it is set as the default app. There is, however, no way to force the user to use the Google Maps app. Clicking the link can also show him the activity chooser or open Google Maps in the browser. It might also open a third-party app that is registered to handle the same Intent. The code snippet you posted will behave exactly like that, too.
This not only works from the browser, but with all links in the system. For example, I sent the link you posted via e-mail to myself and clicked it on my phone. I could open it with my Goolge Maps app. So there is really no need for JavaScript, you can just use a simple HTML link to send the Intent.
Just simply call the function from JavaScript to Android , and inside the function you can call the android intent.
you can find out the tutorial how to call android function from JavaScript:
http://android-er.blogspot.in/2011/10/call-javascript-inside-webview-from.html
and call the map using Google V3 library .
https://developers.google.com/maps/articles/android_v3
Related
I have a location coordinate (lat, lng) and need a link to share it on social media like whatsapp, showing a map, but before doing it, it should open an alert to choose native installed application.
How to create a link that it can open a selection alert?
Note: for instance, we wanna share this link on whatsapp. I know how to create shareable link for this app. All I need is about creating an alert to choose between native maps on mobile devices after opening the link.
You can call navigator.geolocation.getCurrentPosition() method to ask user for geolocation, but you need an https protocole to use this method, so locally it wouldn't work
I'm currently using wikitude sdk 4.0 for android and trying out the the sample of Multiple POIs in my app.
https://github.com/Wikitude/wikitude-sdk-samples/tree/master/3_PointOfInterest_3_MultiplePois
I got it instantiated but stuck with user location.
I don't understand how the user's location is pulled by this Javascript
https://github.com/Wikitude/wikitude-sdk-samples/blob/master/3_PointOfInterest_3_MultiplePois/js/multiplepois.js
The "AR.context.onLocationChanged = World.locationChanged;" in JS does the magic.
After this line is executed the 'World.locationChanged' (or any other given) function is fired on every Android/iOS native call of the architectView's setLocation is executed.
Check out the LocationProvider-implementation in the Sample Application for a very basic approach.
For state-of-the-art location fetching I recommend you to have a look at Google's Location Strategies.
Kind regards.
I’m developing an app that integrates Google map with Google places in a webview. I have it all working well using the JavascriptInterface. Actually it’s working really well. However, I just want to know how to set the API key.
At the moment I’m using:
http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true
I want to add the API key. If I add the API key to the above JavaScript I get a message from Google blocking the connection saying that I have to register the URL, which I can’t do as it is integrated in the app.
I have set the SHA key in the Google API Console.
Any Ideas?
Thanks in advance.
.
u should register your website to google map apis key page there is a button rightof key called Edit allowed referers...
and when u are using key
put it to "addyourkeyhere" in link. and set your sensor false or true.
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AddYourKeyhere&sensor=false"/>
I'm working on an Android app that needs to be able to display information on Google maps.
I'm considering two ways of implementing this:
Use the Google maps api provided for android with the MapActivity class
Or I could use the javascript google maps api and view the map data on my phone through a WebView rather than using a MapView.
Would anyone be able to list any advantages/disadvantages of these methods?
Would the WebView be as responsive as the Android Google Maps app?
Thanks heaps
I won't go far to conclude which is the best, but still these are things that I encountered upon trying for both approach.
Customizable:
Web View: requires you to have a web server (or at least one html page) as basis for your custom overlay via js (or perhaps you can directly draw the overlay over the WebView but having consequences to face nightmare of projecting the geoposition with the screen position)
GMap API: overlay is drawn directly over the MapView.
Download time:
Web View: when one write an html page for mobile view, s/he should consider the varying capability of downloading speed. If you carefully write the html page to fit for mobile download then it should be fine.
GMap API: the data transferred is already managed by the API and should be already in effective and minimum way.
Current Issues:
Web View: can fit to fragment mindset of Android programming
GMap API: no news so far I heard of, hopefully they're working on it. Since fragment is the new standard.
Cheers.
I would like to create a Web App for device. For that I would have some script being stored on device, instead of downloading them all time when I start application. As far as I saw including a GoogleMaps API makes some additional request for javascript files. Is there any way of having all of them taken directly from local store? Or is this always have to refeer to google web address? Thanks for any answers here!
No, you always must load them from the Google site. They offer no way to run Google Maps locally. The GMaps scripts are generated on the fly, based upon (among others, I'm sure) the HTTP_REFERER header of the request. That's how they can bind an API key to a specific website.