com.amap.api.maps2d.model.LatLng Java Examples

The following examples show how to use com.amap.api.maps2d.model.LatLng. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Waypoint2Activity.java    From Android-GSDemo-Gaode-Map with MIT License 6 votes vote down vote up
private void updateDroneLocation() {

        LatLng pos = new LatLng(mAircraftLat, mAircraftLng);
        //Create MarkerOptions object
        final MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(pos);
        markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.aircraft));

        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (droneMarker != null) {
                    droneMarker.remove();
                }

                if (checkGpsCoordination(mAircraftLat, mAircraftLng)) {
                    droneMarker = aMap.addMarker(markerOptions);
                    droneMarker.setRotateAngle(droneHeading * -1.0f);
                }
            }
        });
    }
 
Example #2
Source File: Waypoint2Activity.java    From Android-GSDemo-Gaode-Map with MIT License 6 votes vote down vote up
@Override
public void onMapClick(LatLng point) {
    if (isAdd == true) {
        markWaypoint(point);
        WaypointV2 mWaypoint = new WaypointV2.Builder()
                .setAltitude(altitude)
                .setCoordinate(new LocationCoordinate2D(point.latitude, point.longitude))
                .build();
        //Add Waypoints to Waypoint arraylist;
        if (waypointMissionBuilder != null) {
            waypointList.add(mWaypoint);
            waypointMissionBuilder.addWaypoint(mWaypoint);
        } else {
            waypointMissionBuilder = new WaypointV2Mission.Builder();
            waypointList.add(mWaypoint);
            waypointMissionBuilder.addWaypoint(mWaypoint);
        }
    } else {
        setResultToToast("Cannot Add Waypoint");
    }
}
 
Example #3
Source File: FindMapAroundAty.java    From myapplication with Apache License 2.0 6 votes vote down vote up
private MarkerOptions getMarkerOptions(AMapLocation amapLocation) {
        //设置图钉选项
        MarkerOptions options = new MarkerOptions();
        //图标
        options.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_location_on_black_48dp));
        //位置
        options.position(new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude()));
        StringBuffer buffer = new StringBuffer();
        buffer.append(amapLocation.getCountry() + "" + amapLocation.getProvince() + "" +
                amapLocation.getCity() + "" + amapLocation.getDistrict() + "" +
                amapLocation.getStreet() + "" + amapLocation.getStreetNum());
        //标题
        options.title(buffer.toString());
        //子标题
//        options.snippet("I'am Here!");
        //设置多少帧刷新一次图片资源
        options.period(60);

        return options;

    }
 
Example #4
Source File: Waypoint1Activity.java    From Android-GSDemo-Gaode-Map with MIT License 6 votes vote down vote up
private void updateDroneLocation(){

        LatLng pos = new LatLng(droneLocationLat, droneLocationLng);
        //Create MarkerOptions object
        final MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(pos);
        markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.aircraft));

        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (droneMarker != null) {
                    droneMarker.remove();
                }

                if (checkGpsCoordination(droneLocationLat, droneLocationLng)) {
                    droneMarker = aMap.addMarker(markerOptions);
                }
            }
        });
    }
 
Example #5
Source File: Waypoint1Activity.java    From Android-GSDemo-Gaode-Map with MIT License 6 votes vote down vote up
@Override
public void onMapClick(LatLng point) {
    if (isAdd == true){
        markWaypoint(point);
        Waypoint mWaypoint = new Waypoint(point.latitude, point.longitude, altitude);
        //Add Waypoints to Waypoint arraylist;
        if (waypointMissionBuilder != null) {
            waypointList.add(mWaypoint);
            waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
        }else
        {
            waypointMissionBuilder = new WaypointMission.Builder();
            waypointList.add(mWaypoint);
            waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
        }
    }else{
        setResultToToast("Cannot Add Waypoint");
    }
}
 
