com.baidu.mapapi.search.core.PoiInfo Java Examples

The following examples show how to use com.baidu.mapapi.search.core.PoiInfo. 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: BaiduMapFragment.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
@Override
public void onGetBusLineResult(BusLineResult result) {
    hideProgress();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        onMessage("未找到路线");
    } else {
        clearMarker();
        BusLineOverlay overlay = new BusLineOverlay(mBaiduMap, PoiInfo.POITYPE.fromInt(mTypePoi.getInt()));
        mBaiduMap.setOnMarkerClickListener(overlay);
        overlay.setData(result);
        overlay.addToMap();
        overlay.zoomToSpan();


    }
}
 
Example #2
Source File: NaviConfirmPointActivity.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
/**
 * 将所有BaiduAddress对象信息填充到poi搜索信息集合中
 **/
public void setListReverse() {
    int al = aList.size();
    list.clear();
    int l = Math.min(al, 10);
    for (int i = 0; i < l; i++) {
        PoiInfo poiInfo = new PoiInfo();
        poiInfo.name = aList.get(i).getName();
        poiInfo.uid = aList.get(i).getUid();
        poiInfo.address = aList.get(i).getAddress();
        poiInfo.city = aList.get(i).getCity();
        poiInfo.phoneNum = aList.get(i).getPhoneNum();
        poiInfo.postCode = aList.get(i).getPostCode();
        poiInfo.type = PoiInfo.POITYPE.POINT;
        poiInfo.location = new LatLng(aList.get(i).getLatitude(), aList.get(i).getLongitude());
        list.add(poiInfo);
    }
}
 
Example #3
Source File: SetFavoriteMapActivity.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
/**
 * 将所有BaiduAddress对象信息填充到poi搜索信息集合中
 **/
public void setListReverse() {
    int al = aList.size();
    list.clear();
    int l = Math.min(al, 10);
    for (int i = 0; i < l; i++) {
        PoiInfo poiInfo = new PoiInfo();
        poiInfo.name = aList.get(i).getName();
        poiInfo.uid = aList.get(i).getUid();
        poiInfo.address = aList.get(i).getAddress();
        poiInfo.city = aList.get(i).getCity();
        poiInfo.phoneNum = aList.get(i).getPhoneNum();
        poiInfo.postCode = aList.get(i).getPostCode();
        poiInfo.type = PoiInfo.POITYPE.POINT;
        poiInfo.location = new LatLng(aList.get(i).getLatitude(), aList.get(i).getLongitude());
        list.add(poiInfo);
    }
}
 
Example #4
Source File: NaviConfirmPointActivity.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(NaviPointHolder holder, int position) {
    PoiInfo poiInfo = list.get(position);
    holder.mTpiNameText.setText((position + 1) + "." + poiInfo.name);
    holder.mTpiAddressText.setText(poiInfo.address);
    if (addMode) {
        holder.mTpiItemConfirmText.setText("添加");
        holder.mTpiDistanceText.setVisibility(View.GONE);
    } else {
        holder.mTpiItemConfirmText.setText("出发");
        holder.mTpiDistanceText.setVisibility(View.VISIBLE);
        double distance = DistanceUtil.getDistance(new LatLng(address.getLatitude(), address.getLongitude()),
                poiInfo.location) / 1000;
        holder.mTpiDistanceText.setText(String.format("%.1f", distance) + "km");
    }
    holder.mTpiTargetConfirmBt.setTag(position);
    holder.itemView.setTag(position);
}
 
Example #5
Source File: LocationActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    PoiInfo info = (PoiInfo) adapter.getItem(position);
    if (info == null) {
        return;
    }
    name = info.name;
    address = info.address;
    latitude = info.location.latitude;
    longitude = info.location.longitude;
    LatLng point = new LatLng(latitude, longitude);
    OverlayOptions options = new MarkerOptions().draggable(false)
            .position(point)
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.atom_ui_map_mark));
    if (overlay != null) {
        overlay.remove();
    }
    overlay = baiduMap.addOverlay(options);
    adapter.setCheckPosition(position);
    adapter.notifyDataSetChanged();
}
 
