获取纬度和经度的负值

getting negative values of latitude and longitude

我想在我的应用程序中获取经度和纬度的值,我已经做到了,但问题是我用 values.Values 得到的负号是正确的,但不知道为什么用 values.Values 得到负号值。

javaclass的代码:

package com.vshine.neuron.testing;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class code extends AppCompatActivity implements LocationListener {
    private TextView textView;
    private LocationManager locationManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_code);
        textView = findViewById(R.id.tv);
        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

         if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
         // TODO: Consider calling
         //    ActivityCompat#requestPermissions
         // here to request the missing permissions, and then overriding
         //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
         //                                          int[] grantResults)
         // to handle the case where the user grants the permission. See the documentation
         // for ActivityCompat#requestPermissions for more details.
         return;
         }
         Location location = locationManager.getLastKnownLocation(locationManager.NETWORK_PROVIDER);
         onLocationChanged(location);
         }

@Override
public void onLocationChanged(Location location) {
        double longitude = location.getLongitude();
        double latitude = location.getLatitude();
        textView.setText("Longitude: " + longitude + "\n\n" + "Latitude: " + latitude);

        }

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {

        }

@Override
public void onProviderEnabled(String provider) {

        }

@Override
public void onProviderDisabled(String provider) {

        }
        }

Latitude and Longitude can have negative values.

你的代码没问题

Check any ref

纬度指定赤道的北部和南部。经度指定本初子午线的东西方。

负纬度表示赤道以南,负经度表示本初子午线以西。

位置数据通常以纬度和经度对的形式表示,如下所示:

37.427619, -122.166972 [斯坦福大学胡佛塔]

下面的简单框架可以帮助您解码位置对。

+ + : North and East 
+ - : North and West 
- - : South and West 
- + : South and East

请注意,此框架的中心点是几内亚湾本初子午线和赤道的交点 0,0。

答案来自知乎。 Quora Link

LatLong 可以是正数也可以是负数。

示例:
44.389061321549, -114.659369144245 是美国爱达荷州的有效 LatLong

只需复制您的 LatLong 并将其粘贴到 Google Maps 的搜索框中,您将获得 LatLong 的准确位置。