Example #6
Source File: ShareLocationActivity.java    From sealtalk-android with MIT License 6 votes vote down vote up
private void addMarker(LatLng latLng, String url) {
        AsyncImageView imageView = (AsyncImageView) LayoutInflater.from(this).inflate(R.layout.map_marker_view, null);
//        AsyncImageView imageView = (AsyncImageView) view.findViewById(R.id.icon);
        imageView.setResource(url,0);

//        aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f)
//                .position(new LatLng(30.679879, 104.064855)).title("成都市")
//                .snippet("成都市:30.679879, 104.064855").draggable(true));

        MarkerOptions markerOption = new MarkerOptions();
        markerOption.position(new LatLng(34.341568, 108.940174));
//        markerOption.title("西安市").snippet("西安市:34.341568, 108.940174");
//        markerOption.draggable(true);
//        markerOption.icon(BitmapDescriptorFactory.fromResource(R.drawable.rc_default_portrait));
        markerOption.icon(BitmapDescriptorFactory.fromView(imageView));
//        markerOption.icon(BitmapDescriptorFactory
//                .defaultMarker(BitmapDescriptorFactory.HUE_RED));


        Marker marker2 = aMap.addMarker(markerOption);
        // marker旋转90度
//        marker2.setRotateAngle(90);
    }
 
Example #7
Source File: LocationActivity.java    From Socket.io-FLSocketIM-Android with MIT License 6 votes vote down vote up
private void cameraMove(LatLng latLng) {

        userMoveCamera = false;
        CameraUpdateFactory factory = new CameraUpdateFactory();
        CameraUpdate cameraUpdate = factory.newLatLngZoom(latLng, (float) 15.5);
        aMap.animateCamera(cameraUpdate, new AMap.CancelableCallback() {
            @Override
            public void onFinish() {
                userMoveCamera = true;
            }

            @Override
            public void onCancel() {
                userMoveCamera = true;
            }
        });
    }
 
Example #8
Source File: AMAPLocationActivity.java    From sealtalk-android with MIT License 6 votes vote down vote up
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    if (aMapLocation != null && aMapLocation.getAMapException().getErrorCode() == 0) {
        if (listener != null) {
            listener.onLocationChanged(aMapLocation);// 显示系统小蓝点
        }
        myLocation = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude());//获取当前位置经纬度
        tvCurLocation.setText(aMapLocation.getRoad() + aMapLocation.getStreet() + aMapLocation.getPoiName());//当前位置信息

        double latitude = aMapLocation.getLatitude();
        double longitude = aMapLocation.getLongitude();
        mMsg = LocationMessage.obtain(latitude, longitude, aMapLocation.getRoad() + aMapLocation.getStreet() + aMapLocation.getPoiName(), getMapUrl(latitude, longitude));
        NLog.e("LocationInit", aMapLocation.getRoad() + aMapLocation.getStreet() + aMapLocation.getPoiName() + latitude + "----" + longitude);


        addChooseMarker();
    }
}
 
Example #9
Source File: MapSimFragment.java    From AndroidSDK with MIT License 5 votes vote down vote up
@Override
public void onMapClick(LatLng latLng) {
    mCorrectedLatLng = latLng;
    mRealLatLng = getRealLatLng(mCorrectedLatLng);
    mLocationTextView.setText("lon: " + latLng.longitude + "° / lat: " + latLng.latitude + "°");
    mAmap.clear();
    mAmap.addMarker(new MarkerOptions().position(latLng));
    mAmap.animateCamera(CameraUpdateFactory.changeLatLng(latLng));
}
 
Example #10
Source File: ShowScheduleImpel.java    From BetterWay with Apache License 2.0 5 votes vote down vote up
public void initData(ArrayList<NewPlan> newPlanList, int weatherSrore) {
    mNewPlanList = newPlanList;
    mLatLngList = new ArrayList<LatLng>();
    for (NewPlan newPlan : newPlanList) {
       if (newPlan.getLocation() != null) {
           LatLng latLng = new LatLng(newPlan.getLat(), newPlan.getLon());
           mLatLngList.add(latLng);
       }
    }
    if (weatherSrore == ShowScheduleActivity.NEW) {
        storePlansAndStoreSchedule(newPlanList);
    }
}
 
Example #11
Source File: FindMapAroundAty.java    From myapplication with Apache License 2.0 5 votes vote down vote up
private LatLngBounds getLatLngBounds() {
    LatLngBounds.Builder b = LatLngBounds.builder();
    for (int i = 0; i < mPois.size(); i++) {
        b.include(new LatLng(mPois.get(i).getLatLonPoint().getLatitude(),
                mPois.get(i).getLatLonPoint().getLongitude()));
    }
    return b.build();
}
 