Example #6
Source File: LocationActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
public void onGetPoiResult(PoiResult poiResult) {
    if (getPoiResultCount<poiNum){
        getPoiResultCount++;
    }else {
        getPoiResultCount=1;
        receiveAll=true;
    }
    if (poiResult == null || poiResult.getAllPoi() == null) {
        return;
    }
    if (poiResult.getAllPoi().size() > 0) {
        List<PoiInfo> info = poiResult.getAllPoi();
        infoss.addAll(info);
        adapter.addPoiInfo(infoss);
        adapter.notifyDataSetChanged();
        infoss.clear();
        list.setSelection(firstVisible);
    }
    if (receiveAll){
        refresh = true;
        receiveAll=false;
    }else {
        refresh=false;
    }
}
 
Example #7
Source File: PoiItemAdapter.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder holder;
    if (convertView == null) {
        holder = new ViewHolder();
        convertView = View.inflate(context, R.layout.atom_ui_item_poi, null);
        convertView.setTag(holder);
        holder.address = (TextView) convertView.findViewById(R.id.address);
        holder.name = (TextView) convertView.findViewById(R.id.name);
        holder.checked = (TextView) convertView.findViewById(R.id.checked);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    PoiInfo info = (PoiInfo) getItem(position);
    holder.checked.setVisibility(position == this.checkPosition ? View.VISIBLE : View.GONE);
    holder.address.setText(info.address);
    holder.name.setText(info.name);
    return convertView;
}
 
Example #8
Source File: TrafficShowPresenter.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
public void setListReverse() {
    int al = aList.size();
    poiInfoList.clear();
    int l = Math.min(al, 10);
    for (int i = 0; i < l; i++) {
        PoiInfo poiInfo = new PoiInfo();
        poiInfo.name = aList.get(i).getName();
        poiInfo.uid = aList.get(i).getUid();
        poiInfo.address = aList.get(i).getAddress();
        poiInfo.city = aList.get(i).getCity();
        poiInfo.phoneNum = aList.get(i).getPhoneNum();
        poiInfo.postCode = aList.get(i).getPostCode();
        poiInfo.type = PoiInfo.POITYPE.POINT;
        poiInfo.location = new LatLng(aList.get(i).getLatitude(), aList.get(i).getLongitude());
        poiInfoList.add(poiInfo);
    }
}
 
Example #9
Source File: MapPickerActivity.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
    // 通知是适配器第position个item被选择了
    mAdapter.setNotifyTip(position);
    mAdapter.notifyDataSetChanged();
    BitmapDescriptor mSelectIco = BitmapDescriptorFactory
            .fromResource(R.drawable.picker_map_geo_icon);
    mBaiduMap.clear();
    PoiInfo info = (PoiInfo) mAdapter.getItem(position);
    LatLng la = info.location;
    // 动画跳转
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(la);
    mBaiduMap.animateMapStatus(u);
    // 添加覆盖物
    OverlayOptions ooA = new MarkerOptions().position(la)
            .icon(mSelectIco).anchor(0.5f, 0.5f);
    mBaiduMap.addOverlay(ooA);
    mLoactionLatLng = info.location;
    mAddress = info.address;
    mName = info.name;
    mCity = info.city;

    mLatitude = info.location.latitude;
    mLongitude = info.location.longitude;
    mStreet = info.name;//地图对应位置文字描述
}
 
Example #10
Source File: SearchAddressAdapter.java    From FastWaiMai with MIT License 6 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, PoiInfo item) {

    final ImageView ivPointImage = helper.getView(R.id.iv_point);
    final TextView tvName = helper.getView(R.id.tv_name);
    final TextView tvAddress = helper.getView(R.id.tv_address);
    final TextView tvDistance = helper.getView(R.id.tv_distance);
    LatLng latLng = item.getLocation();

    double distance = DistanceUtil.getDistance(currentLatLng, latLng);
    if(helper.getPosition() == 0){
        ivPointImage.setImageResource(R.drawable.point_orange);
        tvName.setTextColor(Latte.getApplication().getResources().getColor(R.color.orange));
    }else{
        ivPointImage.setImageResource(R.drawable.point_gray);
        tvName.setTextColor(Latte.getApplication().getResources().getColor(R.color.black));
    }
    tvName.setText(item.getName());
    tvAddress.setText(item.getAddress());
    tvDistance.setText(formatDistance(distance));
}
 
