当前位置: 首页>>代码示例>>Java>>正文


Java Location.getLatitude方法代码示例

本文整理汇总了Java中android.location.Location.getLatitude方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getLatitude方法的具体用法?Java Location.getLatitude怎么用?Java Location.getLatitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.location.Location的用法示例。


在下文中一共展示了Location.getLatitude方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onListItemClick

import android.location.Location; //导入方法依赖的package包/类
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    Location loc = (Location) l.getAdapter().getItem(position);
    Toast.makeText(this, loc.getLatitude() + " " + loc.getLongitude(), Toast.LENGTH_SHORT).show();

    //simplesmente centraliza o mapa na latitude/longitude escolhida
    //nao amarra com google maps
    String locData = "geo:"+loc.getLatitude()+","+loc.getLongitude();

    //locData = "geo:"+loc.getLatitude()+","+loc.getLongitude()+"(AQUI)";

    //abre streetview
    //locData = "google.streetview:cbll="+loc.getLatitude()+","+loc.getLongitude();

    //abre navigation
    //locData = "google.navigation:q="+loc.getLatitude()+","+loc.getLongitude();

    Uri locationURI = Uri.parse(locData);

    Intent i = new Intent(Intent.ACTION_VIEW, locationURI);
    if (i.resolveActivity(getPackageManager()) != null) {
        startActivity(i);
    }
}
 
开发者ID:if710,项目名称:2017.2-codigo,代码行数:25,代码来源:LocationActivity.java

示例2: geocodeUserCountryName

import android.location.Location; //导入方法依赖的package包/类
private void geocodeUserCountryName() {
    // Fetch Country Level Location only if no cached location is available
    Location lastKnownCachedLocation = SharedPreferenceManager.getLastKnownLocation(this);
    if (lastKnownCachedLocation == null || lastKnownCachedLocation.getLatitude() == 0.0
            || lastKnownCachedLocation.getLongitude() == 0.0) {

        OnboardingManager onboardingManager = OnboardingManager.sharedManager(this);
        String countryName = Utils.getCountryName(onboardingManager.getUser().getCountryCode());
        if (!HTTextUtils.isEmpty(countryName)) {
            Intent intent = new Intent(this, FetchLocationIntentService.class);
            intent.putExtra(FetchLocationIntentService.RECEIVER, new GeocodingResultReceiver(new Handler()));
            intent.putExtra(FetchLocationIntentService.ADDRESS_DATA_EXTRA, countryName);
            startService(intent);
        }
    }
}
 
开发者ID:hypertrack,项目名称:hypertrack-live-android,代码行数:17,代码来源:Home.java

示例3: getCirclePoints

import android.location.Location; //导入方法依赖的package包/类
private static ArrayList<LatLng> getCirclePoints(int radius, Location center, int resolution) {
    ArrayList<LatLng> circlePoints = new ArrayList<>();
    final double EARTH_RADIUS = 6378100.0;
    double slice = 2 * Math.PI / resolution;

    double lat = center.getLatitude() * Math.PI / 180.0;
    double lon = center.getLongitude() * Math.PI / 180.0;

    // Get all points that form a circle from your current location
    for (int i = 1; i <= resolution; i++) {
        double angle = slice * i;
        // y
        double latPoint = lat + (radius / EARTH_RADIUS) * Math.sin(angle);
        // x
        double lonPoint = lon + (radius / EARTH_RADIUS) * Math.cos(angle) / Math.cos(lat);

        LatLng p = new LatLng(latPoint * 180.0 / Math.PI, lonPoint * 180.0 / Math.PI);
        circlePoints.add(p);
    }
    return circlePoints;
}
 
开发者ID:kav0rka,项目名称:VennTracker,代码行数:22,代码来源:Circles.java

