@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(EUExUtil.getResLayoutID("plugin_uexgaodemap_basic_layout"));
    /*
     * 设置离线地图存储目录,在下载离线地图或初始化地图设置;
     * 使用过程中可自行设置, 若自行设置了离线地图存储的路径,
     * 则需要在离线地图下载和使用地图页面都进行路径设置
     * */
    // Demo中为了其他界面可以使用下载的离线地图,使用默认位置存储,屏蔽了自定义设置
    //  MapsInitializer.sdcardDir =OffLineMapUtils.getSdCacheDir(this);
    Intent intent = getIntent();
    mListener = (OnCallBackListener) intent.getSerializableExtra("callback");

    mContent = (FrameLayout) findViewById(EUExUtil.getResIdID("plugin_uexgaodemap_bg_content"));
    mButtons = new HashMap<String, CustomButtonBean>();
    mapView = (MapView) findViewById(EUExUtil.getResIdID("plugin_uexgaodemap_basic_map"));
    mapView.onCreate(savedInstanceState); // 此方法必须重写
    init();
    aMap.setOnMapLoadedListener(this);
    aMap.setOnMapClickListener(this);
    aMap.setOnMapLongClickListener(this);
    mCenter = intent.getDoubleArrayExtra(JsConst.LATLNG);
    markerMgr = new GaodeMapMarkerMgr(this, aMap, mListener, mOverlays);
    overlayMgr = new GaodeMapOverlayMgr(this, aMap, mListener, mOverlays);
    aMap.setOnMarkerClickListener(markerMgr);
    aMap.setOnInfoWindowClickListener(markerMgr);
  }
Example #2
0
  private void setUpMap() {
    aMap.setLocationSource(this);
    aMap.setOnMarkerClickListener(this);
    aMap.setOnInfoWindowClickListener(this);
    aMap.getUiSettings().setMyLocationButtonEnabled(true);
    aMap.setMyLocationEnabled(true);

    aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
  }
  /** 设置地图 */
  private void setUpMap() {
    mMap.setOnMarkerClickListener(this); // 设置点击marker事件监听器
    mMap.setInfoWindowAdapter(this);
    mMap.setOnInfoWindowClickListener(this); // 设置点击infoWindow事件监听器
    mMap.setOnMapLoadedListener(this); // 设置map载入成功事件监听器
    mMap.setOnCameraChangeListener(this);
    routeSearch = new RouteSearch(getActivity());
    routeSearch.setRouteSearchListener(this);
    setLocation();
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(position_schoolLatLngs[0], 17.904732f));
    startTextView =
        (AutoCompleteTextView) schoolView.findViewById(R.id.autotextview_roadsearch_start);
    startTextView.setFocusable(false);
    endTextView =
        (AutoCompleteTextView) schoolView.findViewById(R.id.autotextview_roadsearch_goals);
    endTextView.setFocusable(false);
    routeSearchImagebtn = (ImageButton) schoolView.findViewById(R.id.imagebtn_roadsearch_search);
    routeSearchImagebtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            strStart = startTextView.getText().toString().trim();
            strEnd = endTextView.getText().toString().trim();
            if (strStart == null || strStart.length() == 0) {
              Toast.makeText(getActivity(), "请选择起点", Toast.LENGTH_SHORT).show();
              return;
            }
            if (strEnd == null || strEnd.length() == 0) {
              Toast.makeText(getActivity(), "请选择终点", Toast.LENGTH_SHORT).show();
              return;
            }
            if (startPoint != null && endPoint != null) {
              if (NetworkUtils.isConnect(getActivity())) {
                progDialog = ProgressDialog.show(getActivity(), null, "正在搜索", true, true);
                searchRoute();
              } else {
                Toast.makeText(getActivity(), "亲,请检查网络连接", Toast.LENGTH_SHORT).show();
              }

              // searchRouteResult(startPoint, endPoint);
            }
          }
        });
  }