Example #11
Source File: PoiSearchAdapter.java    From MoveMapLocation with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.poisearch_item, null);
        holder = new ViewHolder(convertView);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    PoiInfo poiInfo = poiInfos.get(position);
    holder.poisearch_name.setText(poiInfo.name);
    holder.poisearch_address.setText(poiInfo.address);
    holder.poisearch_distance.setText((int)DistanceUtil.getDistance(locationLatLng, poiInfo.location)+"米");
    return convertView;
}
 
Example #12
Source File: BaiduMapFragment.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onGetBusLineResult(BusLineResult result) {
    hideProgress();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        onMessage("未找到路线");
    } else {
        clearMarker();
        BusLineOverlay overlay = new BusLineOverlay(mBaiduMap, PoiInfo.POITYPE.fromInt(mTypePoi.getInt()));
        mBaiduMap.setOnMarkerClickListener(overlay);
        overlay.setData(result);
        overlay.addToMap();
        overlay.zoomToSpan();


    }
}
 
Example #13
Source File: PoiAdapter.java    From MoveMapLocation with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if (convertView == null) {
        convertView = LayoutInflater.from(context).inflate(R.layout.locationpois_item, null);
        linearLayout = (LinearLayout) convertView.findViewById(R.id.locationpois_linearlayout);
        holder = new ViewHolder(convertView);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    if (position == 0 && linearLayout.getChildCount() < 2) {
        ImageView imageView = new ImageView(context);
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(32, 32);
        imageView.setLayoutParams(params);
        imageView.setBackgroundColor(Color.TRANSPARENT);
        imageView.setImageResource(R.mipmap.baidumap_ico_poi_on);
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        linearLayout.addView(imageView, 0, params);
        holder.locationpoi_name.setTextColor(Color.parseColor("#FF5722"));
    }
    PoiInfo poiInfo = pois.get(position);
    holder.locationpoi_name.setText(poiInfo.name);
    holder.locationpoi_address.setText(poiInfo.address);
    return convertView;
}
 
Example #14
Source File: MapPickerActivity.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        // 没有找到检索结果
        status.setText(R.string.picker_internalerror);
        status.setVisibility(View.VISIBLE);
    }
    // 获取反向地理编码结果
    else {
        status.setVisibility(View.GONE);
        // 当前位置信息
        mLoactionLatLng = result.getLocation();
        mAddress = result.getAddress();
        mName = result.getAddressDetail().street;
        mStreet = result.getAddressDetail().street;
        mCity = result.getAddressDetail().city;

        //滑动地图.中间位置坐标记录下来发送.相当于默认点击了一下listView中的第一条
        mLatitude = result.getLocation().latitude;
        mLongitude = result.getLocation().longitude;

        mCurentInfo = new PoiInfo();
        mCurentInfo.address = result.getAddress();
        mCurentInfo.location = result.getLocation();
        mCurentInfo.name = "[当前位置]";
        mInfoList.clear();
        mInfoList.add(mCurentInfo);
        // 将周边信息加入表
        if (result.getPoiList() != null) {
            mInfoList.addAll(result.getPoiList());
        }
        mAdapter.setNotifyTip(0);
        // 通知适配数据已改变
        mAdapter.notifyDataSetChanged();
        loading.setVisibility(View.GONE);

    }
}
 
