Get Current Location in WebView Google maps - android

I have a link of my custom made map in Google which includes marker to several destinations , what i want is to get the current Location of user and show a marker or something on that location without disturbing my other markers in google map.
i have following Google map which i want to show in webView: https://www.google.com/maps/d/u/0/viewer?mid=1Wm3cIfP77Z8av8wGOi7xzQvrVxY
what modifications i should do in URL or android code to make it work?
my attempt: https://www.google.com/maps/d/u/0/dir/Current+Location/viewer?mid=1qriRe112Bm54KPXEgtfeA6n2la8&z=5 [FAILED]
Edited:
https://www.google.com/maps/d/u/0/viewer?mid=1qriRe112Bm54KPXEgtfeA6n2la8&z=5&saddr=Current+Location [FAILED]

You can create an instance of a WebView and load the URL of the Google Maps site. You can add parameters to the URL which allows you to use more functionality than is available using the Java-based Google Maps API.
Below code snippet shows how to create instance of a WebView to display a mobile Google Maps URL with parameters in an Android App. The main activity of your app should contain the following lines in its onCreate() method.
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView webView = (WebView) findViewById(R.id.mywebview);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://maps.googleapis.com/maps/api/staticmap?
ll=36.97,%20-122&lci=bike&z=13&t=p&size=500x500&sensor=true");
}

Related

Google Map and Web view

I have a Google Map opening in a Webview using query strings and the API to determine the location.
This worked fine up until a week or so ago; now the window pops up asking what application you would like to use.
Has something changed? How can I stop this box popping up and have the webview handle the map instead of it trying to open a new browser or Maps?
Relevant code:
String detail = (String)getIntent().getExtras().get(CustomizedListView.KEY_DETAIL);
WebView detailweb = (WebView)findViewById(R.id.detailsText);
detailweb.loadData(detail, "text/html", "UTF-8");

Issue with WebView and Google Maps

In my application on click of a button i am trying to launch the following url using a web view :
https://maps.google.com/maps?saddr=indiranagar bangalore&daddr=mgroad bangalore
My code is as below:
WebView webView=new WebView(this);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);
webView.loadUrl("https://maps.google.com/maps?saddr=indiranagar bangalore&daddr=mgroad bangalore");
When the web view appears it first displays the following:
And immediately displays the following:
I do not get to see the maps. Am i missing on something in my code. Can someone kindly help me with this please. Thanks in advance.
I had the same issue in using Google Maps URL into a ColorBox popup.
I found out that you can add &output=embed at the end of the URL to make it show in an iframe.
Maybe this solution will help you too.
So try:
webView.loadUrl("https://maps.google.com/maps?saddr=indiranagar bangalore&daddr=mgroad bangalore&output=embed");
i found that WebView does not support javascript by default, and this will lead google map jump to a URL that contains a params "nojs",
so, just add this line for your webview, problem gone.
webview.getSettings().setJavaScriptEnabled(true);

android java call javascript

In my programme, there are textview button scrollview and webview. All of them write by java except webview(write by html js/jquery). Is that availabe to trigger some javascript when I click button(clicklistener write by java android google api)?
Basically, my programme receives some data from tcp response (json type data) and save in a json file. jquery library plot retrieve that file and draw graph. There are two buttons. One is for retrieving data and another one is drawing graph. Because they and java and javascript. Is there any way when I click the retrieving button, the graph will auto drawing? How to interact java and javascript?
Thanks!!!
You can run JavaScript from java in your webview this way:
onCreate I do this:
webView = (WebView)findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.google.de/");
On click on a button this happens:
public void onClick(View v) {
webView.loadUrl("javascript:document.bgColor = '#a00';");
}
Should change the bg-color of your document to red which works perfectly fine for me with google.de

Android, Trying to embed YouTube video in webpage

I’m trying to display a page of embed YouTube videos. I got the code from YouTube website. The page gets displayed correctly when I load it up in the browser but on my embedded web page the YouTube videos do not show the first frame. Its just a black box with the YouTube logo on the bottom. If you click on it, it does play the video. I tread to enable java script, still did not work.
public class cVideos extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videos);
WebView mWeb=(WebView) findViewById(R.id.webvideo);
mWeb.getSettings().setJavaScriptEnabled(true);
mWeb.getSettings().setJavaScriptEnabled(true);
// mWeb.loadUrl("http://www.besttechsolutions.biz/projects/bigbiz/mobvideo.php");
mWeb.loadUrl("http://www.besttechsolutions.biz/projects/bigbiz/videored.php");
}
}
Try embedding &autoplay=1 in the src attribute of the iframe tag in the page source.
Even so, autoplay will not work on Android 2.1 devices, as they cannot support HTML5 video in the browser.

URL to open facebook app in android [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Open Facebook page from Android app?
I have a webview in my android app, and I would like to put a link in that opens the facebook app to my fanpage. In iOS you can say fb://... and it will open the facebook app. Is there a way to do it in android? I'm already overriding shouldOverrideUrlLoading, so I could intercept it and launch an intent if I need to.
You need to use Intents. Here's how to call the FB application (if it is installed):
Intent intent = new Intent();
intent.setClassName("com.facebook.katana","com.facebook.katana.ProxyAuth");
intent.putExtra("client_id", applicationId);
mAuthActivityCode = activityCode;
activity.startActivityForResult(intent, activityCode);
This code is taken from the Facebook API, which authorizes an action. Ajust to suit your needs. Code is Copyright 2010 Facebook, Inc., licensed under the Apache License, Version 2.0.
myWebView = (WebView) findViewById(R.id.webview); // Create an instance of WebView and set it to the layout component created with id webview in main.xml
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl("http://m.facebook.com/pages/xxxxx-xxxxx-xxxxx/xxxxxxxxxx"); // Specify the URL to load when the application starts
//myWebView.loadUrl("file://sdcard/"); // Specify a local file to load when the application starts. Will only load file types WebView supports
myWebView.setWebViewClient(new WebViewKeep());
myWebView.setInitialScale(1); // Set the initial zoom scale
myWebView.getSettings().setBuiltInZoomControls(true); // Initialize zoom controls for your WebView component
myWebView.getSettings().setUseWideViewPort(true); // Initializes double-tap zoom control
Check if this works for you.

Categories

Resources