示例4: onLocationChanged

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {

    currentLatitude = location.getLatitude();
    currentLongitude = location.getLongitude();

    //Toast.makeText(this, currentLatitude + " WORKS " + currentLongitude + "", Toast.LENGTH_LONG).show();

    LatLng latLng = new LatLng(currentLatitude, currentLongitude);
    googleMap.addMarker(new MarkerOptions().position(latLng));
    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
    googleMap.animateCamera(CameraUpdateFactory.zoomIn());
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);

    getNearByClinics(currentLongitude, currentLatitude);

}
 
开发者ID:webianks,项目名称:Crimson,代码行数:18,代码来源:SearchClinics.java

示例5: onLocationChanged

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location)
{
    mLastLocation = location;
    if (mCurrLocationMarker != null) {
        mCurrLocationMarker.remove();
    }

    //Place current location marker
    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    markerOptions.title("Current Position");
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
    mCurrLocationMarker = mGoogleMap.addMarker(markerOptions);

    //move map camera
    mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng,11));

}
 
开发者ID:CMPUT301F17T29,项目名称:HabitUp,代码行数:21,代码来源:MapsActivity.java

示例6: onMapReady

import android.location.Location; //导入方法依赖的package包/类
/**
 * Add map markers for all events that have valid locations
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    LatLngBounds.Builder builder = new LatLngBounds.Builder();

    // whether there is atleast one event with a location to be displayed on the map or not
    boolean atleastOneEvent = false;

    for (CompletedEventDisplay event : events){
        Location location = event.getLocation();
        if (location != null){
            LatLng coordinates = new LatLng(location.getLatitude(), location.getLongitude());
            builder.include(coordinates);
            atleastOneEvent = true;
            mMap.addMarker(new MarkerOptions().position(coordinates).title(event.getDescriptionWithLocation(this)));
        }
    }

    /**
     * This, along with the LatLngBounds.Builder part of this method is based off of andr's answer:
     * https://stackoverflow.com/a/14828739
     *
     * The width, height, padding aspects of newLatLngBounds() is from:
     * https://github.com/OneBusAway/onebusaway-android/issues/581
     */
    if (atleastOneEvent) {
        mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), getResources().getDisplayMetrics().widthPixels,
                getResources().getDisplayMetrics().heightPixels, (int) Math.ceil(0.12 * getResources().getDisplayMetrics().widthPixels)));
    } else {
        // move the map to the device's current location
        Location deviceLoc = LocationUtilities.getLocation(this);
        if (deviceLoc != null)
            googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(deviceLoc.getLatitude(), deviceLoc.getLongitude()), 30));
    }
}
 
开发者ID:CMPUT301F17T15,项目名称:CIA,代码行数:39,代码来源:ViewEventsMapActivity.java

示例7: onReceive

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (LocationResult.hasResult(intent)) {
        LocationResult locationResult = LocationResult.extractResult(intent);
        Location location = locationResult.getLastLocation();
        if (location != null) {
            GPSTracker.mLastestLocation = new LatLng(location.getLatitude(), location.getLongitude());
            adapter.notifyDataSetChanged();
        }
    }
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:12,代码来源:ProductListFragment.java

示例8: setCoordinates

import android.location.Location; //导入方法依赖的package包/类
private void setCoordinates(Location location) {
    Log.e("SET", "setting, location is: " + location.getLatitude() + "and" + location.getLongitude());
    if (coordinate != null) {
        coordinate.setLat(location.getLatitude());
        coordinate.setLon(location.getLongitude());
    }
    else {
        coordinate = new Coordinate(location.getLatitude(), location.getLongitude());
    }
}
 
开发者ID:CMPUT301W17T08,项目名称:Moodr,代码行数:11,代码来源:AddMoodActivity.java

示例9: onMapReady

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onMapReady( GoogleMap googleMap ){
    map = googleMap;
    if( isLocationEnable() ){
        Location location = getLastKnownLocation();
        if( location != null ){
            double latitude = location.getLatitude();
            double longitude = location.getLongitude();
            LatLng current = new LatLng( latitude, longitude );
            map.moveCamera( CameraUpdateFactory.newLatLngZoom( current, DEFAULT_ZOOM ) );
        }
    }
    setupMap();
}
 