Example #15
Source File: MapPickerActivity.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initMap() {
    //ricky init baidumap begin
    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
    mMapView.showZoomControls(false);
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(17.0f);
    mBaiduMap.setMapStatus(msu);
    mBaiduMap.setOnMapTouchListener(touchListener);
    // 初始化POI信息列表
    mInfoList = new ArrayList<PoiInfo>();
    // 初始化当前MapView中心屏幕坐标,初始化当前地理坐标
    mCenterPoint = mBaiduMap.getMapStatus().targetScreen;
    mLoactionLatLng = mBaiduMap.getMapStatus().target;
    // 定位
    mBaiduMap.setMyLocationEnabled(true);
    // 隐藏百度logo ZoomControl
    int count = mMapView.getChildCount();
    for (int i = 0; i < count; i++) {
        View child = mMapView.getChildAt(i);
        if (child instanceof ImageView || child instanceof ZoomControls) {
            child.setVisibility(View.INVISIBLE);
        }
    }
    // 隐藏比例尺
    //mMapView.showScaleControl(false);
    // 地理编码

    mGeoCoder = GeoCoder.newInstance();
    mGeoCoder.setOnGetGeoCodeResultListener(GeoListener);
    list = (ListView) findViewById(R.id.list);
    list.setOnItemClickListener(this);
    list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    loading = (ProgressBar) findViewById(R.id.loading);
    status = (TextView) findViewById(R.id.status);
    mAdapter = new MapPickerAdapter(MapPickerActivity.this, mInfoList);
    list.setAdapter(mAdapter);
}
 
Example #16
Source File: NaviSetPointPresenter.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * 将poi搜索信息填充到BaiduAddress对象中
 **/
private void setBaiduAddressFromPoiInfo(BaiduAddress ad, PoiInfo poiInfo) {
    ad.setAddress(poiInfo.address);
    ad.setUid(poiInfo.uid);
    ad.setName(poiInfo.name);
    ad.setCity(poiInfo.city);
    ad.setCreated(new Date(System.currentTimeMillis()));
    ad.setHasCaterDetails(poiInfo.hasCaterDetails ? 1 : 0);
    ad.setIsPano(poiInfo.isPano ? 1 : 0);
    ad.setLatitude(poiInfo.location.latitude);
    ad.setLongitude(poiInfo.location.longitude);
    ad.setPhoneNum(poiInfo.phoneNum);
    ad.setPostCode(poiInfo.postCode);
}
 
Example #17
Source File: SetFavoriteMapActivity.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(FavorPointHolder holder, int position) {
    PoiInfo poiInfo = list.get(position);
    BaiduAddress baiduAddress = aList.get(position);
    holder.mTpiNameText.setText(new StringBuilder().append(position + 1).append(".").append(poiInfo.name).toString());
    holder.mTpiAddressText.setText(poiInfo.address);

    holder.mTpiTargetConfirmBt.setTag(position);
    holder.itemView.setTag(position);
    switch (mode) {
        case SET_FAVORITE:
            holder.mTpiItemConfirmText.setText(baiduAddress.getFavoritedTime() == null ? "收藏" : "删除");
            // holder.mTpiItemConfirmText.setVisibility(View.GONE);
            //  holder.mTpiFavoriteStarBt.setVisibility(View.VISIBLE);
            break;
        case SET_HOME:
            holder.mTpiItemConfirmText.setText(baiduAddress.getRemark() == null || !baiduAddress.getRemark().equals("家") ? "设为家" : "清除");
            break;
        case SET_COMPANY:
            holder.mTpiItemConfirmText.setText(baiduAddress.getRemark() == null || !baiduAddress.getRemark().equals("单位") ? "设为单位" : "清除");
            break;
        case SET_START:
            holder.mTpiItemConfirmText.setText(baiduAddress.getRemark() == null || !baiduAddress.getRemark().equals("出发地") ? "设为出发地" : "清除");
            //  holder.mTpiItemConfirmText.setVisibility(View.GONE);
            //  holder.mTpiFavoriteStarBt.setVisibility(View.VISIBLE);
            break;
        case SET_END:
            holder.mTpiItemConfirmText.setText(baiduAddress.getRemark() == null || !baiduAddress.getRemark().equals("目的地") ? "设为目的地" : "清除");
            // holder.mTpiItemConfirmText.setVisibility(View.GONE);
            //  holder.mTpiFavoriteStarBt.setVisibility(View.VISIBLE);
            break;
    }
}
 
