Contenido sobre Android
Buscar
Social
Ofertas laborales ES

Foro sobre Android > geolocalizacion

//clase principal
package com.comboyz.googlemapsC;

import android.os.Bundle;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;

public class main extends MapActivity {
/** Called when the activity is first created. */
MapController mControl;
GeoPoint GeoP;
MapView mapV;
MyLocationOverlay compass;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mapV = (MapView)findViewById(R.id.mapView);
mapV.displayZoomControls(true);
mapV.setBuiltInZoomControls(true);


//AQUI DANDO LOS VALORES ME DICE EN DONDE ES
double lat = 60.0;
double longi = 6.666;

GeoP = new GeoPoint((int)( lat *1E6 ),(int)(longi *1E6) );


mControl = mapV.getController();
mControl.animateTo(GeoP);
mControl.setZoom(13);

compass = new MyLocationOverlay(this, mapV);
mapV.getOverlays().add(compass);

}

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}

@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();

compass.disableCompass();
}

@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
compass.enableCompass();
}


}

//layout main.xml tienen que conseguir la llave.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0BcccAUytnWiR8MGlCYYZGuRhX6qlGZkkG_f-IA"
/>

</RelativeLayout>


//androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.comboyz.googlemapsC"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>


<uses-library android:name="com.google.android.maps"/>



<category android:name="android.intent.category.LAUNCHER" />


</manifest>


noviembre 11, 2011 | Unregistered Commenterrquiroz