helo,
i am trying to create a google maps application on android enabled
phones.. i am using eclipse along with android 2.2 which provides me
with an emulator..

i tried the example given on 
http://code.google.com/apis/maps/articles/android_v3.html
however i have some problems understanding the code..
mainly where am i supposed to write the javascript portion that is
given in the example??
am i supposed to include a different javascript file for it??? please
help because i am stuck ..

i am writing my source code 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 i have created a javascript file namedmaps.js to write the
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>


i also have taken care of the permissions that have been advised by
the example and mande changes to main.xml..

please help.. its urgent

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" 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/google-maps-js-api-v3?hl=en.

Reply via email to