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


Java LatLng类代码示例

本文整理汇总了Java中com.google.android.gms.maps.model.LatLng的典型用法代码示例。如果您正苦于以下问题:Java LatLng类的具体用法?Java LatLng怎么用?Java LatLng使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onMapReady

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
/**
     * Manipulates the map once available.
     * This callback is triggered when the map is ready to be used.
     * This is where we can add markers or lines, add listeners or move the camera. In this case,
     * we just add a marker near Sydney, Australia.
     * If Google Play services is not installed on the device, the user will be prompted to install
     * it inside the SupportMapFragment. This method will only be triggered once the user has
     * installed Google Play services and returned to the app.
     */
    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;


        // Add a marker in Sydney and move the camera
Log.e("zzzz"+MainActivity.mylocationa, ""+MainActivity.myLocationb);
        LatLng sydney = new LatLng(MainActivity.lat,MainActivity.longi);
        mMap.addMarker(new MarkerOptions().position(sydney).title("Marker at your location"));
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney,16));
        Toast.makeText(getApplicationContext(),"At the height of "+MainActivity.diffelevation+" metres",Toast.LENGTH_LONG).show();
         }
 
开发者ID:iamjaspreetsingh,项目名称:LifeSaver,代码行数:22,代码来源:MapsActivity.java

示例2: showMarkers

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
private void showMarkers() {
  googleMap.clear();
  Observable
      .fromIterable(currentDevices)
      .subscribe(device -> {
        Location center = GeoHash.fromString(device.getGeoHash()).getCenter();
        Marker marker = googleMap.addMarker(new MarkerOptions()
            .position(new LatLng(center.getLatitude(), center.getLongitude()))
            .icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_launcher))
            .flat(true)
            .title(device.getName())
            .snippet(device.getAddress())
        );
        Bitmap bitmap = Device.getBitmapImage(device.getImage(), getResources());
        Bitmap bmp = Bitmap.createScaledBitmap(bitmap, markerSize, markerSize, false);
        bitmap.recycle();
        marker.setIcon(BitmapDescriptorFactory.fromBitmap(bmp));
      });
}
 
开发者ID:drfonfon,项目名称:ITagAntiLost,代码行数:20,代码来源:DevicesActivity.java

示例3: getDirectionsUrl

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
public LinkedHashMap<String,String> getDirectionsUrl(LatLng origin, LatLng dest){

        LinkedHashMap<String,String> map = new LinkedHashMap<>();
        map.put("origin",origin.latitude+","+origin.longitude);
        map.put("destination",dest.latitude+","+dest.longitude);
        map.put("sensor","false");
        map.put("units","metric");

        if (modeType!=null){
            map.put(MODE,modeType.getName());
        }
        else{
            map.put(MODE, Mode.DRIVING.getName());
        }

        return map;
    }
 
开发者ID:afiqiqmal,项目名称:MVP-Android,代码行数:18,代码来源:GMapUtils.java

