Wednesday 23 November 2011

map view to view longitude lattitude in map using google map api (key is not required)


//to view the map,key is not required
package com.MapActivity;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

public class MapActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);//default main.xml
        double SLatitude = 1.234;
double SLongitude = 1.34;

final Intent intent = new Intent(Intent.ACTION_VIEW,
/** Using the web based turn by turn directions url. */
Uri.parse("http://maps.google.com/maps?" + "saddr="
+ SLatitude + "," + SLongitude + "&daddr="
+ 2.34 + "," + 3.45 + ""));

intent.setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(intent);
    }
}
manifest:=>

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.MapActivity" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-library android:name="com.google.android.maps" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MapActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>
</manifest>

No comments:

Post a Comment