You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<br />
2. แก้ไขโค้ด Java ในไฟล์ SampleGPSActivity.java โดยแก้ไขเมธอด onCreate() ดังนี้<br />
package com.android.example.simplegps;<br />
import com.google.android.maps.GeoPoint;<br />
import com.google.android.maps.MapActivity;<br />
import com.google.android.maps.MapController;<br />
import com.google.android.maps.MapView;<br />
import android.content.Context;<br />
import android.location.Location;<br />
import android.location.LocationListener;<br />
import android.location.LocationManager;<br />
import android.os.Bundle;<br />
import android.widget.CompoundButton;<br />
import android.widget.CompoundButton.OnCheckedChangeListener;<br />
import android.widget.Toast;<br />
import android.widget.ToggleButton;<br />
public class SampleGPSActivity extends MapActivity {<br />
private LocationManager lm;<br />
private LocationListener locationListener;<br />
private MapView mapView;<br />
private MapController mc;<br />
public void onCreate(Bundle savedInstanceState) {<br />
super.onCreate(savedInstanceState);<br />
setContentView(R.layout.main);<br />
2<br />
แก้ไขโค้ด<br />
mapView = (MapView) findViewById(R.id.mapview1);<br />
mapView.setBuiltInZoomControls(true);<br />
mc = mapView.getController();<br />
mc.setZoom(14);<br />
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);<br />
locationListener = new MyLocationListener();<br />
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 1,<br />
locationListener);<br />
ToggleButton traffic = (ToggleButton) findViewById(R.id.bt_traffic);<br />
ToggleButton satellite = (ToggleButton) findViewById(R.id.bt_satellite);<br />
บทที ่ 9 การพัฒนาแอพพลิเคชันติดต่อกับ GPS และการอ้างอิงกับระบบแผนที่ (Map) 189