ArcGIS Runtime SDK for Android 100.x系列中如何去除水印和ESRI logo信息

背景:

ArcGIS Runtime SDK for Android中一个展示地图的示例(https://developers.arcgis.com/android/latest/sample-code/display-map.htm),如下:

public class MainActivity extends AppCompatActivity {

  private MapView mMapView;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    // inflate MapView from layout
    mMapView = (MapView) findViewById(R.id.mapView);
    // create a map with the BasemapType topographic
    ArcGISMap map = new ArcGISMap(Basemap.Type.TOPOGRAPHIC, 34.056295, -117.195800, 16);
    // set the map to be displayed in this view
    mMapView.setMap(map);
  }

  @Override
  protected void onPause() {
    super.onPause();
    mMapView.pause();
  }

  @Override
  protected void onResume() {
    super.onResume();
    mMapView.resume();
  }

  @Override
  protected void onDestroy() {
    super.onDestroy();
    mMapView.dispose();
  }
}

运行完是这样的:

其中“Licensed For Developer Use Only”是水印,“Powered by Esri”是logo,如果不想在自己的地图视图显示水印和logo,怎样去除呢,方法如下:

1、ArcGIS Runtime SDK for Android 100.x系列中如何去除水印

在自己的代码中,在调用ArcGIS Runtime SDK for Android 的api代码段之前加上下述语句,

   // license with a license key
ArcGISRuntimeEnvironment.setLicense("runtimelite,1000,rud4449636536,none,NKMFA0PL4S0DRJE15166");

即可在运行程序后清除水印,清除后的效果图如下:

但是,此时在我们的地图视图下方还能看到“Powered by Esri”logo,如何去除请往下看;

2、ArcGIS Runtime SDK for Android 100.x系列中如何去除ESRI logo信息

调用MapView的setAttributionTextVisible()这一方法,如下:

mMapView.setAttributionTextVisible(false);

注:在10.2.x系列上直接调用MapView的setEsriLogoVisible方法即可。

设置后,再次运行应用程序。

最终我们的清除水印和logo的代码如下:

public class MainActivity extends AppCompatActivity {

  private MapView mMapView;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // license with a license key
    ArcGISRuntimeEnvironment.setLicense("runtimelite,1000,rud4449636536,none,NKMFA0PL4S0DRJE15166");

   // inflate MapView from layout
    mMapView = (MapView) findViewById(R.id.mapView);

    mMapView.setAttributionTextVisible(false);
   // create a map with the BasemapType topographic
    ArcGISMap map = new ArcGISMap(Basemap.Type.TOPOGRAPHIC, 34.056295, -117.195800, 16);
   // set the map to be displayed in this view
    mMapView.setMap(map);
  }

  @Override
  protected void onPause() {
    super.onPause();
    mMapView.pause();
  }

  @Override
  protected void onResume() {
    super.onResume();
    mMapView.resume();
  }

  @Override
  protected void onDestroy() {
    super.onDestroy();
    mMapView.dispose();
  }
}

原理解析:

在上述中清除水印调用了ArcGISRuntimeEnvironment的setLicense方法,通过在setLicense中传入我们的licenseKey,也就是授权码就能够成功去除水印,在上述示例中的licenseKey我是传入自己的Lite级别的licenseKey。

在你可以在生产中使用你的应用程序之前,需要授权ArcGIS Runtime应用程序。Esri提供了四个ArcGIS Runtime许可级别:Lite、Basic、Standard和Advanced。每增加一个级别,就会为应用程序用户提供更多的可用功能。其中Lite级别是免费的,可以登录ArcGIS for Developers帐户,转到仪表板,将Runtime Lite许可证密钥复制到应用程序中,即可去除水印,但是Lite级别能够支持的功能是有限,如果你的应用程序还需要用到更高级的功能,那就需要购买其它级别(Basic、Standard和Advanced)的Runtime许可了。

每种许可类型(:Lite、Basic、Standard和Advanced)支持的对应功能的具体介绍,可以参考链接:https://developers.arcgis.com/android/license-and-deployment/license/

提示:我们开发测试时是可以使用所有功能的,只是这时运行的app界面会有“Licensed For Developer Use Only”水印。

如果是想获取Lite级别的Runtime licenseKey如何获取呢?请参考这个链接:https://developers.arcgis.com/pricing/licensing/

(提示:在下述示意图中需要注册developer账号,我是之前注册过所以直接输入账户名和密码即可登录ArcGIS for Developer。)

 

  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值