|
|
第1行: |
第1行: |
− | {{androidarsdk-sidebar}}
| |
| | | |
− | == 自定义目标 ==
| |
− |
| |
− | Android AR识别SDK支持开发者自定义坐标点和自定义名称在屏幕上展示,Android AR识别SDK会根据用户传递的坐标信息以及本地的定位信息计算出坐标点在本地位置的方位,再根据开发者上传的名字信息进行显示。<br/>a) 开发者可根据如下代码显示一个单点数据;
| |
− |
| |
− | 示例代码如下:
| |
− | <pre class="prettyprint codestyle">//1、ArLatLng类用于开发者自定义的目标点信息,传递经纬度
| |
− | ArLatLng arLatLng = new ArLatLng(40.082545, 116.376188);
| |
− | //2、 ArPoiInfo类用于开发者传递经纬度ArLatLng对象和自定义名称
| |
− | ArPoiInfo poiInfo = new ArPoiInfo();
| |
− | //3、 PoiInfoImpl类用于ArPoiInfo对象的存储
| |
− | PoiInfoImpl poiImpl = new PoiInfoImpl();
| |
− | //4、最后在ArActivity的SimpleSensor.OnHoldPositionListener 传感器监听类中传递给mCamGLView中进行显示,调用方法:
| |
− | mCamGLView.setFindArSensorState(remapValue, getLayoutInflater(), mArPoiItemRl, ArActivity.this, poiInfos, ArActivity.this);
| |
− | </pre>
| |
− |
| |
− | 效果展示如下:<br/>http://mapopen-pub-androidsdk.cdn.bcebos.com/ar/images/singlepoint2.jpg
| |
− |
| |
− | <br/>b) Android AR识别SDK支持传递多坐标点和自定义名称(同自定义单点)在屏幕上展示, Android AR识别SDK会根据用户上传显示多个自定义点,由于手机屏幕限制,一竖排最多能展示7个目标点,自定义目标点最多可展示15个;<br/>示例代码如下:
| |
− | <pre class="prettyprint codestyle"> //1、ArLatLng类用于开发者自定义多个目标点信息,传递经纬度
| |
− | private ArLatLng[] latLngs = {new ArLatLng(40.082545, 116.376188), new ArLatLng(40.04326, 116.376781),
| |
− | new ArLatLng(40.043204, 116.300784)...}
| |
− | //2、遍历多目标点信息,存储到PoiInfoImpl对象中
| |
− | poiInfos = new ArrayList<PoiInfoImpl>();
| |
− | int i = 0;
| |
− | for (ArLatLng all : latLngs) {
| |
− | ArPoiInfo pTest = new ArPoiInfo();
| |
− | pTest.name = "testPoint" + i++;
| |
− | pTest.location = all;
| |
− | PoiInfoImpl poiImplT = new PoiInfoImpl();
| |
− | poiImplT.setPoiInfo(pTest);
| |
− | poiInfos.add(poiImplT);
| |
− | }
| |
− | //3、最后在ArActivity的SimpleSensor.OnHoldPositionListener 传感器监听类中传递给mCamGLView中进行显示,调用方法:
| |
− | mCamGLView.setFindArSensorState(remapValue, getLayoutInflater(),mArPoiItemRl, ArActivity.this, poiInfos, ArActivity.this);
| |
− | </pre>
| |
− |
| |
− | 效果展示如下:<br/>http://mapopen-pub-androidsdk.cdn.bcebos.com/ar/images/points2.jpg
| |