@Override public void onResponse(int requestCode, String data) { dismissDialog(); try { String resultData = replaceSpecialtyStr(new String(data.getBytes("ISO-8859-1"), "GBK"), null, ""); if (requestCode == Constants.GET_CAR_BUSINESS) { JsonUtil<List<BusinessInfo>> jsonUtil = new JsonUtil<List<BusinessInfo>>(); RequestResult<List<BusinessInfo>> requestResult = jsonUtil.json2Obj( resultData, new TypeReference<RequestResult<List<BusinessInfo>>>() {}); if (requestResult != null) { switch (requestResult.getMsg().getResultCode()) { case 200: List<BusinessInfo> businessInfoList = requestResult.getData(); if (mapFragment == null) { mapFragment = (MapFragment) getSupportFragmentManager().findFragmentByTag(MAP_TAG); } mapFragment.addMarkersToMap(businessInfoList); mapFragment.addBusinessInfo(businessInfoList); break; case 400: T.showShort(this, new String(requestResult.getMsg().getMessage())); break; } } } L.d(resultData); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
// 显示或隐藏地图 private void showOrHiddenMap() { if (mapFragment == null) { mapFragment = (MapFragment) getSupportFragmentManager().findFragmentByTag(MAP_TAG); } if (!mapFragment.showOrHiddenMap()) { T.showShort(this, "地图尚未加载完成"); } }
/** 初始化Fragment */ private void initFragment() { // MapFragment map = new MapFragment(); Fragment map = MapFragment.newInstance(); getSupportFragmentManager() .beginTransaction() .replace(R.id.framelayout, map, MAP_TAG) .addToBackStack(null) .commit(); }
// 定位 private void startLocation() { if (mapFragment == null) { mapFragment = (MapFragment) getSupportFragmentManager().findFragmentByTag(MAP_TAG); } mapFragment.startLocation(); }