android毕业设计方案外文资料翻译.docx

上传人:rrsccc 文档编号:8942880 上传时间:2021-01-26 格式:DOCX 页数:6 大小:70.08KB
返回 下载 相关 举报
android毕业设计方案外文资料翻译.docx_第1页
第1页 / 共6页
android毕业设计方案外文资料翻译.docx_第2页
第2页 / 共6页
android毕业设计方案外文资料翻译.docx_第3页
第3页 / 共6页
android毕业设计方案外文资料翻译.docx_第4页
第4页 / 共6页
android毕业设计方案外文资料翻译.docx_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《android毕业设计方案外文资料翻译.docx》由会员分享,可在线阅读,更多相关《android毕业设计方案外文资料翻译.docx(6页珍藏版)》请在三一文库上搜索。

1、android 毕业设计方案外文资料翻译毕业设计 ( 论文 ) 外文资料翻译外文出处MarkAndroid 2Chapter 33Mapping with MapView and MapActivityOne of Googles most popular services-after search of course-is Google Maps, which lets you find everything from the nearest pizza parlor to directions from New York City to San Francisco (only 2,905

2、miles!), along with supplying street views and satellite imagery.Most Android devices, not surprisingly, integrate Google Maps. For those that do, there is a mapping activity available to users directly from the main Android launcher. More relevant to you, as a developer, are MapView and MapActivity

3、, which allow you to integrate maps into your own applications. Not only can you display maps, control the zoom level, and allow people to pan around, but you can tie in Androids location-based services (covered in Chapter 32) to show where the device is and where it is going.Fortunately, integratin

4、g basic mapping features into your Android project is fairly easy. And there is also a fair bit of power available to you, if you want to get fancy.Terms, Not of EndearmentIntegrating Google Maps into your own application requires agreeing to a fairly lengthy set of legal terms. These terms include

5、clauses that you may find unpalatable.If you are considering Google Maps, please review these terms closely to determine if your intended use will not run afoul of any clauses. You are strongly recommended to seek professional legal counsel if there are any potential areas of conflict.Also, keep you

6、r eyes peeled for other mapping options, based on other sources of map data, such as OpenStreetMap (). Piling OnAs of Android , Google Maps is not strictly part of the Android SDK. Instead, it is part of the Google APIs add-on, an extension of the stock SDK. The Android add-on system provides hooks

7、for other subsystems that may be part of some devices but not others.NOTE: Google Maps is not part of the Android open source project, and undoubtedly there will be some devicesthat lack Google Maps due tolicensing issues.For example, at the time of this writing, the Archos 5 Android tablet does not

8、 have Google Maps.By and large, the fact that Google Maps is in an add-on does not affect your day-to-day development. However, bear in mind the following:You will need to create your project with a suitable target to ensure the Google Maps APIs will be available.To test your Google Maps integration

9、, you will also need an AVD that supports the Google Maps API.The Bare BonesFar and away the simplest way to get a map into your application is to create your own subclassof MapActivity. Like ListActivity, which wraps up some of the smarts behind having an activity dominated by a ListView, MapActivi

10、ty handles some of the nuances of setting up an activity dominated by a MapView.In your layout for the MapActivity subclass,you need to add an element named, at the time of this writing, . This is the longhand way to spell out the names of widget classes, by including the full package name along wit

11、h the class name. This is necessarybecauseMapView is not in the namespace.You can give the MapView widget whatever android:id attribute value you want, plus handle all the layout details to have it render properly alongside your other widgets.However, you do need to have these two items:android:apiK

12、ey, which in production will need to be a Google Maps API keyandroid:clickable=true, if you want users to be able to click and pan through your mapFor example, from the Maps/NooYawk sample application, here is the main layout: android:id=+id/map android:layout_width= fill_parentandroid:layout_height

13、=fill_parentandroid:apiKey=android:clickable=true /Well cover that mysterious apiKey later in this chapter, in the The Key toIt All section. In addition, you will need a couple of extra things in your file:The INTERNET and ACCESS_COARSE_LOCATION permissions (the latter for use with the MyLocationOve

14、rlay class, described later in this chapter)Inside your , a element with android:name =, to indicate you are using one of the optional Android APIsHere is thefile for NooYawk:That is pretty much all you need for starters, plus to subclass your activity from MapActivity. If you were to do nothing els

15、e, and built that project and tossed it in the emulator, you would get a nice map of the world. Note, however, that MapActivity is abstract. You need to implement isRouteDisplayed() toindicate if you are supplying some sort of driving directions.In theory, users could pan around the map using the D-

16、pad. However, thats not terribly useful when they have the whole world in their hands.Since a map of the world is not much good by itself, we need to add a fewthings, as described next.Exercising Your ControlYou can find your MapView widget by findViewById(), just as with anyother widget. The widget

17、 itself offers a getMapController() method. Between theMapView and MapController, you have a fair bit of capability to determine whatthe map shows and how it behaves. The following sections cover zoom and center,the features you will most likely want to use.ZoomThe map of the world you start with is

18、 rather broad. Usually, people looking at a map on a phone will be expecting something a bit narrower in scope, such as a few city blocks.You can control the zoom level directly via the setZoom() method on the MapController. This takes an integer representing the level of zoom, where 1 is the world

19、view and 21 is the tightest zoom you can get. Each level is a doubling of the effective resolution: 1 has the equator measuring 256 pixels wide, while 21 has the equator measuring 268,435,456 pixels wide. Since the phones display probably doesnt have 268,435,456 pixels in either dimension, the user

20、sees a small map focused on one tiny corner of the globe. A level of 16 will show several city blocks in each dimension, which is probably a reasonable starting point for experimentation.If you wish to allow users to change the zoom level, call setBuiltInZoomControls (true);, and the user will be ab

21、le to zoom in and out of the map via zoom controls found at the bottom center of the map. CenterTypically, you will need to control what the map is showing, beyond the zoom level, such as the users current location or a location saved with some data in your activity. To change the maps position, call setCenter() on the MapController.The setCenter() method takes a GeoPoint as a parameter. A GeoPoint represents a location, via latitude and longitude. The catch is that the GeoPoint

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1