Tìm kiếm theo tiêu đề

Tin tức cộng đồng

[MỜI HỢP TÁC] Các kỳ thi Olympic Quốc tế 2026 (IMO - IEO - ISO)

Kính gửi Quý Lãnh đạo, Ban Giám hiệu và Quý Thầy/Cô, FermatTech (Đối tác Google tại VN) phối hợp cùng SCO Ấn Độ trân trọng kính mời tham gia 3 kỳ thi uy tín dành cho HS từ lớp 1 - 12: - IMO: Olympic Toán Quốc tế. - IEO: Olympic Tiếng Anh Quốc tế. - ISO: Olympic Khoa học...
Xem tiếp

Tin tức thư viện

Chức năng Dừng xem quảng cáo trên violet.vn

12087057 Kính chào các thầy, cô! Hiện tại, kinh phí duy trì hệ thống dựa chủ yếu vào việc đặt quảng cáo trên hệ thống. Tuy nhiên, đôi khi có gây một số trở ngại đối với thầy, cô khi truy cập. Vì vậy, để thuận tiện trong việc sử dụng thư viện hệ thống đã cung cấp chức năng...
Xem tiếp

Hỗ trợ kĩ thuật

  • (024) 62 930 536
  • 0919 124 899
  • hotro@violet.vn

Liên hệ quảng cáo

  • (024) 66 745 632
  • 096 181 2005
  • contact@bachkim.vn

Android + Map API full

Wait
  • Begin_button
  • Prev_button
  • Play_button
  • Stop_button
  • Next_button
  • End_button
  • 0 / 0
  • Loading_status
Nhấn vào đây để tải về
Báo tài liệu có sai sót
Nhắn tin cho tác giả
(Tài liệu chưa được thẩm định)
Nguồn:
Người gửi: Nguyễn Tuấn Kiệt
Ngày gửi: 10h:39' 30-12-2013
Dung lượng: 699.0 KB
Số lượt tải: 14
Số lượt thích: 0 người
Maps
Dr. David Janzen
Except as otherwise noted, the content of this presentation is
licensed under the Creative Commons Attribution 2.5 License.
Maps
Google Maps API is widely used on the web
The Android SDK provides support for easily integrating the Google Maps API
Using Google Maps in our apps
Configure
Maps require the Google API as the project build target
Maps require a Map API Key in order to be deployed
http://code.google.com/android/add-ons/google-apis/maps-overview.html
Code
Create a MapView in a MapActivity
Create Map Overlays
Add Google API in Eclipse
http://developer.android.com/sdk/adding-components.html
Add Google API in Eclipse
Use API 4 for SDK 1.6
http://developer.android.com/guide/appendix/api-levels.html
Add Google API in Eclipse
Set the Google API as the Project Build Target
Right-click on the project, select Properties
Keys
As we learned in lab 1 section 6,
https://sites.google.com/site/androidappcourse/labs/lab-1
our apps must be signed in order to deploy them on a device
Eclipse automatically creates a signed debug keystore that is used when launching our app from Eclipse
In order to deploy our app to the public, we must create a signed keystore
See http://developer.android.com/guide/publishing/app-signing.html#ExportWizard
Find your keystore
http://code.google.com/android/add-ons/google-apis/mapkey.html
Find your debug keystore
http://code.google.com/android/add-ons/google-apis/mapkey.html
Get your certificate fingerprint
http://code.google.com/android/add-ons/google-apis/mapkey.html
Register your certificate with Google
http://code.google.com/android/maps-api-signup.html
What’s in the legal agreement?
Read the Terms of Service (sections 1-11)
http://code.google.com/android/maps-api-signup.html
Examples
Maps may include ads in future
Google may limit number of transactions
Cannot use for turn-by-turn directions or autonomous driving
Add the Map API Key to your Application
android:id="@+id/myMap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="@string/mapApiKey"/>
Configure AndroidManifest.xml


...

Finally, we can start coding
MapView
Contains a map
via Google Maps API
Map tile retrieval and caching is all done for you
Includes pan
Includes zoom
use setBuiltInZoomControls(true);
MapView Modes
MapView
You determine mode
setSatellite(true);
setTraffic(true);
setStreetView(true);
MapActivity
MapView can only be constructed or inflated in a MapActivity
public class MyActivity extends MapActivity {
…
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
…
MapView myMap = (MapView)findViewById(R.id.myMap);
myMap.setBuiltInZoomControls();
myMap.setSatellite(true);
MapController
You can pan and zoom the map programmatically
MapView myMap = (MapView)findViewById(R.id.myMap);
MapController mapController = myMap.getController();
mapController.setZoom(1); //widest zoom/far away
…
mapController.setZoom(21); //narrowest zoom/close in
mapController.zoomIn(); //one level
mapController.zoomOut(); //one level
GeoPoint
You can move to a particular point
MapView myMap = (MapView)findViewById(R.id.myMap);
MapController mapController = myMap.getController();

Double lat = 37.123456 * 1E6;
Double long = -122.123456 * 1E6;
GeoPoint point = new GeoPoint(lat.intValue(), long.intValue());
mapController.setCenter(point); //jump to point
…
mapController.animateTo(point); //smooth transition to point
Reverse Geocoding
Find address from longitude/latitude
location = locationManager.getLastKnownLocation(
LocationManager.GPS_PROVIDER);
double lat = location.getLatitude();
double lng = location.getLongitude();

Geocoder gc = new Geocoder(this, Locale.getDefault());
List
addresses = null;
try {
addresses = gc.getFromLocation(lat, lng, 10);
} catch (IOException e) {}
Forward Geocoding
Find longitude/latitude (and more) from address
Geocoder gc = new Geocoder(this, Locale.US);
List
addresses = null;
try {
addresses = gc.getFromLocationName(
“123 Main St., Newton, Kansas”, 10);
} catch (IOException e) {}
double lat = addresses.get(0).getLatitude();
String zip = addresses.get(0).getPostalCode();
Geolocation
Options
GPS, cell network
Wifi-based
Skyhook Wireless
http://www.skyhookwireless.com/developers/Android_Integration_Manual.php
Setting up location services
public MyActivity() {
criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
criteria.setPowerRequirement(Criteria.POWER_LOW);
};
private final LocationListener locationListener = new LocationListener() {
public void onLocationChanged(Location location) {
updateWithNewLocation(location);
}
public void onProviderDisabled(String provider) {
updateWithNewLocation(null);
}
public void onProviderEnabled(String provider) {}
public void onStatusChanged(String provider, int status, Bundle extras) {}
};
@Override
protected void onStart() {
super.onStart();
locationManager = (LocationManager)getSystemService(
Context.LOCATION_SERVICE);
provider = locationManager.getBestProvider(criteria, true);
// or could be LocationManager.GPS_PROVIDER
try {
updateWithNewLocation(locationManager.getLastKnownLocation(
provider));
} catch (Exception e) {}
locationManager.requestLocationUpdates(provider, 2000, 10,
locationListener);
}
private void updateWithNewLocation(Location location) {
double latitude = 0.0;
double longitude = 0.0;
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
//do something with latitude and longitude (e.g. print or move map there)
}
Turn GPS on and off to save battery
@Override
protected void onPause() {
super.onPause();
//stop receiving GPS locationManager.removeUpdates(locationListener);
}
@Override
protected void onResume() {
super.onResume();
//restart receiving GPS locationManager.requestLocationUpdates(provider, 2000, 10,
locationListener);
}
 
Gửi ý kiến