示例4: getQuestionAnswers

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
public static QuestionAnswerManager.QuestionAnswers getQuestionAnswers(LatLng latLng, int qaId) {

        JSONObject obj = qa.get(latLng);
        String questionKey = "Question" + qaId;

        String question = "";
        List<String> answers = new ArrayList<>();
        String answerKey = "Answer" + qaId;

        try {
            question = obj.getString(questionKey);
            for (int i = 1; i <= 3; i++) {
                answers.add(obj.getString(answerKey + i));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new QuestionAnswers(question, answers);
    }
 
开发者ID:Augugrumi,项目名称:SpaceRace,代码行数:21,代码来源:QuestionAnswerManager.java

示例5: buildClickBoundingBox

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
/**
 * Build a bounding box using the location coordinate click location and map view bounds
 *
 * @param latLng    click location
 * @param mapBounds map bounds
 * @return bounding box
 * @since 1.2.7
 */
public BoundingBox buildClickBoundingBox(LatLng latLng, BoundingBox mapBounds) {

    // Get the screen width and height a click occurs from a feature
    double width = TileBoundingBoxMapUtils.getLongitudeDistance(mapBounds) * screenClickPercentage;
    double height = TileBoundingBoxMapUtils.getLatitudeDistance(mapBounds) * screenClickPercentage;

    LatLng leftCoordinate = SphericalUtil.computeOffset(latLng, width, 270);
    LatLng upCoordinate = SphericalUtil.computeOffset(latLng, height, 0);
    LatLng rightCoordinate = SphericalUtil.computeOffset(latLng, width, 90);
    LatLng downCoordinate = SphericalUtil.computeOffset(latLng, height, 180);

    BoundingBox boundingBox = new BoundingBox(leftCoordinate.longitude, downCoordinate.latitude, rightCoordinate.longitude, upCoordinate.latitude);

    return boundingBox;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:24,代码来源:FeatureOverlayQuery.java

示例6: updateUI

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
private void updateUI() {
    if (mMap == null || mMapImage == null) {
        return;
    }
    Log.d(TAG, "updateUI: ");
    LatLng itemPoint = new LatLng(mMapItem.getLat(), mMapItem.getLon());
    LatLng myPoint = new LatLng(mCurrentLocation.getLatitude(),
            mCurrentLocation.getLongitude());
    BitmapDescriptor itemBitmap = BitmapDescriptorFactory.fromBitmap(mMapImage);
    MarkerOptions itemMarker = new MarkerOptions()
            .position(itemPoint)
            .icon(itemBitmap);
    MarkerOptions myMarker = new MarkerOptions()
            .position(myPoint);
    mMap.clear();
    mMap.addMarker(itemMarker);
    mMap.addMarker(myMarker);
    LatLngBounds bounds = new LatLngBounds.Builder()
            .include(itemPoint)
            .include(myPoint)
            .build();
    int margin = getResources().getDimensionPixelSize(R.dimen.map_inset_margin);
    CameraUpdate update = CameraUpdateFactory.newLatLngBounds(bounds, margin);
    mMap.animateCamera(update);
}
 
开发者ID:ivicel,项目名称:Android-Programming-BigNerd,代码行数:26,代码来源:LocatrFragment.java

示例7: showPermissionGranted

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
public void showPermissionGranted(String permission) {
    makeInitialRequest();
    if (getActivity() != null) {
        LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (getActivity().checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && getActivity().checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                notificationManager.showMessage(getString(R.string.no_location));
                map.setMyLocationEnabled(false);
            } else {
                map.setMyLocationEnabled(true);
                locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
                map.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() {
                    @Override
                    public boolean onMyLocationButtonClick() {
                        if (userLocation != null) {
                            LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());
                            map.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16));
                        }
                        return true;
                    }
                });
            }
        }
    }
}
 
开发者ID:Mun0n,项目名称:MADBike,代码行数:26,代码来源:MapFragment.java

示例8: isClosestGate

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
public boolean isClosestGate(LatLng point){
    int gate=Integer.MAX_VALUE;
    float minDistance=Float.MAX_VALUE;

    Location loca1 = new Location("");

    loca1.setLatitude(point.latitude);
    loca1.setLongitude(point.longitude);

    int count=0;
    for(String iterator:delegate.gateNameArray()){
        Location loca2 = new Location("");
        loca2.setLatitude(Double.parseDouble(delegate.gateLatArray()[count]));
        loca2.setLongitude(Double.parseDouble(delegate.gateLongArray()[count]));
        float distance = loca1.distanceTo(loca2);
        if(distance <= minDistance){
            gate = count;
            minDistance = distance;
        }
        count++;
    }

    if(gate == this.gatePosition) return true;
    else return false;

}
 
开发者ID:sarikaya,项目名称:Bee-Analyzer,代码行数:27,代码来源:DBTransaction.java

示例9: doInBackground

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
@Override
protected Integer doInBackground(String... params) {
    android.location.Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
    int times = 0;
    while (location == null && times < 20){
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {

        }
        location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
        times++;
    }
    if (location != null) {
        final CameraPosition position = new CameraPosition.Builder()
                .target(new LatLng(location.getLatitude(), location.getLongitude()))
                .zoom(14.0f).build();
        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                map.animateCamera(CameraUpdateFactory.newCameraPosition(position));
            }
        });
    }
    return null;
}
 
开发者ID:medialab-prado,项目名称:puremadrid,代码行数:26,代码来源:MyMapFragment.java

