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


Java LatLng类代码示例

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


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

示例1: onLocationChanged

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
    if (mListener != null && aMapLocation != null) {
        if (aMapLocation != null && aMapLocation.getErrorCode() == 0) {
            mAMapLocation = aMapLocation;
            mlocationClient.stopLocation();
            mListener.onLocationChanged(aMapLocation);// 显示系统小蓝点
            lp = new LatLonPoint(aMapLocation.getLatitude(), aMapLocation.getLongitude());
            mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lp.getLatitude(), lp.getLongitude()), 17));
            doSearchQuery(aMapLocation.getPoiName().trim(), aMapLocation.getCityCode(), false);
        } else {
            String errText = "定位失败," + aMapLocation.getErrorCode() + ": " + aMapLocation.getErrorInfo();
            ToastUtils.showToast(this, errText);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:PoiAroundSearchActivity.java

示例2: onCameraChangeFinish

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
@Override
public void onCameraChangeFinish(CameraPosition cameraPosition) {
    LatLng target = cameraPosition.target;
    lp = new LatLonPoint(target.latitude, target.longitude);
    GeocodeSearch geocoderSearch = new GeocodeSearch(this);
    geocoderSearch.setOnGeocodeSearchListener(new GeocodeSearch.OnGeocodeSearchListener() {
        @Override
        public void onRegeocodeSearched(RegeocodeResult result, int rCode) {
            if (rCode == AMapException.CODE_AMAP_SUCCESS) {
                if (result != null && result.getRegeocodeAddress() != null
                        && result.getRegeocodeAddress().getPois() != null) {
                    listviewAdapter.setData(result.getRegeocodeAddress().getPois());
                }
            } else {
                ToastUtils.showToast(mContext, String.valueOf(rCode));
            }
        }

        @Override
        public void onGeocodeSearched(GeocodeResult geocodeResult, int i) {

        }
    });
    RegeocodeQuery query = new RegeocodeQuery(lp, 200, GeocodeSearch.AMAP);
    geocoderSearch.getFromLocationAsyn(query);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:PoiAroundSearchActivity.java

示例3: onLocationChanged

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
/**
     * 实现定位
     * @param amapLocation
     */
    @Override
    public void onLocationChanged(AMapLocation amapLocation) {
        if (mListener != null && amapLocation != null) {
            if (amapLocation != null
                    &&amapLocation.getErrorCode() == 0) {

                if(isFirstTime){//只要第一次的数据,当然,也可以在这里关闭定位
//                    mlocationClient.stopLocation();//停止定位
                    mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
                    lvHolder.title = "[位置]";
                    lvHolder.address = amapLocation.getProvider()+amapLocation.getCity()+amapLocation.getStreet()+amapLocation.getStreetNum();
                    lvHolder.lp = new LatLonPoint(amapLocation.getLatitude(),amapLocation.getLongitude());
                    mEndMarker.setPosition(new LatLng(amapLocation.getLatitude(),amapLocation.getLongitude()));
                    data.add(0,lvHolder);
                    doSearchQuery();

                }

            } else {
                String errText = "定位失败," + amapLocation.getErrorCode()+ ": " + amapLocation.getErrorInfo();
                Log.e("AmapErr",errText);
            }
        }
    }
 
开发者ID:Vicent9920,项目名称:MyMap,代码行数:29,代码来源:PiclocationActivity.java

示例4: onMapClick

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
/**
 * 点击map,隐藏/显示Map上的元素
 * @param latLng
 */
@Override
public void onMapClick(LatLng latLng) {
    SearchView search_view = (SearchView) ((Activity)mContext).findViewById(R.id.search_view);
    MapToolsView map_tool = (MapToolsView) ((Activity)mContext).findViewById(R.id.map_tool);

    DisplayMetrics metrics = new DisplayMetrics();
    ((Activity)mContext).getWindowManager().getDefaultDisplay().getMetrics(metrics);

    if (mIsMapElementsShow) {
        mIsMapElementsShow = false;
        search_view.animate().translationY((search_view.getHeight() + dp2px(mContext, 6)) * (-1)).setInterpolator(new DecelerateInterpolator());
        map_tool.animate().translationY(map_tool.getHeight() + dp2px(mContext, 6)).setInterpolator(new DecelerateInterpolator());
    } else {
        mIsMapElementsShow = true;
        search_view.animate().translationY(0).setInterpolator(new DecelerateInterpolator());
        map_tool.animate().translationY(0).setInterpolator(new DecelerateInterpolator());
    }
}
 
开发者ID:sherlockchou86,项目名称:yphoto,代码行数:23,代码来源:MapFragment.java

示例5: onPageSelected

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
@Override
public void onPageSelected(int position) {
    final Map<String, Object> record = mPhotos.get(position);
    if(record != null) {
        TextView counter = (TextView) findViewById(R.id.counter);
        counter.setText((position + 1)  + "/" + mPhotos.size());

        MapFragmentSimple map = (MapFragmentSimple) ((Activity)mContext).getFragmentManager().findFragmentById(R.id.map_simple_fragment);
        map.updateLoc((LatLng) record.get("loc"));  // update the map center

        final TextView loc_str = (TextView) findViewById(R.id.loc_str);
        loc_str.setText(record.get("loc_str").toString());

        final CircleImageView avatar = (CircleImageView) findViewById(R.id.author_avatar);
        avatar.setImageResource((int)record.get("avatar"));
    }
}
 
开发者ID:sherlockchou86,项目名称:yphoto,代码行数:18,代码来源:PhotoSwitchView.java

示例6: init

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
private void init(AMap aMap, LatLng loc) {
    this.aMap = aMap;
    ac = aMap.addCircle(new CircleOptions().center(loc)
            .fillColor(Color.argb(155, 255, 218, 185))
            .radius(acr * aMap.getScalePerPixel()).strokeColor(Color.argb(255, 255, 228, 185))
            .strokeWidth(5));

    c = aMap.addCircle(new CircleOptions().center(loc)
            .fillColor(Color.WHITE).radius(cr * aMap.getScalePerPixel())
            .strokeColor(Color.argb(255, 255, 228, 185)).strokeWidth(0));

    circle = aMap.addCircle(new CircleOptions().center(loc)
            .fillColor(Color.argb(155, 2, 155, 252))
            .radius(circle_r * aMap.getScalePerPixel()).strokeColor(Color.argb(255, 255, 228, 185))
            .strokeWidth(0));

    start = SystemClock.uptimeMillis();
    mTimer.schedule(this, 0, 30);
}
 
开发者ID:sherlockchou86,项目名称:yphoto,代码行数:20,代码来源:CircleTask.java

示例7: onCreateView

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View sView = inflater.inflate(R.layout.fragment_map_simple, container, false);

    mMapView = (MapView) sView.findViewById(R.id.map_simple);
    mMapView.onCreate(savedInstanceState);

    AMap map = mMapView.getMap();
    map.setMapType(AMap.MAP_TYPE_NIGHT);
    map.getUiSettings().setZoomControlsEnabled(false);
    map.getUiSettings().setAllGesturesEnabled(false);

    LatLng loc = new LatLng(39.9793157, 116.3107618);
    CameraUpdate mCameraUpdate = CameraUpdateFactory.newCameraPosition(new CameraPosition(loc,14 ,0,0));
    map.animateCamera(mCameraUpdate, 1000, null);

    if(mCircleTask == null) {
        mCircleTask = new CircleTask(map, loc, 15, 20, 40);
    }

    return sView;
}
 
开发者ID:sherlockchou86,项目名称:yphoto,代码行数:25,代码来源:MapFragmentSimple.java

示例8: accept

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
@Override
public boolean accept(AMapLocation previous, AMapLocation current) {
    if(previous == null){
        return true;
    }
    LatLng pre = new LatLng(previous.getLatitude(), previous.getLongitude());
    LatLng cur = new LatLng(current.getLatitude(), current.getLongitude());
    float distance = AMapUtils.calculateLineDistance(pre, cur);
    if(distance < RMConfiguration.DRAW_DISTANCE){
        return false;
    }
    float speed = current.getSpeed();
    double interval = (SystemClock.elapsedRealtime() - mPreviousUpdateTime)/1000.0;
    float v = (float) (distance/interval);
    if(v > RMConfiguration.MAX_SPEED || v > speed * 1.5){
        return false;
    }
    mPreviousUpdateTime = SystemClock.elapsedRealtime();
    return true;
}
 
开发者ID:stdnull,项目名称:RunMap,代码行数:21,代码来源:SpeedAndDistanceFilter.java

示例9: addRailwayMarkers

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
private void addRailwayMarkers(RouteRailwayItem railway) {
    LatLng Departureposition = AMapUtil.convertToLatLng(railway
            .getDeparturestop().getLocation());
    String Departuretitle = railway.getDeparturestop().getName()+"上车";
    String Departuresnippet = railway.getName();

    addStationMarker(new MarkerOptions().position(Departureposition).title(Departuretitle)
            .snippet(Departuresnippet).anchor(0.5f, 0.5f).visible(nodeIconVisible)
            .icon(getBusBitmapDescriptor()));


    LatLng Arrivalposition = AMapUtil.convertToLatLng(railway
            .getArrivalstop().getLocation());
    String Arrivaltitle = railway.getArrivalstop().getName()+"下车";
    String Arrivalsnippet = railway.getName();

    addStationMarker(new MarkerOptions().position(Arrivalposition).title(Arrivaltitle)
            .snippet(Arrivalsnippet).anchor(0.5f, 0.5f).visible(nodeIconVisible)
            .icon(getBusBitmapDescriptor()));
}
 
开发者ID:yimiaoxiehou,项目名称:ZhuHaiBusApplication,代码行数:21,代码来源:BusRouteOverlay.java

示例10: prepareAnimation

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
private void prepareAnimation(final List<List<LatLng>> drawSource){
    mapInstance.clear();
    this.mDrawSource = drawSource;
    mSegmentIndex = 0;
    if(isFirstAnimation) {
        isFirstAnimation = false;
        TaskHanler.getInstance().sendTaskDelayed(new Runnable() {
            @Override
            public void run() {
                mapInstance.moveToSpecficCamera(CameraUpdateFactory.newCameraPosition(
                        new CameraPosition(drawSource.get(mSegmentIndex).get(0), 16, 0, 0)));
            }
        }, 1000);
    }
    else {
        mapInstance.moveToSpecficCamera(CameraUpdateFactory.newCameraPosition(
                new CameraPosition(drawSource.get(mSegmentIndex).get(0), 16, 0, 0)));
    }

    mapInstance.drawTrackAnimation(drawSource.get(mSegmentIndex), mSegmentIndex, new TrackLineMoveListener());
}
 
开发者ID:stdnull,项目名称:RunMap,代码行数:22,代码来源:ReviewPresenterImpl.java

示例11: getAngle

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
/**
 * 根据两点算取图标转的角度
 */
private double getAngle(LatLng fromPoint, LatLng toPoint) {
	double slope = getSlope(fromPoint, toPoint);
	if (slope == Double.MAX_VALUE) {
		if (toPoint.latitude > fromPoint.latitude) {
			return 0;
		} else {
			return 180;
		}
	}
	float deltAngle = 0;
	if ((toPoint.latitude - fromPoint.latitude) * slope < 0) {
		deltAngle = 180;
	}
	double radio = Math.atan(slope);
	double angle = 180 * (radio / Math.PI) + deltAngle - 90;
	return angle;
}
 
开发者ID:KellenHu,项目名称:Amap-Move-Example,代码行数:21,代码来源:MainActivity.java

示例12: GetDistance

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
/**
     * 求两点经纬度之间的距离
     * @param startLatLng
     * @param endLatLng
     * @return
     */
    public double GetDistance(LatLng startLatLng,LatLng endLatLng)
    {

        double lat1 = startLatLng.latitude;
        double lng1 = startLatLng.longitude;

        double lat2 = endLatLng.latitude;
        double lng2 = endLatLng.longitude;

        double radLat1 = rad(lat1);
        double radLat2 = rad(lat2);
        double a = radLat1 - radLat2;
        double b = rad(lng1) - rad(lng2);

        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
                Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
        s = s * EARTH_RADIUS;
//        s = Math.round(s * 10000) / 10000;
//        double s = Math.sqrt((lat1 - lat2) * (lat1 - lat2) - (lng1 - lng2) * (lng1 - lng2));
        return s;
    }
 
开发者ID:KellenHu,项目名称:Amap-Move-Example,代码行数:28,代码来源:MainActivity.java

示例13: SetEdgeBar

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
public void SetEdgeBar(){
       Log.d(TAG, "onCreate: Now Create");
       findViewById(R.id.MainActivity_search_box).clearFocus();
       aMap.setOnMapClickListener(new AMap.OnMapClickListener() {
           @Override
           public void onMapClick(LatLng latLng) {
               if(routePlanLayout == null || routePlanLayout.getVisibility() == View.GONE){
                   POILatlng =latLng;
                   SearchPOI(latLng);
               }
/*               if(!isGetPOI){
                   if(top_view.getVisibility() == View.VISIBLE) top_view.setVisibility(View.INVISIBLE); else top_view.setVisibility(View.VISIBLE);
               }*/

           }
       });
   }
 
开发者ID:BoldFei,项目名称:Zmap_test,代码行数:18,代码来源:MainActivity.java

示例14: SearchPOI

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
public void SearchPOI(LatLng latLng){

        PoiSearch.Query query = new PoiSearch.Query("郑州","","");
        query.setPageSize(1);// 设置每页最多返回多少条poiitem
        query.setPageNum(1);//设置查询页码
        PoiSearch poiSearch = new PoiSearch(this, query);

        List<LatLonPoint> points =new ArrayList<LatLonPoint>();
        points.add(new LatLonPoint(latLng.latitude+0.0001,latLng.longitude+0.0001));
        points.add(new LatLonPoint(latLng.latitude-0.0001,latLng.longitude-0.0001));
        points.add(new LatLonPoint(latLng.latitude-0.0001,latLng.longitude+0.0001));
        points.add(new LatLonPoint(latLng.latitude+0.0001,latLng.longitude-0.0001));
        poiSearch.setBound(new PoiSearch.SearchBound(points));//设置多边形区域
        poiSearch.setOnPoiSearchListener(this);
        poiSearch.searchPOIAsyn();
    }
 
开发者ID:BoldFei,项目名称:Zmap_test,代码行数:17,代码来源:MainActivity.java

示例15: onBackPressed

import com.amap.api.maps.model.LatLng; //导入依赖的package包/类
/**
 * 如果搜索列表可见-》隐藏
 * 否则销毁活动,返回数据
 */
@Override
public void onBackPressed() {
    if(searchResultListView != null && searchResultListView.getVisibility() == View.VISIBLE){
        searchResultListView.setVisibility(View.GONE);
        typeButtonHistoryView.setVisibility(View.VISIBLE);
        editText.setText("");
        if(nothingTextView != null && nothingTextView.getVisibility() == View.VISIBLE) nothingTextView.setVisibility(View.GONE);
        getAndShowSearchHistoryRecord();
    }
    else {   //销毁活动
        Intent intent = new Intent();
        intent.putExtra("poiData", new SearchResultItem(new LatLng(0.0, 0.0), "NONE"));
        setResult(RESULT_OK, intent);
        finish();
    }
}
 
开发者ID:BoldFei,项目名称:Zmap_test,代码行数:21,代码来源:SearchPageActivity.java


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