Example #18
Source File: TrafficShowPresenter.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
private void setBaiduAddressFromPoiInfo(BaiduAddress ad, PoiInfo poiInfo) {
    ad.setAddress(poiInfo.address);
    ad.setUid(poiInfo.uid);
    ad.setName(poiInfo.name);
    ad.setCity(poiInfo.city);
    ad.setCreated(new Timestamp(System.currentTimeMillis()));
    ad.setHasCaterDetails(poiInfo.hasCaterDetails ? 1 : 0);
    ad.setIsPano(poiInfo.isPano ? 1 : 0);
    ad.setLatitude(poiInfo.location.latitude);
    ad.setLongitude(poiInfo.location.longitude);
    ad.setPhoneNum(poiInfo.phoneNum);
    ad.setPostCode(poiInfo.postCode);
}
 
Example #19
Source File: GeolocationModule.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {
    WritableMap params = Arguments.createMap();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        params.putInt("errcode", -1);
    }
    else {
        ReverseGeoCodeResult.AddressComponent addressComponent = result.getAddressDetail();
        params.putString("address", result.getAddress());
        params.putString("province", addressComponent.province);
        params.putString("city", addressComponent.city);
        params.putString("district", addressComponent.district);
        params.putString("street", addressComponent.street);
        params.putString("streetNumber", addressComponent.streetNumber);

        WritableArray list = Arguments.createArray();
        List<PoiInfo> poiList = result.getPoiList();
        for (PoiInfo info: poiList) {
            WritableMap attr = Arguments.createMap();
            attr.putString("name", info.name);
            attr.putString("address", info.address);
            attr.putString("city", info.city);
            attr.putDouble("latitude", info.location.latitude);
            attr.putDouble("longitude", info.location.longitude);
            list.pushMap(attr);
        }
        params.putArray("poiList", list);
    }
    sendEvent("onGetReverseGeoCodeResult", params);
}
 
Example #20
Source File: TrafficShowPresenter.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * 进入设置导航路线页面
 **/
private void intoNaviSetLine(int index, PoiInfo info) {
    if (voiceMode) {
        if (SynthesizerBase.isInited()) {
            SynthesizerBase.get().stopSpeakingAbsolte();
        }
        Intent is = new Intent(mContext, AssistantService.class);
        is.putExtra(AssistantService.CMD, AssistantService.ServiceCmd.STOP_RECOGNIZE);
        mContext.startService(is);
        is.putExtra(AssistantService.CMD, AssistantService.ServiceCmd.PUSH_ROUTE_CACULATE);
        is.putExtra("text", "第" + (index + 1) + "个");
        is.putExtra(AssistantService.CALLBACK, true);
        mContext.startService(is);
    } else {
        //没有网络进行提示
        if (NetUtil.getInstance(mContext).getCurrentNetType().equals(NetUtil.NetType.NETWORK_TYPE_NONE)) {
            final CommonDialog commonDialog = new CommonDialog(mContext, "网络错误", "网络状态不佳,请检查网络设置", "确定");
            commonDialog.setOnConfirmListener(new CommonDialog.OnConfirmListener() {
                @Override
                public void onConfirm() {
                    commonDialog.cancel();
                }
            }).show();
            return;
        }
        Intent intent = new Intent(mContext, NaviSetLineActivity.class);
        intent.putExtra("latitude", info.location.latitude);
        intent.putExtra("longitude", info.location.longitude);
        intent.putExtra("address", info.name);
        mContext.startActivity(intent);

    }
}
 
Example #21
Source File: BusActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
/**
 * 以下是执行searchButtonProcess开始按钮后,返回的POI数据。
 * 
 */