示例10: PlacePinAndPositionCamera

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
public void PlacePinAndPositionCamera(LatLng addressPosition) {

        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(addressPosition);
        mMap.addMarker(markerOptions
                .title("Crisis Location").icon(BitmapDescriptorFactory
                        .defaultMarker(BitmapDescriptorFactory.HUE_RED)));
        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(addressPosition, 12));
        LatLngBounds.Builder builder = new LatLngBounds.Builder();

        builder.include(addressPosition);

        LatLngBounds bounds = builder.build();

        int padding = 150; // offset from edges of the map in pixels
        CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);

        mMap.animateCamera(cu);
    }
 
开发者ID:panzerama,项目名称:Dispatch,代码行数:20,代码来源:MainActivity.java

示例11: onMapReady

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    boolean success = googleMap.setMapStyle(new MapStyleOptions(getResources()
            .getString(R.string.style_json)));

    if (!success) {
        Log.e("Style", "Style parsing failed.");
    }
    LatLng jakarta = new LatLng(-6.232812, 106.820933);
    LatLng southjakarta = new LatLng(-6.22865,106.8151753);
    mMap.addMarker(new MarkerOptions().position(jakarta).icon(BitmapDescriptorFactory.fromBitmap(getBitmapFromView("Set Pickup Location", R.drawable.dot_pickup))));
    mMap.addMarker(new MarkerOptions().position(southjakarta).icon(BitmapDescriptorFactory.fromBitmap(getBitmapFromView("Set Dropoff Location", R.drawable.dot_dropoff))));
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(jakarta, 15f));


}
 
开发者ID:ahmadnurhidayat,项目名称:Taxi-App-Android-XML,代码行数:19,代码来源:Home.java

示例12: addGateway

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
public void addGateway(Packet packet) {
    for (Gateway gateway : packet.getGateways()) {
        double gwLat = gateway.getLatitude();
        double gwLon = gateway.getLongitude();

        if (gwLat != 0 && gwLon != 0) {
            String gatewayId = gateway.getGatewayID();

            if (gatewaysWithMarkers.contains(gatewayId)) {
                //already has a marker for this gateway
            } else {
                MarkerOptions gwoptions = new MarkerOptions();
                gwoptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.gateway_dot));
                gwoptions.position(new LatLng(gwLat, gwLon));
                gwoptions.title(gatewayId);
                //gwoptions.snippet(gatewayId);
                gwoptions.anchor((float) 0.5, (float) 0.5);
                mMap.addMarker(gwoptions);

                gatewaysWithMarkers.add(gatewayId);
            }
        }
    }
}
 
开发者ID:jpmeijers,项目名称:ttnmapper_android_v2,代码行数:25,代码来源:MapsActivity.java

示例13: gotoLocation

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
/**
 * For actually moving the map to the desired location.
 * @param fctx
 * @param loc
 */
public static void gotoLocation(Activity fctx, Location loc) {
    Location locc = loc;
    sloc = loc;
    if(loc == null){
        locc = getCurrentLocation(fctx);
    }
    if(code == AddHabitEventActivity.EVENT_PERMISSION_CHECK){
    }

    float zoom = 15.0f;
    if(locc == null){
        DummyMainActivity.toastMe("Could not get location", fctx);
    }else{
        double[] d = {locc.getLatitude(), locc.getLongitude()};
        AddHabitEventActivity.setLocation(d);

        LatLng ll = new LatLng(locc.getLatitude(), locc.getLongitude());
        CameraUpdate update = CameraUpdateFactory.newLatLngZoom(ll, zoom);
        gmap.moveCamera(update);
    }
}
 
开发者ID:CMPUT301F17T17,项目名称:Habitizer,代码行数:27,代码来源:MapController.java

示例14: onMapReady

import com.google.android.gms.maps.model.LatLng; //导入依赖的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

示例15: isPointNearMultiLatLng

import com.google.android.gms.maps.model.LatLng; //导入依赖的package包/类
/**
 * Is the point near any points in the multi lat lng
 *
 * @param point       point
 * @param multiLatLng multi lat lng
 * @param tolerance   distance tolerance
 * @return true if near
 */
public static boolean isPointNearMultiLatLng(LatLng point, MultiLatLng multiLatLng, double tolerance) {
    boolean near = false;
    for (LatLng multiPoint : multiLatLng.getLatLngs()) {
        near = isPointNearPoint(point, multiPoint, tolerance);
        if (near) {
            break;
        }
    }
    return near;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:19,代码来源:MapUtils.java


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