【问题标题】:Get the latitude and longitude from sqlite to open waze从sqlite获取经纬度到open waze
【发布时间】:2015-11-02 06:25:29
【问题描述】:

我创建了一个由列表视图和地图组成的应用程序。当用户从列表视图中选择时,地图将自动转到该位置。还将显示位置配置文件。由按钮组成的配置文件,当用户单击时,它将指向位智并获取经度的纬度。我不知道我的代码有什么问题,因为它无法获取位置的纬度和经度。我认为我的问题出在字符串 url 中,我无法获取纬度和经度,但我不知道获取它的正确代码。

        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

              LatLng latLngtofocus = new LatLng(Double.parseDouble(GetLocation.get(i).getlatitude()),  Double.parseDouble(GetLocation.get(i).getlatitude()));

                    map.animateCamera(CameraUpdateFactory.newLatLngZoom(latlngtofocus, 17.0f));
                }


    LocationListView = findViewById(R.id.locationlayout);
                    ViewGroup parent = (ViewGroup) LocationListView.getParent();
                    parent.removeView(LocationListView);
                    // inflate your profile view (or get the reference to it if it's already inflated)
                    LocationProfileView = getLayoutInflater().inflate(R.layout.profile_location, parent, false);
                    // add it to the parent
                    parent.addView(LocationProfileView);

btnwaze = (Button) findViewById(R.id.waze);
                btnwaze.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        try
                        {
                            String url = "waze://?q=(Double.parseDouble(GetLocation.get(i).getlatitude()), Double.parseDouble(GetLocation.get(i).getlongitude()))";
                            Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( url ) );
                            startActivity( intent );
                        }
                        catch ( ActivityNotFoundException ex  )
                        {
                            Intent intent =
                                    new Intent( Intent.ACTION_VIEW, Uri.parse( "market://details?id=com.waze" ) );
                            startActivity(intent);
                        }
                    }
                });
  });

【问题讨论】:

    标签: android sqlite google-maps android-studio


    【解决方案1】:

    设置为 final int i 并将之前的代码更改为 String url = "waze://?ll="+GetLocation.get(i).getlatitude()+","+ GetLocation.get(i).getlongitude( )+"&navigate=yes";

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-11
      • 2020-11-07
      • 2010-12-02
      相关资源
      最近更新 更多