Example #12
Source File: FindMapAroundAty.java    From myapplication with Apache License 2.0 5 votes vote down vote up
private MarkerOptions getMarkerOptions(int index) {
    return new MarkerOptions()
            .position(
                    new LatLng(mPois.get(index).getLatLonPoint()
                            .getLatitude(), mPois.get(index)
                            .getLatLonPoint().getLongitude()))
            .title(getTitle(index)).snippet(getSnippet(index))
            .icon(getBitmapDescriptor(index));
}
 
Example #13
Source File: ShareLocationActivity.java    From sealtalk-android with MIT License 5 votes vote down vote up
@Override
public void onMapLoaded() {
    // 设置所有maker显示在当前可视区域地图中
    LatLngBounds bounds = new LatLngBounds.Builder().include(new LatLng(34.341568, 108.940174)).build();

    aMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10));
}
 
Example #14
Source File: AMAPLocationActivity.java    From sealtalk-android with MIT License 5 votes vote down vote up
private void initAmap() {
    if (aMap == null) {
        aMap = mapView.getMap();
    }

    if (getIntent().hasExtra("location")) {
        isPerview = true;
        mMsg = getIntent().getParcelableExtra("location");
        tvCurLocation.setVisibility(View.GONE);
        returns.setVisibility(View.GONE);

        if (model) {
            CameraPosition location = new CameraPosition.Builder()
                    .target(new LatLng(mMsg.getLat(), mMsg.getLng())).zoom(18).bearing(0).tilt(30).build();
            show(location);
        } else {
            aMap.addMarker(new MarkerOptions().anchor(0.5f, 0.5f)
                    .position(new LatLng(mMsg.getLat(), mMsg.getLng())).title(mMsg.getPoi())
                    .snippet(mMsg.getLat() + "," + mMsg.getLng()).draggable(false));
        }
        return;
    }


    aMap.setLocationSource(this);// 设置定位监听
    aMap.setMyLocationEnabled(true);
    aMap.getUiSettings().setZoomControlsEnabled(false);
    aMap.getUiSettings().setMyLocationButtonEnabled(false);
    CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(15);//设置缩放监听
    aMap.moveCamera(cameraUpdate);

    successDescripter = BitmapDescriptorFactory.fromResource(R.drawable.icon_usecarnow_position_succeed);
    geocodeSearch = new GeocodeSearch(this);
    geocodeSearch.setOnGeocodeSearchListener(this);
}
 
Example #15
Source File: RealTimeLocationActivity.java    From sealtalk-android with MIT License 5 votes vote down vote up
public void onEventMainThread(final RongEvent.RealTimeLocationReceiveEvent event) {
    String userId = event.getUserId();
    UserInfo userInfo = getCacheUserInfoById(userId);
    if (userInfo != null) {
        moveMarker(new LatLng(event.getLatitude(), event.getLongitude()), userInfo);
    }
}
 
Example #16
Source File: AmapActivity.java    From sealtalk-android with MIT License 5 votes vote down vote up
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    if (aMapLocation != null && aMapLocation.getAMapException().getErrorCode() == 0) {
        if (listener != null) {
            listener.onLocationChanged(aMapLocation);// 显示系统小蓝点
        }
        myLocation = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude());
        tvCurLocation.setText(aMapLocation.getRoad() + aMapLocation.getStreet() + aMapLocation.getPoiName());
        addChooseMarker();
    }
}
 
Example #17
Source File: MapSimFragment.java    From AndroidSDK with MIT License 5 votes vote down vote up
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    mProgressDialog.dismiss();
    if (aMapLocation != null && aMapLocation.getErrorCode() == 0) {
        mCorrectedLatLng = new LatLng(aMapLocation.getLatitude(), aMapLocation.getLongitude());
        mRealLatLng = getRealLatLng(mCorrectedLatLng);
        mAmap.animateCamera(CameraUpdateFactory.zoomTo(17));
        mAmap.animateCamera(CameraUpdateFactory.changeLatLng(mCorrectedLatLng));
        mLocationTextView.setText("lon: " + aMapLocation.getLongitude() + "° / lat: " + aMapLocation.getLatitude() + "°");
        mAmap.clear();
        mAmap.addMarker(new MarkerOptions().position(mCorrectedLatLng));
    }
}
 
