【Langston Smith】为中国的安卓⽤户提供有效的地图服务

慈书云

2017/12/31 发布于 技术 分类

2017年,droidcon 第2次来到中国,并将于2017年11月在北京盛大开幕。参会人群包括业界领袖、技术大咖、技术开发者、大众创业者及领域从业者。大会将邀请来自Google、微软、Facebook、Ebay、Intel、Telenav、阿里巴巴、腾讯、小米、乐视、联想等国内外安卓技术与应用领域的大咖,沿袭历年国际大会特色,聚焦行业最前沿技术,碰撞切磋技术火花。

文字内容
1. Delivering accurate maps to Chinese Android users 为中国安卓用户提供准确的地图服务
2. ● Work at Mapbox includes: Android apps, demos, starter kits, documentation, support, syncing Android team with other departments, etc. 工作包括:安卓app、演示、初学者工 具包、客户服务、等 ● Lived in Beijing from 2011-2015 2011到2015,我住在北京!
3. Today’s talk: 简报主题:
4. Today’s talk: 简报主题: 1. Design 地图设计决策
5. Today’s talk: 简报主题: 1. Design 地图设计决策 1. Location data 位置数据服务
6. Today’s talk: 简报主题: 1. Design 地图设计决策 1. Location data 位置数据服务 1. How to create an app with Mapbox 通过Mapbox,怎么开发一个安卓 应用?
7. Design decisions 地图设计决策
8. Does the map have too much information? Too little? Wrong type of information? 太多信息? 太少?
9. Correct zoom level for a hotel? 酒店的位置:正确 的缩放级别?
10. Right layers and information? Correct UI/UX? 你要给用户什么 选择?
11. App user has 13 choices including the map. Right amount of options? Right type? 应用用户有十三 个选择。适量选 择吗?说不定...
12. App user has 16 choices including the map(!) 十六个选择(!)
13. Right info displayed for a bicyclist? 骑自行车的人需要 看什么信息?
14. What's important here? Schools? Hotel prices? Subway stations? 什么是重要的?大学 的位置?酒店的价格 ?每一个地铁站?
15. Don’t show subway lines if in driving mode? Buildings 如果开车的话, 不用看地铁线? 不用看每一个大 楼? ??????
16. Marker clustering 标记群集
17. Static image decision (markers, camera position, etc.) 静止的地图决策(标 记、视角位置、等)
18. What’s the difference? 有什么区别 ?
19. Navigation 导航–>
20. Daily life 日常生活–>
22. Asking for permissions 位置权限
24. Location data + context 位置数据服务
26. 导航
27. 位置搜索 (地理编码)
28. 智能手表
29. AR(增强现实)游戏
30. 物流
31. 社交媒体
33. ● Location data platform for developers 开发者而建的地图平台
34. ● Location data platform for developers 开发者而建的地图平台 ○ Maps 地图
35. Vector tiles + video game technology (OpenGL) 矢量瓦片 + 动画游戏技术
36. ● Location data platform for developers 开发者而建的地图平台 ○ Maps 地图 ○ Location search 位置搜索 (地理编码)
37. ● Location data platform for developers 开发者而建的地图平台 ○ Maps 地图 ○ Location search 位置搜索 (地理编码) ○ Navigation (driving, walking, biking) 导航 (开车、 走路、骑车)
38. Open-source tools (700 public Github repos) 开源的安卓产品
39. SDKs for Android, iOS, Unity, Qt (for cars), & React Native 软件开发包: 安卓、 苹果公司、Unity、 Qt (一种汽车平台) 、& React Native.
40. Extrusions 三维外形
41. “Dancing buildings” 三维外形 + 麦克风
42. AR(Core) 增强现实
43. AR(Core) 增强现实
44. In-app nav 应用里导航
45. Offline 离线下载
46. Heatmaps 热点地图
47. Let’s build! 咱们开始!
48. Set up basic project
49. App-level build.gradle file dependencies { ... compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.2.0-beta.4@aar') { transitive = true} ... }
50. App-level build.gradle file dependencies { ... compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.2.0-beta.4@aar') { transitive = true} ... }
51. Maps SDK size 软件开发包大小 ● Less than 1MB 可能小于1MB ● SDKs final impact is dependent on other app decisions
52. strings.xml file 字符串的文件 Add your key to the strings file 加你Mapbox的访问令牌 <resources> ... <string name="access_token">MAPBOX_ACCESS_TOKEN</string> ... </resources> Your first 50,000 mobile users are free! 你前面五万的移动用户是免费的!
53. XML layout file – XML布局文件 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:mapbox="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <com.mapbox.mapboxsdk.maps.MapView android:id="@+id/mapview" android:layout_width="match_parent" android:layout_height="match_parent"/> </RelativeLayout>
54. Additional map XML attributes – 更多XML属性 <com.mapbox.mapboxsdk.maps.MapView android:id="@+id/mapview" android:layout_width="match_parent" android:layout_height="match_parent" mapbox:mapbox_cameraTargetLat="19.948045" mapbox:mapbox_cameraTargetLng="-84.654463" mapbox:mapbox_cameraZoom="3.371717" mapbox:mapbox_cameraTilt="50" mapbox:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/> More XML attributes – 更多XML属性 github.com/mapbox/mapbox-glnative/blob/master/platform/android/MapboxGLAndroidSDK/src/main/res/value s/attrs.xml
55. Activity file – Activity文件 public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Mapbox.getInstance(this, getString(R.string.access_token)); setContentView(R.layout.activity_main); }
56. public class MainActivity extends AppCompatActivity { private MapView mapView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Mapbox.getInstance(this, getString(R.string.access_token)); setContentView(R.layout.activity_main); mapView = (MapView) findViewById(R.id.runtime_mapview); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(final MapboxMap mapboxMap) { // Customize map with markers, polylines, etc. } }); }
57. @Override public void onResume() { super.onResume(); mapView.onResume(); } Method overrides 重写此方法 @Override protected void onStart() { super.onStart(); mapView.onStart(); } @Override protected void onStop() { super.onStop(); mapView.onStop(); } @Override public void onPause() { super.onPause(); mapView.onPause(); } @Override public void onLowMemory() { super.onLowMemory(); mapView.onLowMemory(); } @Override protected void onDestroy() { super.onDestroy(); mapView.onDestroy(); } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mapView.onSaveInstanceState(outState); }
58. The result! 结果!
59. Run-time styling 运行时地图模式
61. mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(final MapboxMap mapboxMap) { final Layer waterLayer = mapboxMap.getLayer("water"); }); }
62. mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(final MapboxMap mapboxMap) { final Layer waterLayer = mapboxMap.getLayer("water"); findViewById(R.id.floatingActionButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (waterLayer != null) { waterLayer.setProperties(PropertyFactory.fillColor(Color.parseColor("#023689"))); } } }); }
63. mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(final MapboxMap mapboxMap) { final Layer waterLayer = mapboxMap.getLayer("water"); findViewById(R.id.floatingActionButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (waterLayer != null) { waterLayer.setProperties(PropertyFactory.fillColor(Color.parseColor("#023689"))); } } }); }
64. findViewById(R.id.floatingActionButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (waterLayer != null) { waterLayer.setProperties(PropertyFactory.fillColor(Color.parseColor("#023689"))); } for (Layer singleMapLayer : mapboxMap.getLayers()) { if (singleMapLayer.getId().contains("marine")) { singleMapLayer.setProperties( PropertyFactory.textHaloBlur(10f), PropertyFactory.textSize(25f), PropertyFactory.textColor(Color.parseColor("#00FF08")), PropertyFactory.textOpacity(1f)); } } } });
65. findViewById(R.id.floatingActionButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (waterLayer != null) { waterLayer.setProperties(PropertyFactory.fillColor(Color.parseColor("#023689"))); } for (Layer singleMapLayer : mapboxMap.getLayers()) { if (singleMapLayer.getId().contains("marine")) { singleMapLayer.setProperties( PropertyFactory.textHaloBlur(10f), PropertyFactory.textSize(25f), PropertyFactory.textColor(Color.parseColor("#00FF08")), PropertyFactory.textOpacity(1f)); } } } });
66. Retrieving a single map style’s layer names mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(final MapboxMap mapboxMap) { for (Layer singleMapLayer : mapboxMap.getLayers()) { Log.d("MainActivity", "onMapReady: layer name = "+ singleMapLayer.getId()); } }); }
67. Data-driven styling
68. Some current customers – 现有的客户
69. Want to learn more? 你想了解更多吗?
70. Android documentation 技术资料 mapbox.com/android-docs 中文资料: mapbox.cn/help/first-steps-android-sdk/ & mapbox.cn/android-sdk
71. Blog 博客 blog.mapbox.com 微信公众号:Mapbox
72. Location + context 最后,位置数据服务是最重要的