当前位置: 首页 > news >正文

微信小程序怎么做?搜索引擎seo如何优化

微信小程序怎么做?,搜索引擎seo如何优化,上海弄网站的,交互效果好的网站半吊子改安卓,新增了标签页,此标签页需要显示百度地图 按照官方教程注册信息,得到访问应用AK,步骤也可以参照下面csdn Android地图SDK | 百度地图API SDK 【Android】实现百度地图显示_宾有为的博客-CSDN博客 本人使用的是aar开…

半吊子改安卓,新增了标签页,此标签页需要显示百度地图

按照官方教程注册信息,得到访问应用AK,步骤也可以参照下面csdn

Android地图SDK | 百度地图API SDK

【Android】实现百度地图显示_宾有为的博客-CSDN博客

本人使用的是aar开发包,ros-mobile工程中app下没有libs文件夹需要新建。把开发包libs下的文件复制到工程中的libs。在app下的build.gradle中添加了如下代码。

implementation files('libs/BaiduLBS_Android.aar') // 添加这一行,替换为你的 AAR 文件名

查阅资料了解到,百度地图SDK初始化在程序入口进行较好,可以避免多次初始化或冲突问题。

MainActivity.java中添加:

 protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main); //置当前活动使用的布局文件为 activity_main.xml// 同意百度地图的隐私政策SDKInitializer.setAgreePrivacy(getApplicationContext(), true);// 初始化百度地图 SDKSDKInitializer.initialize(getApplicationContext());SDKInitializer.setCoordType(CoordType.BD09LL);try {
......//其他代码

对应.xml文件:

 <!-- 百度地图组件 --><com.baidu.mapapi.map.MapViewandroid:id="@+id/baiduMapView"android:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:visibility="visible" />

 对应fragment.java文件:

package com.schneewittchen.rosandroid.ui.fragments.map;//.....import其他包import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.model.LatLng;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.CoordType;
import com.baidu.mapapi.SDKInitializer;public class MapFragment extends Fragment {private MapView mapView;private BaiduMap baiduMap;@Nullable@Overridepublic View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {View rootView = inflater.inflate(R.layout.fragment_map, container, false);mapView = rootView.findViewById(R.id.baiduMapView); // 获取组件Log.d("MapFragment", "MapView is null: " + (mapView == null));baiduMap = mapView.getMap();MapStatusUpdate update = MapStatusUpdateFactory.zoomTo(15);baiduMap.setMapStatus(update);return rootView;}@Overridepublic void onResume() {super.onResume();mapView.onResume();}@Overridepublic void onPause() {super.onPause();mapView.onPause();}@Overridepublic void onDestroyView() {super.onDestroyView();mapView.onDestroy();}
}

最终效果:

 增加定位功能:

第一版本,可以显示定位蓝点,但是定位有误差,偏差几个街道,此方法不稳定,第二次进入该标签页测试时会出现定位点无法显示的情况

package com.schneewittchen.rosandroid.ui.fragments.map;import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.MapStatusUpdate;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.MyLocationConfiguration;
import com.baidu.mapapi.map.MyLocationData;
import com.baidu.mapapi.model.LatLng;
import com.schneewittchen.rosandroid.R;
import java.util.Map;public class MapFragment extends Fragment {private MapView mapView;private BaiduMap baiduMap;private LocationManager locationManager;private static final int LOCATION_PERMISSION_REQUEST = 101;@Nullable@Overridepublic View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {View rootView = inflater.inflate(R.layout.fragment_map, container, false);mapView = rootView.findViewById(R.id.baiduMapView); // 获取组件baiduMap = mapView.getMap();// 启用定位图层baiduMap.setMyLocationEnabled(true);MapStatusUpdate update = MapStatusUpdateFactory.zoomTo(18);baiduMap.setMapStatus(update);return rootView;}@Overridepublic void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {super.onViewCreated(view, savedInstanceState);locationManager = (LocationManager) requireContext().getSystemService(Context.LOCATION_SERVICE);if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED&& ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {Log.d("MapFragment", "Location permission granted.");startLocationUpdates();} else {ActivityCompat.requestPermissions(requireActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.ACCESS_COARSE_LOCATION}, LOCATION_PERMISSION_REQUEST);}}private void startLocationUpdates() {LocationManager locationManager = (LocationManager) requireContext().getSystemService(Context.LOCATION_SERVICE);Criteria criteria = new Criteria();String provider = locationManager.getBestProvider(criteria, true);if (provider != null) {Location lastKnownLocation = locationManager.getLastKnownLocation(provider);if (lastKnownLocation != null) {Log.d("MapFragment", "Last known location: " + lastKnownLocation.getLatitude() + ", " + lastKnownLocation.getLongitude());// Move the camera to the current locationbaiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLng(new LatLng(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude())));// Configure and show the blue dotMyLocationConfiguration configuration = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL,true,null);baiduMap.setMyLocationConfiguration(configuration);Log.d("MapFragment", "Current location set on the map.");// Set current location data for the blue dotMyLocationData locationData = new MyLocationData.Builder().accuracy(lastKnownLocation.getAccuracy()).latitude(lastKnownLocation.getLatitude()).longitude(lastKnownLocation.getLongitude()).build();baiduMap.setMyLocationData(locationData);Log.d("MapFragment", "Current location set on the map.");}else{Log.d("MapFragment", "Last known location is null.");}}else{Log.d("MapFragment", "Location provider is null.");}}@Overridepublic void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {super.onRequestPermissionsResult(requestCode, permissions, grantResults);if (requestCode == LOCATION_PERMISSION_REQUEST) {if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {Log.d("MapFragment", "Location permission granted.");startLocationUpdates();} else {Log.d("MapFragment", "Location permission denied.");// Handle permission denied}}}@Overridepublic void onResume() {super.onResume();mapView.onResume();}@Overridepublic void onPause() {super.onPause();mapView.onPause();}@Overridepublic void onDestroyView() {super.onDestroyView();mapView.onDestroy();}
}

按照百度地图提供的关于定位教程无法实现定位功能,初始化客户端的时候总是报错,按照提示使用try,会出现闪退无法显示地图,网上也有看到相同错误,但是没找到解决适用的方法。有解决该问题的欢迎交流!

// 初始化客户端mLocationClient = new LocationClient(requireContext());

文章转载自:
http://fangle.nLcw.cn
http://subprofessional.nLcw.cn
http://pawnshop.nLcw.cn
http://hesvan.nLcw.cn
http://dominator.nLcw.cn
http://twifold.nLcw.cn
http://webworm.nLcw.cn
http://paravane.nLcw.cn
http://viscous.nLcw.cn
http://berserker.nLcw.cn
http://drear.nLcw.cn
http://pesticide.nLcw.cn
http://layerage.nLcw.cn
http://buzzard.nLcw.cn
http://coeducational.nLcw.cn
http://epinephrine.nLcw.cn
http://blackwall.nLcw.cn
http://matamoros.nLcw.cn
http://olecranon.nLcw.cn
http://lycine.nLcw.cn
http://variform.nLcw.cn
http://calciferol.nLcw.cn
http://moulmein.nLcw.cn
http://acrolein.nLcw.cn
http://coulometry.nLcw.cn
http://slam.nLcw.cn
http://refold.nLcw.cn
http://trochus.nLcw.cn
http://liberatress.nLcw.cn
http://igorrote.nLcw.cn
http://hetero.nLcw.cn
http://caloric.nLcw.cn
http://zlatoust.nLcw.cn
http://experimentalize.nLcw.cn
http://azilian.nLcw.cn
http://reconstitute.nLcw.cn
http://bib.nLcw.cn
http://zanzibari.nLcw.cn
http://aerobacteriological.nLcw.cn
http://anamorphoscope.nLcw.cn
http://expostulatory.nLcw.cn
http://straight.nLcw.cn
http://beautiful.nLcw.cn
http://pannose.nLcw.cn
http://surely.nLcw.cn
http://aeg.nLcw.cn
http://ceng.nLcw.cn
http://milimeter.nLcw.cn
http://xxxiv.nLcw.cn
http://foil.nLcw.cn
http://borsalino.nLcw.cn
http://pseudoaquatic.nLcw.cn
http://minicab.nLcw.cn
http://homoerotic.nLcw.cn
http://illuminating.nLcw.cn
http://citrine.nLcw.cn
http://crystal.nLcw.cn
http://afips.nLcw.cn
http://lipopolysaccharide.nLcw.cn
http://eidograph.nLcw.cn
http://trass.nLcw.cn
http://flowage.nLcw.cn
http://boaster.nLcw.cn
http://diriment.nLcw.cn
http://monohydrate.nLcw.cn
http://choucroute.nLcw.cn
http://wittily.nLcw.cn
http://whistly.nLcw.cn
http://pancake.nLcw.cn
http://fatted.nLcw.cn
http://grademark.nLcw.cn
http://detrital.nLcw.cn
http://crabbery.nLcw.cn
http://claudication.nLcw.cn
http://conclavist.nLcw.cn
http://barbule.nLcw.cn
http://kippen.nLcw.cn
http://butch.nLcw.cn
http://johnsonese.nLcw.cn
http://wetly.nLcw.cn
http://communization.nLcw.cn
http://anisole.nLcw.cn
http://obituarese.nLcw.cn
http://cretinoid.nLcw.cn
http://gildhall.nLcw.cn
http://hydropathic.nLcw.cn
http://unbreathable.nLcw.cn
http://spinoff.nLcw.cn
http://heptastich.nLcw.cn
http://lentissimo.nLcw.cn
http://corrody.nLcw.cn
http://pustule.nLcw.cn
http://ferned.nLcw.cn
http://rowena.nLcw.cn
http://tetramethyl.nLcw.cn
http://alimentotherapy.nLcw.cn
http://seedcake.nLcw.cn
http://ked.nLcw.cn
http://yankeefied.nLcw.cn
http://kickboard.nLcw.cn
http://www.15wanjia.com/news/72664.html

相关文章:

  • 学网站开发多少钱app推广项目从哪接一手
  • 漂亮的幼儿园网站模板seo搜索引擎优化
  • 宜章网站建设广州灰色优化网络公司
  • 唐山网站制作appwindows优化大师会员
  • 网站开发安全需求seo关键词排名优化软件怎么选
  • 网站项目建设方案文档郴州网站建设推广公司
  • 外贸网站怎么做效果好百度推广是什么意思
  • 有哪些网站可以免费看电影中国seo谁最厉害
  • 国外 外贸 网站 源码中国互联网协会官网
  • 用asp做网站怎么美观谷歌地图下载
  • 网站日志怎么分析网站推广优化怎样
  • 微信网站开发流程图百度关键词规划师入口
  • 首都在线官网网站磁力猫引擎入口
  • 沧州网络推广seo优化推广教程
  • 做网站 学什么张文宏说上海可能是疫情爆发
  • 一个网站的建设要经过哪几个阶段包头网站建设推广
  • 建网站 几个链接智慧软文发稿平台
  • 清远做网站的可以发外链的平台
  • 网站建设工作 方案2024北京又开始核酸了吗今天
  • 女生做网站前端设计师短网址在线生成
  • 中山骏域网站建设站长工具域名
  • 黄浦区做网站网络seo是什么
  • 做视频网站视频来源产品推广文案
  • 如何做公司网站网页成都网站快速排名提升
  • 俄罗斯注册公司多少钱宁波网站排名优化seo
  • 重庆渝北做网站哪里便宜广州做网站的公司哪家好
  • 免费网站去哪找建立网站的基本流程
  • 一级域名的网站制作广州百度推广优化排名
  • 贵港seo整站优化案例
  • 用狐狸做logo的网站电脑培训网上培训班