Example #18
Source File: Waypoint2Activity.java    From Android-GSDemo-Gaode-Map with MIT License 5 votes vote down vote up
private void cameraUpdate() {
    LatLng pos = new LatLng(mAircraftLat, mAircraftLng);
    float zoomlevel = (float) 18.0;
    CameraUpdate cu = CameraUpdateFactory.newLatLngZoom(pos, zoomlevel);
    aMap.moveCamera(cu);

}
 
Example #19
Source File: GCJ2WGS.java    From AndroidSDK with MIT License 5 votes vote down vote up
public static LatLng convert(LatLng latLng) {
    double a = 6378245.0;
    double ee = 0.00669342162296594323;
    double dLat = transformLat(latLng.longitude - 105.0, latLng.latitude - 35.0);
    double dLon = transformLon(latLng.longitude - 105.0, latLng.latitude - 35.0);
    double radLat = latLng.latitude / 180.0 * Math.PI;
    double magic = Math.sin(radLat);
    magic = 1 - ee * magic * magic;
    double sqrtMagic = Math.sqrt(magic);
    dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * Math.PI);
    dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * Math.PI);
    LatLng wgsLatLng = new LatLng(latLng.latitude - dLat, latLng.longitude - dLon);
    return wgsLatLng;
}
 
Example #20
Source File: Waypoint1Activity.java    From Android-GSDemo-Gaode-Map with MIT License 5 votes vote down vote up
private void initMapView() {

        if (aMap == null) {
            aMap = mapView.getMap();
            aMap.setOnMapClickListener(this);// add the listener for click for amap object
        }

        LatLng shenzhen = new LatLng(22.5362, 113.9454);
        aMap.addMarker(new MarkerOptions().position(shenzhen).title("Marker in Shenzhen"));
        aMap.moveCamera(CameraUpdateFactory.newLatLng(shenzhen));
    }
 
Example #21
Source File: Waypoint1Activity.java    From Android-GSDemo-Gaode-Map with MIT License 5 votes vote down vote up
private void markWaypoint(LatLng point){
    //Create MarkerOptions object
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(point);
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
    Marker marker = aMap.addMarker(markerOptions);
    mMarkers.put(mMarkers.size(), marker);
}
 
Example #22
Source File: Waypoint1Activity.java    From Android-GSDemo-Gaode-Map with MIT License 5 votes vote down vote up
private void cameraUpdate(){
    LatLng pos = new LatLng(droneLocationLat, droneLocationLng);
    float zoomlevel = (float) 18.0;
    CameraUpdate cu = CameraUpdateFactory.newLatLngZoom(pos, zoomlevel);
    aMap.moveCamera(cu);

}
 
Example #23
Source File: Waypoint2Activity.java    From Android-GSDemo-Gaode-Map with MIT License 5 votes vote down vote up
private void markWaypoint(LatLng point) {
    //Create MarkerOptions object
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(point);
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
    Marker marker = aMap.addMarker(markerOptions);
    mMarkers.put(mMarkers.size(), marker);
}
 
Example #24
Source File: AutoScheduleAssistFragment.java    From BetterWay with Apache License 2.0 5 votes vote down vote up
@Override
public void onGeocodeSearched(GeocodeResult geocodeResult, int i) {
    LogUtil.e(TAG, "onGeocodeSearched");
    GeocodeAddress geocodeAddress = geocodeResult.getGeocodeAddressList().get(0);
    LatLng latLng = new LatLng(geocodeAddress.getLatLonPoint().getLatitude(),
            geocodeAddress.getLatLonPoint().getLongitude());
    aMap.moveCamera(CameraUpdateFactory.changeLatLng(latLng));
}
 
Example #25
Source File: AMapLiteActivity.java    From XposedRimetHelper with GNU General Public License v2.0 5 votes vote down vote up
private List<LocationSearchSuggestions> searchResultData2SearchSuggestion(List<PoiItem> data) {
    List<LocationSearchSuggestions> result = new ArrayList<>();
    for (PoiItem datum : data) {
        result.add(new LocationSearchSuggestions(datum.getTitle(),
                datum.getCityName() + datum.getAdName() + datum.getSnippet(),
                new LatLng(datum.getLatLonPoint().getLatitude(),
                        datum.getLatLonPoint().getLongitude())));
    }
    return result;
}
 
