i tried using webview but i really don't know where to add the
javascript code in it..
i tried some example using the tutorial on the net..
but could not understand it..
the link was
http://www.google.com/url?sa=D&q=http://code.google.com/apis/maps/articles/android_v3.html&usg=AFQjCNFnEdIn1isVqet3vK3d1o6BB6kT9w

i'll paste my code for you here..

WebMapActivity.java:
package com.example.hellomaps;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class WebMapActivity extends Activity implements
LocationListener {
    /** Called when the activity is first created. */
        private WebView webView;
        private Location mostRecentLocation;
        private static final String MAP_URL = "http://gmaps-
samples.googlecode.com/svn/trunk/articles-android-webmap/simple-
android-map.html";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        getLocation();
        setupWebView();
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
        private void setupWebView() {
                // TODO Auto-generated method stub
                final String centerURL = "javascript:centerAt(" +
                  mostRecentLocation.getLatitude() + "," +
                  mostRecentLocation.getLongitude()+ ")";
                  webView = (WebView) findViewById(R.id.webview);
                  webView.getSettings().setJavaScriptEnabled(true);
                  //Wait for the page to load then send the location
information
                  webView.setWebViewClient(new WebViewClient(){
                    @Override
                    public void onPageFinished(WebView view, String
url){
                      webView.loadUrl(centerURL);
                    }
                  });
                  webView.loadUrl(MAP_URL);
        }
        private void getLocation() {
                // TODO Auto-generated method stub
                LocationManager locationManager =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
          Criteria criteria = new Criteria();
          criteria.setAccuracy(Criteria.ACCURACY_FINE);
          String provider =
locationManager.getBestProvider(criteria,true);
          //In order to make sure the device is getting the location,
request updates.
          locationManager.requestLocationUpdates(provider, 1, 0,
this);
          mostRecentLocation =
locationManager.getLastKnownLocation(provider);
        }
        @Override
        public void onLocationChanged(Location location) {
                // TODO Auto-generated method stub
        }
        @Override
        public void onProviderDisabled(String provider) {
                // TODO Auto-generated method stub
        }
        @Override
        public void onProviderEnabled(String provider) {
                // TODO Auto-generated method stub
        }
        @Override
        public void onStatusChanged(String provider, int status,
Bundle
extras) {
                // TODO Auto-generated method stub
        }

and this is the javascript code..
javascript code..
<script type="text/javascript"
  src="http://maps.google.com/maps/api/js?sensor=true";></script>
<script type="text/javascript">
  var map;
  function initialize() {
    var latitude = 0;
    var longitude = 0;
    if (window.android){
      latitude = window.android.getLatitude();
      longitude = window.android.getLongitude();
    }
    var myLatlng = new google.maps.LatLng(latitude,longitude);
    var myOptions = {
      zoom: 8,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById("map_canvas"),
      myOptions);
    }
  function centerAt(latitude, longitude){
    myLatlng = new google.maps.LatLng(latitude,longitude);
    map.panTo(myLatlng);
  }
</script>

On Aug 31, 8:07 pm, Jeremy Wadsack <[email protected]> wrote:
> You could build your own WebView container activity and run your JS there.
> Or you could use some off-the-shelf package that does this like Phonegap or
> Appcelerator.
>
> If you want to run native JS without the web view, then I think you'll need
> to bundle your own interpreter or use a cross-compiler. Unless V8 is exposed
> to the app framework somehow, but I don't off hand see any mention of that.
>
> --
> Jeremy Wadsack
>
> On Tue, Aug 31, 2010 at 7:51 AM, anushree <[email protected]>wrote:
>
>
>
> > hello all,
> > i am trying to develop a google maps application for android using
> > javascripts v3 api. but the main problem is that i haven't worked with
> > javascripts for android application development..
> > i have only used java code to develop an application
> > so i don't know where to start..
> > has anyone used javascripts for development in android??
> > if so,
> > please can you help me by providing the code of your application so
> > that i can learn how to develop using javascripts in android..
> > thanks-
> > anushree
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<android-developers%2Bunsubs 
> > [email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to