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

西安行业网站建设/网络营销到底是个啥

西安行业网站建设,网络营销到底是个啥,做网站 做什么网站好,私人诊所网站源码在这罗盘上的箭头显示从你的位置到天房的方向( 目的地位置 )你可以简单的使用bearingTo,这样就可以给你从你的位置到目的地的直接angular度Location userLocnew Location("service Provider"); //get longitudeM Latitude and altitude of current locati…

在这罗盘上的箭头显示从你的位置到天房的方向( 目的地位置 )

你可以简单的使用bearingTo,这样就可以给你从你的位置到目的地的直接angular度

Location userLoc=new Location("service Provider"); //get longitudeM Latitude and altitude of current location with gps class and set in userLoc userLoc.setLongitude(longitude); userLoc.setLatitude(latitude); userLoc.setAltitude(altitude); Location destinationLoc = new Location("service Provider"); destinationLoc.setLatitude(21.422487); //kaaba latitude setting destinationLoc.setLongitude(39.826206); //kaaba longitude setting float bearTo=userLoc.bearingTo(destinationLoc);

bearingTo会给你一个从-180到180的范围,这会使事情混淆一点。 我们将需要将这个值转换成从0到360的范围以获得正确的旋转。

这是我们真正想要的东西,比较什么方向给我们

+-----------+--------------+ | bearingTo | Real bearing | +-----------+--------------+ | 0 | 0 | +-----------+--------------+ | 90 | 90 | +-----------+--------------+ | 180 | 180 | +-----------+--------------+ | -90 | 270 | +-----------+--------------+ | -135 | 225 | +-----------+--------------+ | -180 | 180 | +-----------+--------------+

所以我们必须在bearTo之后添加这个代码

// If the bearTo is smaller than 0, add 360 to get the rotation clockwise. if (bearTo < 0) { bearTo = bearTo + 360; //bearTo = -100 + 360 = 260; }

您需要实现SensorEventListener及其函数(onSensorChanged,onAcurracyChabge)并将所有代码写入onSensorChanged

完整的代码是在这里为朝拜指南针的方向

public class QiblaDirectionCompass extends Service implements SensorEventListener{ public static ImageView image,arrow; // record the compass picture angle turned private float currentDegree = 0f; private float currentDegreeNeedle = 0f; Context context; Location userLoc=new Location("service Provider"); // device sensor manager private static SensorManager mSensorManager ; private Sensor sensor; public static TextView tvHeading; public QiblaDirectionCompass(Context context, ImageView compass, ImageView needle,TextView heading, double longi,double lati,double alti ) { image = compass; arrow = needle; // TextView that will tell the user what degree is he heading tvHeading = heading; userLoc.setLongitude(longi); userLoc.setLatitude(lati); userLoc.setAltitude(alti); mSensorManager = (SensorManager) context.getSystemService(SENSOR_SERVICE); sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); if(sensor!=null) { // for the system's orientation sensor registered listeners mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_GAME);//SensorManager.SENSOR_DELAY_Fastest }else{ Toast.makeText(context,"Not Supported", Toast.LENGTH_SHORT).show(); } // initialize your android device sensor capabilities this.context =context; @Override public void onCreate() { // TODO Auto-generated method stub Toast.makeText(context, "Started", Toast.LENGTH_SHORT).show(); mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_GAME); //SensorManager.SENSOR_DELAY_Fastest super.onCreate(); } @Override public void onDestroy() { mSensorManager.unregisterListener(this); Toast.makeText(context, "Destroy", Toast.LENGTH_SHORT).show(); super.onDestroy(); } @Override public void onSensorChanged(SensorEvent sensorEvent) { Location destinationLoc = new Location("service Provider"); destinationLoc.setLatitude(21.422487); //kaaba latitude setting destinationLoc.setLongitude(39.826206); //kaaba longitude setting float bearTo=userLoc.bearingTo(destinationLoc); //bearTo = The angle from true north to the destination location from the point we're your currently standing.(asal image k N se destination taak angle ) //head = The angle that you've rotated your phone from true north. (jaise image lagi hai wo true north per hai ab phone jitne rotate yani jitna image ka n change hai us ka angle hai ye) GeomagneticField geoField = new GeomagneticField( Double.valueOf( userLoc.getLatitude() ).floatValue(), Double .valueOf( userLoc.getLongitude() ).floatValue(), Double.valueOf( userLoc.getAltitude() ).floatValue(), System.currentTimeMillis() ); head -= geoField.getDeclination(); // converts magnetic north into true north if (bearTo < 0) { bearTo = bearTo + 360; //bearTo = -100 + 360 = 260; } //This is where we choose to point it float direction = bearTo - head; // If the direction is smaller than 0, add 360 to get the rotation clockwise. if (direction < 0) { direction = direction + 360; } tvHeading.setText("Heading: " + Float.toString(degree) + " degrees" ); RotateAnimation raQibla = new RotateAnimation(currentDegreeNeedle, direction, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); raQibla.setDuration(210); raQibla.setFillAfter(true); arrow.startAnimation(raQibla); currentDegreeNeedle = direction; // create a rotation animation (reverse turn degree degrees) RotateAnimation ra = new RotateAnimation(currentDegree, -degree, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); // how long the animation will take place ra.setDuration(210); // set the animation after the end of the reservation status ra.setFillAfter(true); // Start the animation image.startAnimation(ra); currentDegree = -degree; } @Override public void onAccuracyChanged(Sensor sensor, int i) { } @Nullable @Override public IBinder onBind(Intent intent) { return null; }

XML代码在这里

http://www.jmfq.cn/news/5085235.html

相关文章:

  • html 与wordpress/重庆seo霸屏
  • 企业网站及公众号建设方案/俄罗斯搜索引擎yandex官网入口
  • hefei 网站制作/关注公众号推广2元一个
  • 企业名录搜索网站/广州seo网站
  • 建网站做站长怎么赚钱/软文一般发布在哪些平台
  • 商城网站建设方案/东莞seo推广机构帖子
  • wordpress nginx 404/关键词推广seo怎么优化
  • 网站电子签名怎么做/最新中国新闻
  • 现在标书都从哪个网站下载/网络优化的基本方法
  • 网站如何提升流量/bt种子万能搜索神器
  • 辅导班如何做网站/网络查询网站
  • 千锋教育西安校区/seo排名优化公司价格
  • 营销型网站建设大千建站/浙江网络推广公司
  • 网页使用怎么做/杭州seo顾问
  • 网站域名怎么免费获取/网络优化工程师需要学什么
  • 福永网站的建设/建网站怎么赚钱
  • 网站后期维护工作包括哪些/厉害的seo顾问
  • 查询企业年报的网站/东莞搜索引擎推广
  • 成都设计公司视频制作/百度关键词优化系统
  • 篇高端网站愿建设/在线看seo网站
  • 乐山 做网站/百度搜索引擎优化的方法
  • 网站建设设计的流程/矿泉水软文广告500字
  • 通信工程网站建设/郑州网络运营培训
  • 湖北省住房和城乡建设厅门户网站/郑州seo多少钱
  • 曰本真人性做爰 酥酥网站/百度网络营销中心
  • 深圳网站设计公司电/热搜榜排名今日
  • 做微信网站/线上宣传方式
  • 电商实训网站建设报告/百度推广技巧方法
  • 网站建设公司哪里好/线下营销推广方式有哪些
  • 新民正规网站建设价格咨询/网络广告四个特征