Example #26
Source File: AMapLiteActivity.java    From XposedRimetHelper with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 添加标记 并移除旧的
 *
 * @param latLng
 * @return
 */
private void addMarker(LatLng latLng, String name) {
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_current_location));
    markerOptions.position(latLng);
    markerOptions.snippet(latLng.latitude + "," + latLng.longitude);
    markerOptions.title(TextUtils.isEmpty(name) ? "未知" : name);
    Marker marker = mAMap.addMarker(markerOptions);

    if (mChooseMarker != null) {
        mChooseMarker.remove();
    }
    mChooseMarker = marker;
}
 
Example #27
Source File: LocationActivity.java    From Socket.io-FLSocketIM-Android with MIT License 5 votes vote down vote up
@OnClick(R.id.map_relocated_btn)
void relocatedLocation() {

    Location location = aMap.getMyLocation();
    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    cameraMove(latLng);

    addLocationPinAnimation();
    searchLocationsName(latLng);
}
 
Example #28
Source File: AutoScheduleAssistFragment.java    From BetterWay with Apache License 2.0 5 votes vote down vote up
@Override
public void onMyLocationChange(Location location) {
    LogUtil.e(TAG, "onMyLocationChange");
    GeocodeSearch geocoderSearch = new GeocodeSearch(getContext());
    geocoderSearch.setOnGeocodeSearchListener(this);
    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    aMap.moveCamera(CameraUpdateFactory.changeLatLng(latLng));
    LatLonPoint latLonPoint = new LatLonPoint(location.getLatitude(), location.getLongitude());
    RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 10000, GeocodeSearch.AMAP);
    geocoderSearch.getFromLocationAsyn(query);
}
 
Example #29
Source File: AutoScheduleAssistFragment.java    From BetterWay with Apache License 2.0 5 votes vote down vote up
/**
 * 取得获得的坐标并移动地图到该坐标
 * @param latLonPoint 获得的坐标
 */
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
public void onLatLngPointEvent(LatLonPoint latLonPoint) {
    LogUtil.e(TAG, "moveToLatLngPoint()");
    mLatLng = new LatLng(latLonPoint.getLatitude(), latLonPoint.getLongitude());
    aMap.moveCamera(CameraUpdateFactory.changeLatLng(mLatLng));
}
 
Example #30
Source File: ListLocationPlan.java    From BetterWay with Apache License 2.0 5 votes vote down vote up
/**
 * 根据距离重新排序locationPlanList
 * @param locationPlanList 需要排序的List
 * @return 重新排序后的List
 */
private List<LocationPlan> sortLocationPlanList(List<LocationPlan> locationPlanList) {
    List<LocationPlan> locationPlans = new ArrayList<LocationPlan>();
    LocationPlan firstLocationPlan = locationPlanList.get(0);
    locationPlanList.remove(0);
    locationPlans.add(firstLocationPlan);
    LogUtil.d(TAG, firstLocationPlan.getLocation());
    int count = locationPlanList.size();
    for (int i = 0; i < count; i++) {
        LocationPlan locationPlan = locationPlans.get(locationPlans.size() - 1);
        LatLng mainLatLng = LatLngUtil.converLocationPlanToLatLng(locationPlan);
        float minDis = 0;
        int index = 0;
        for (int j = 0; j < locationPlanList.size(); j++) {
            LocationPlan compareLocationPlan = locationPlanList.get(j);
            LatLng compareLatLng = LatLngUtil.converLocationPlanToLatLng(compareLocationPlan);
            float distance = AMapUtils.calculateLineDistance(mainLatLng, compareLatLng);
            if (minDis == 0 || distance < minDis) {
                minDis = distance;
                index = j;
            }
        }
        LocationPlan newLocationPlan = locationPlanList.get(index);
        locationPlans.add(newLocationPlan);
        locationPlanList.remove(index);
    }
    locationPlanList = null;
    sortedList.addAll(locationPlans);
    return locationPlans;
}