@Override
public void onGetPoiResult(PoiResult result) {

	if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
		Toast.makeText(context, "抱歉,未找到结果", Toast.LENGTH_LONG).show();
		return;
	}
	// 遍历所有poi,找到类型为公交线路的poi
	busLineIDList.clear();

	/**
	 * 
	 * 一般以下for循环执行2次,因为同一条公交线路有正反2个方向;
	 */
	for (PoiInfo poi : result.getAllPoi()) {
		if (poi.type == PoiInfo.POITYPE.BUS_LINE
				|| poi.type == PoiInfo.POITYPE.SUBWAY_LINE) {
			busLineIDList.add(poi.uid);// 就把该poi信息存储到公交路线列表中;busLineIDList中存储的是公交线路的ID值;
			Log.i("TAG", "城市:" + poi.city + ";线路:" + poi.name);
			city_return = poi.city;
		}
	}
	// 即要把原来所有的数据清空;
	SearchNextBusline(null);
	route = null;
}
 
Example #22
Source File: TrafficShowPresenter.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(NaviPointHolder holder, int position) {
    PoiInfo poiInfo = poiInfoList.get(position);
    holder.mTpiNameText.setText((position + 1) + "." + poiInfo.name);
    holder.mTpiAddressText.setText(poiInfo.address);

    holder.mTpiItemConfirmText.setText("出发");
    holder.mTpiDistanceText.setVisibility(View.VISIBLE);
    double distance = DistanceUtil.getDistance(new LatLng(address.getLatitude(), address.getLongitude()),
            poiInfo.location) / 1000;
    holder.mTpiDistanceText.setText(String.format("%.1f", distance) + "km");

    holder.mTpiTargetConfirmBt.setTag(position);
    holder.itemView.setTag(position);
}
 
Example #23
Source File: MainActivity.java    From MoveMapLocation with Apache License 2.0 5 votes vote down vote up
/**
 * 输入框监听---输入完毕
 *
 * @param s
 */
@Override
public void afterTextChanged(Editable s) {
    if (s.length() == 0 || "".equals(s.toString())) {
        searchPois.setVisibility(View.GONE);
    } else {
        //创建PoiSearch实例
        PoiSearch poiSearch = PoiSearch.newInstance();
        //城市内检索
        PoiCitySearchOption poiCitySearchOption = new PoiCitySearchOption();
        //关键字
        poiCitySearchOption.keyword(s.toString());
        //城市
        poiCitySearchOption.city(city);
        //设置每页容量,默认为每页10条
        poiCitySearchOption.pageCapacity(10);
        //分页编号
        poiCitySearchOption.pageNum(1);
        poiSearch.searchInCity(poiCitySearchOption);
        //设置poi检索监听者
        poiSearch.setOnGetPoiSearchResultListener(new OnGetPoiSearchResultListener() {
            //poi 查询结果回调
            @Override
            public void onGetPoiResult(PoiResult poiResult) {
                List<PoiInfo> poiInfos = poiResult.getAllPoi();
                PoiSearchAdapter poiSearchAdapter = new PoiSearchAdapter(MainActivity.this, poiInfos, locationLatLng);
                searchPois.setVisibility(View.VISIBLE);
                searchPois.setAdapter(poiSearchAdapter);
            }

            //poi 详情查询结果回调
            @Override
            public void onGetPoiDetailResult(PoiDetailResult poiDetailResult) {
            }
        });
    }
}
 
Example #24
Source File: NaviConfirmPointActivity.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * 进入设置导航路线页面
 **/