开发者ID:TheKhaeng,项目名称:nongbeer-mvp-android-demo,代码行数:15,代码来源:MapActivity.java

示例10: onConnected

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {

    if (checkPermission()) {
        Location location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
        double latitude = location.getLatitude();
        double longitude = location.getLongitude();
    } else {

    }

}
 
开发者ID:PacktPublishing,项目名称:Android-Wear-Projects,代码行数:13,代码来源:MapsActivity.java

示例11: setLatLong

import android.location.Location; //导入方法依赖的package包/类
public void setLatLong(Location location) {
    double lastLat = location.getLatitude();
    double lastLong = location.getLongitude();
    SharedPreferences.Editor edit = preferences.edit();
    edit.putString("last_gps_lat", String.valueOf(lastLat));
    edit.putString("last_gps_long", String.valueOf(lastLong));
    edit.apply();
    settingsFragment.setLocSummary();
}
 
开发者ID:MTBehnke,项目名称:NightSkyGuide,代码行数:10,代码来源:SettingsActivity.java

示例12: onLocationChanged

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location l) {
    if (l != null) {
        userLocation = new LatLng(l.getLatitude(), l.getLongitude());
        if (mUser.getUserID() != null) {
            mDatabase.child("users").child(mUser.getUserID()).child("latitude").setValue(userLocation.latitude);
            mDatabase.child("users").child(mUser.getUserID()).child("longitude").setValue(userLocation.longitude);
        } else {
            Toast.makeText(getApplicationContext(), "Current user not recognized. Try reauthenticating.",
                    Toast.LENGTH_LONG).show();
        }
    }
}
 
开发者ID:panzerama,项目名称:Dispatch,代码行数:14,代码来源:LocationUpdaterService.java

示例13: Geolocation

import android.location.Location; //导入方法依赖的package包/类
Geolocation(Location location) {
        this.setFieldValue(TIMESTAMP, location.getTime());
        this.setFieldValue(PROVIDER, location.getProvider());
//        List<Double> coordinates = new ArrayList<>();
//        coordinates.add(location.getLatitude());
//        coordinates.add(location.getLongitude());
//        coordinates.add(location.getAltitude());
//        this.setFieldValue(COORDINATES, coordinates);
        LatLon latLon = new LatLon(location.getLatitude(), location.getLongitude());
        this.setFieldValue(LAT_LON, latLon);
        this.setFieldValue(ACCURACY, location.getAccuracy());
        this.setFieldValue(SPEED, location.getSpeed());
        this.setFieldValue(BEARING, location.getBearing());
    }
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:15,代码来源:Geolocation.java

示例14: locationUpdates

import android.location.Location; //导入方法依赖的package包/类
@Override
public void locationUpdates(Location location)
{
    double currentLatitude = location.getLatitude();
    double currentLongitude = location.getLongitude();

    Toast.makeText(MainActivity.this, "Latitude: " + currentLatitude + "" + " Longitude: " + currentLongitude + "", Toast.LENGTH_LONG).show();

}
 
开发者ID:yash786agg,项目名称:GPS,代码行数:10,代码来源:MainActivity.java

示例15: onLocationChanged

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
    //int counter = 0;
    if (location != null) {
        lon = location.getLongitude();
        lat = location.getLatitude();

        Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
        try {
            address = geocoder.getFromLocation(lat, lon, 1);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


    }
    if(address != null && address.size() != 0){
        premise = address.get(0).getPremises();
        locality = address.get(0).getLocality();
        postalCode = address.get(0).getPostalCode();
        //country = address.get(0).getCountryName();
        thoroughfare = address.get(0).getThoroughfare();
        subThoroughfare = address.get(0).getSubThoroughfare();
        subLocality = address.get(0).getSubLocality();


    }
}
 
开发者ID:sommukhopadhyay,项目名称:nirbhaya,代码行数:30,代码来源:LocationSendService.java


注:本文中的android.location.Location.getLatitude方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。