Ejemplo n.º 1
0
  @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);
  }
Ejemplo n.º 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() {
   Button searButton = (Button) findViewById(R.id.searchButton);
   searButton.setOnClickListener(this);
   Button nextButton = (Button) findViewById(R.id.nextButton);
   nextButton.setOnClickListener(this);
   searchText = (AutoCompleteTextView) findViewById(R.id.keyWord);
   searchText.addTextChangedListener(this); // 添加文本输入框监听事件
   editCity = (EditText) findViewById(R.id.city);
   aMap.setOnMarkerClickListener(this); // 添加点击marker监听事件
   aMap.setInfoWindowAdapter(this); // 添加显示infowindow监听事件
 }
  /** 设置地图 */
  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);
            }
          }
        });
  }
Ejemplo n.º 5
0
  private void setUpMap() {
    aMap.setOnMarkerClickListener(this);
    aMap.setOnCameraChangeListener(this);

    // 自定义系统定位蓝点
    MyLocationStyle myLocationStyle = new MyLocationStyle();

    // 设置定位图标围栏为透明
    myLocationStyle.radiusFillColor(color.transparent);

    // 自定义定位蓝点图标
    myLocationStyle.myLocationIcon(
        BitmapDescriptorFactory.fromResource(R.drawable.md_switch_thumb_on_pressed));

    // 自定义精度范围的圆形边框颜色
    myLocationStyle.strokeColor(Color.TRANSPARENT);

    // 自定义精度范围的圆形边框宽度
    myLocationStyle.strokeWidth(0);

    // 将自定义的 myLocationStyle 对象添加到地图上
    aMap.setMyLocationStyle(myLocationStyle);

    // 设置定位监听
    aMap.setLocationSource(this);

    // 设置默认定位按钮是否显示
    aMap.getUiSettings().setMyLocationButtonEnabled(true);
    aMap.getUiSettings().setZoomControlsEnabled(false);
    aMap.getUiSettings().setMyLocationButtonEnabled(false);

    // 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
    aMap.setMyLocationEnabled(true);

    // 设置定位的类型为定位模式:定位(AMap.LOCATION_TYPE_LOCATE)、跟随(AMap.LOCATION_TYPE_MAP_FOLLOW)
    // 地图根据面向方向旋转(AMap.LOCATION_TYPE_MAP_ROTATE)三种模式
    aMap.setMyLocationType(AMap.LOCATION_TYPE_MAP_FOLLOW);
  }