private void intoNaviSetLine(int index, PoiInfo info) {
    if (voiceMode) {
        if (SynthesizerBase.isInited()) {
            SynthesizerBase.get().stopSpeakingAbsolte();
        }
        Intent is = new Intent(NaviConfirmPointActivity.this, AssistantService.class);
        is.putExtra(AssistantService.CMD, AssistantService.ServiceCmd.STOP_RECOGNIZE);
        startService(is);
        is.putExtra(AssistantService.CMD, AssistantService.ServiceCmd.PUSH_ROUTE_CACULATE);
        is.putExtra("text", "第" + (index + 1) + "个");
        is.putExtra(AssistantService.CALLBACK, true);
        startService(is);
    } else {
        if(NetUtil.getInstance(NaviConfirmPointActivity.this).getCurrentNetType().equals(NetUtil.NetType.NETWORK_TYPE_NONE)){
            final CommonDialog commonDialog =  new CommonDialog(NaviConfirmPointActivity.this,"网络错误","网络状态不佳,请检查网络设置","确定");
            commonDialog.setOnConfirmListener(new CommonDialog.OnConfirmListener() {
                @Override
                public void onConfirm() {
                    commonDialog.cancel();
                }
            }).show();
            return;
        }
        Intent intent = new Intent(NaviConfirmPointActivity.this, NaviSetLineActivity.class);
        intent.putExtra("latitude", info.location.latitude);
        intent.putExtra("longitude", info.location.longitude);
        intent.putExtra("address", info.name);
        startActivity(intent);
        goInto();
    }
    finish();
}
 
Example #25
Source File: NaviConfirmPointActivity.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * 重置搜索地址集合
 *
 * @param list
 **/
private void setAlist(List<PoiInfo> list) {
    aList.clear();
    for (PoiInfo poiInfo : list) {
        BaiduAddress address = new BaiduAddress();
        setBaiduAddressFromPoiInfo(address, poiInfo);
        aList.add(address);
    }
}
 
Example #26
Source File: BusLineOverlay.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
public BitmapDescriptor getStationMarker() {
    if (type == PoiInfo.POITYPE.SUBWAY_LINE){
        return BitmapDescriptorFactory.fromAssetWithDpi("icon_subway_station.png");
    }else {
        return BitmapDescriptorFactory.fromAssetWithDpi("icon_bus_station.png");
    }
}
 
Example #27
Source File: SetFavoriteMapActivity.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * 重置搜索地址集合
 *
 * @param list
 **/
private void setAlist(List<PoiInfo> list) {
    aList.clear();
    for (PoiInfo poiInfo : list) {
        if (poiInfo.location == null)
            continue;
        BaiduAddress address = new BaiduAddress();
        setBaiduAddressFromPoiInfo(address, poiInfo);
        aList.add(address);
    }
}
 
Example #28
Source File: SetFavoriteMapActivity.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * 将poi搜索信息填充到BaiduAddress对象中
 **/
private void setBaiduAddressFromPoiInfo(BaiduAddress ad, PoiInfo poiInfo) {
    ad.setAddress(poiInfo.address);
    ad.setUid(poiInfo.uid);
    ad.setName(poiInfo.name);
    ad.setCity(poiInfo.city);
    ad.setCreated(new Date(System.currentTimeMillis()));
    ad.setHasCaterDetails(poiInfo.hasCaterDetails ? 1 : 0);
    ad.setIsPano(poiInfo.isPano ? 1 : 0);
    ad.setLatitude(poiInfo.location.latitude);
    ad.setLongitude(poiInfo.location.longitude);
    ad.setPhoneNum(poiInfo.phoneNum);
    ad.setPostCode(poiInfo.postCode);
}
 
Example #29
Source File: LocationActivity.java    From imsdk-android with MIT License 5 votes vote down vote up
private void searchNearByPoi(PoiInfo info, String keyword,int pageNum) {
    PoiNearbySearchOption option = new PoiNearbySearchOption();
    option.keyword(keyword).
            radius(1000).pageNum(pageNum).pageCapacity(5).
            sortType(PoiSortType.distance_from_near_to_far).
            location(new LatLng(info.location.latitude, info.location.longitude));
    poiSearch.searchNearby(option);
}
 
Example #30
Source File: BusLineOverlay.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
public BitmapDescriptor getStationMarker() {
    if (type == PoiInfo.POITYPE.SUBWAY_LINE){
        return BitmapDescriptorFactory.fromAssetWithDpi("icon_subway_station.png");
    }else {
        return BitmapDescriptorFactory.fromAssetWithDpi("icon_bus_station.png");
    }
}