@Override
 public void onCreate() {
   // TODO Auto-generated method stub
   super.onCreate();
   // 百度地图初始化
   SDKInitializer.initialize(getApplicationContext());
 }
示例#2
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   SDKInitializer.initialize(getApplicationContext());
   setContentView(R.layout.activity_main);
   mMapView = (MapView) findViewById(R.id.bmapView);
 }
  @Override
  public void onCreate() {
    super.onCreate();

    HSAccountManager.getInstance();

    doInit();

    initImageLoader(this);

    // 初始化百度地图 SDK
    SDKInitializer.initialize(getApplicationContext());

    // 初始化通讯录管理类,同步通讯录,用于生成好友列表
    HSPhoneContactMgr.init();
    HSPhoneContactMgr.enableAutoUpload(true);
    HSPhoneContactMgr.startSync();

    // 初始化好友列表管理类,同步好友列表
    HSContactFriendsMgr.init(this, null, URL_SYNC, URL_ACK);
    HSContactFriendsMgr.startSync(true);

    // 将本类添加为 HSMessageManager 的监听者,监听各类消息变化事件
    // 参见 HSMessageManager 类与 HSMessageChangeListener 接口
    HSMessageManager.getInstance().addListener(this, new Handler());

    // 为 HSGlobalNotificationCenter 功能设定监听接口
    INotificationObserver observer = this;
    HSGlobalNotificationCenter.addObserver(
        SampleFragment.SAMPLE_NOTIFICATION_NAME,
        observer); // 演示HSGlobalNotificationCenter功能:增加名为 SAMPLE_NOTIFICATION_NAME 的观察者
  }
 @Override
 public void onCreate() {
   // TODO Auto-generated method stub
   super.onCreate();
   // 在使用 SDK 各组间之前初始化 context 信息,传入 ApplicationContext
   SDKInitializer.initialize(this);
 }
示例#5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // 添加百度地图SDK
    SDKInitializer.initialize(getApplicationContext());
    // setContentView(R.layout.activity_main);

    setContentView(R.layout.layout_login);
    application = (MyApplication) this.getApplication();
    context = LoginActivity.this;
    AbTitleBar mAbTitleBar = this.getTitleBar();
    mAbTitleBar.setVisibility(View.GONE);

    String username = application.getProperty(Constants.USER_NAME);
    if (null != username && username.length() > 0) {
      inputUsername.setText(username);
    }

    Button button = (Button) findViewById(R.id.login_button);

    button.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View arg0) {
            login();
          }
        });

    inputPassword.setOnEditorActionListener(
        new OnEditorActionListener() {

          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
              // 隐藏软键盘
              InputMethodManager imm =
                  (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(inputPassword.getWindowToken(), 0);
              login();
              return true;
            }
            return false;
          }
        });

    OnClickListener keyboard_hide =
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            InputMethodManager imm =
                (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
          }
        };
    full_screen_layout.setClickable(true);
    full_screen_layout.setOnClickListener(keyboard_hide);
  }
 // 加载百度地图,
 @Override
 public void onCreate() {
   super.onCreate();
   SDKInitializer.initialize(getApplicationContext());
   StaticDatas.context = this;
   Intent ChatServiceIntent = new Intent(this, ChatService.class);
   startService(ChatServiceIntent);
 }
  @Override
  public void onCreate() {
    // TODO Auto-generated method stub
    // 在使用 SDK 各组间之前初始化 context 信息,传入 ApplicationContext
    SDKInitializer.initialize(this);
    app = this;
    super.onCreate();
    isActive = true;

    PushManager.startWork(
        getApplicationContext(), PushConstants.LOGIN_TYPE_API_KEY, "TGBGeiev9mNRlWno7K2QhdXr");
  }
 @Override
 public void onCreate() {
   Log.i(BaiduMapAll.LOG_TAG, "初始化LocationApplication!");
   super.onCreate();
   // onCreate(getBaseContext());
   mLocationClient = new LocationClient(this.getBaseContext());
   mMyLocationListener = new MyLocationListener();
   mLocationClient.registerLocationListener(mMyLocationListener);
   // this.activityContex=context;
   // 不初始化,不能计算距离
   SDKInitializer.initialize(this.getBaseContext().getApplicationContext());
   handler = new Handler(Looper.getMainLooper());
 }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   SDKInitializer.initialize(getApplicationContext());
   setContentView(R.layout.activity_main);
   this.context = this;
   mapView = (MapView) findViewById(R.id.bmapView);
   // 设置初始的地图比例  500米
   mBaiduMap = mapView.getMap();
   MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f);
   mBaiduMap.setMapStatus(msu);
   // 初始化定位
   initLocation();
 }
示例#10
0
 /**
  * 获取定位Client
  *
  * @return locationClient
  * @author Anddward.Liao <*****@*****.**>
  */
 public LocationClient getmLocationClient() {
   if (null == mLocationClient) {
     SDKInitializer.initialize(getApplicationContext());
     mLocationClient = new LocationClient(getInstance()); // 声明LocationClient类
     LocationClientOption option = new LocationClientOption();
     option.setLocationMode(LocationMode.Battery_Saving); // 设置定位模式
     option.setCoorType("bd09ll"); // 返回的定位结果是百度经纬度,默认值gcj02
     option.setScanSpan(20000); // 设置发起定位请求的间隔时间为5000ms
     option.setIsNeedAddress(true); // 返回的定位结果包含地址信息
     option.setNeedDeviceDirect(false); // 返回的定位结果包含手机机头的方向
     mLocationClient.setLocOption(option);
   }
   return mLocationClient;
 }
示例#11
0
  /**
   * 构造方法
   *
   * @param context
   * @param inParent
   */
  public EUExBaiduMap(Context context, EBrowserView inParent) {
    super(context, inParent);

    if (!isBaiduSdkInit) {
      SDKInitializer.initialize(
          context.getApplicationContext()); // 在使用SDK各组间之前初始化context信息,传入ApplicationContext
      isBaiduSdkInit = true;
    }

    // 注册 SDK 广播接收器
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_OK);
    intentFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR);
    intentFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR);
    mSDKReceiver = new SDKReceiver();
    mContext.registerReceiver(mSDKReceiver, intentFilter);
  }
示例#12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    SDKInitializer.initialize(getApplicationContext());
    super.onCreate(savedInstanceState);

    // 百度推送
    Utils.logStringCache = Utils.getLogText(getApplicationContext());
    Resources resource = this.getResources();
    String pkgName = this.getPackageName();
    // Push: 以apikey的方式登录,一般放在主Activity的onCreate中。
    // 这里把apikey存放于manifest文件中,只是一种存放方式,
    // 您可以用自定义常量等其它方式实现,来替换参数中的Utils.getMetaValue(PushDemoActivity.this,
    // "api_key")
    PushManager.startWork(
        getApplicationContext(),
        PushConstants.LOGIN_TYPE_API_KEY,
        Utils.getMetaValue(this, "api_key"));
    // Push: 如果想基于地理位置推送,可以打开支持地理位置的推送的开关
    // PushManager.enableLbs(getApplicationContext());

    // Push: 设置自定义的通知样式,具体API介绍见用户手册,如果想使用系统默认的可以不加这段代码
    // 请在通知推送界面中,高级设置->通知栏样式->自定义样式,选中并且填写值:1,
    // 与下方代码中 PushManager.setNotificationBuilder(this, 1, cBuilder)中的第二个参数对应
    CustomPushNotificationBuilder cBuilder =
        new CustomPushNotificationBuilder(
            getApplicationContext(),
            resource.getIdentifier("notification_custom_builder", "layout", pkgName),
            resource.getIdentifier("notification_icon", "id", pkgName),
            resource.getIdentifier("notification_title", "id", pkgName),
            resource.getIdentifier("notification_text", "id", pkgName));
    cBuilder.setNotificationFlags(Notification.FLAG_AUTO_CANCEL);
    cBuilder.setNotificationDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
    cBuilder.setStatusbarIcon(this.getApplicationInfo().icon);
    cBuilder.setLayoutDrawable(
        resource.getIdentifier("simple_notification_icon", "drawable", pkgName));
    PushManager.setNotificationBuilder(this, 1, cBuilder);

    // ToastUtil.toast(getApplicationContext(), ""+PushConstants.LOGIN_TYPE_API_KEY);
    // Log.e("开始推动",""+ PushConstants.LOGIN_TYPE_API_KEY);

    Log.i(TAG, "=========开始定位=========");
    setContentView(R.layout.indoorsy_home);
    fragmentManager = getSupportFragmentManager(); // 获取FragmentManager实例
    init(); // 初始化页面
  }
示例#13
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "[ACTIVITY] onCreate");
    super.onCreate(savedInstanceState);
    instance = this;
    // 在使用SDK各组件之前初始化context信息,传入ApplicationContext
    // 注意该方法要再setContentView方法之前实现
    SDKInitializer.initialize(getApplicationContext());
    mStepValue = 0;
    mPaceValue = 0;

    setContentView(R.layout.layoutmain);

    mUtils = Utils.getInstance();
    mMapView = (MapView) findViewById(R.id.bmapView);
    // sendButton = (Button) findViewById(R.id.btn_location_send);
    Intent intent = getIntent();
    double latitude = intent.getDoubleExtra("latitude", 0);
    mCurrentMode = LocationMode.NORMAL;
    mBaiduMap = mMapView.getMap();
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f);
    mBaiduMap.setMapStatus(msu);
    initMapView();
    if (latitude == 0) {
      mMapView = new MapView(this, new BaiduMapOptions());
      mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(mCurrentMode, true, null));
      showMapWithLocationClient();
    } else {
      double longtitude = intent.getDoubleExtra("longitude", 0);
      String address = intent.getStringExtra("address");
      LatLng p = new LatLng(latitude, longtitude);
      mMapView =
          new MapView(
              this, new BaiduMapOptions().mapStatus(new MapStatus.Builder().target(p).build()));
      showMap(latitude, longtitude, address);
    }
    // 注册 SDK 广播监听者
    IntentFilter iFilter = new IntentFilter();
    iFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR);
    iFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR);
    mBaiduReceiver = new BaiduSDKReceiver();
    registerReceiver(mBaiduReceiver, iFilter);
  }
示例#14
0
  @Override
  public void onCreate() {
    super.onCreate();
    mInstance = this;
    /** 初始化 */
    AiYouManager.getInstance(this);
    NetWorkManager.getInstance(this);
    SwitchManager.getInstance(this);

    if (FileManager.checkSDCard()) {
      removeExpiredCache();
    } else {
      Toast.makeText(getBaseContext(), "SD卡未安装或空间不足", Toast.LENGTH_SHORT).show();
    }

    try {
      // 百度地图初始化
      SDKInitializer.initialize(this);
      initEngineManager(this);
    } catch (Exception e) {
      Logcat.e(TAG, "百度地图初始化错误");
    }

    /** 友盟推送 */
    mPushAgent = PushAgent.getInstance(this);
    mPushAgent.setDebugMode(false);
    /** 友盟用户反馈 */
    FeedbackPush.getInstance(this).init(false);
    /** 友盟自动更新 */
    // 非wifi环境更新开启,要放在updata()之前调用
    UmengUpdateAgent.setUpdateOnlyWifi(SwitchManager.getInstance(this).getUpdateOnlyWifi());
    UmengUpdateAgent.update(this);
    /** 友盟在线参数—— 获取帖子尾巴 */
    MobclickAgent.updateOnlineConfig(this);
    BBSManager.getInstance(this).setAppTail(MobclickAgent.getConfigParams(this, "app_tail"));
    // 获取iptv频道列表
    IptvManager.getChanelList();

    MapHelper.initMapDatas(this);

    initSections();
    initFavorite();
  }
  @Override
  public void onCreate() {
    super.onCreate();
    SDKInitializer.initialize(getApplicationContext());
    RequestManager.init(getApplicationContext());
    // 百度地图初始化
    // PropertyConfigurator.configure("log4j.properties");
    // // 给全局上下文赋值
    Globals.context = getApplicationContext();
    if (Globals.context != null) {
      initImageConfigure();
    }
    RequestManager.init(this);
    mLocationClient = new LocationClient(this.getApplicationContext());
    mMyLocationListener = new MyLocationListener();
    mLocationClient.registerLocationListener(mMyLocationListener);
    mGeofenceClient = new GeofenceClient(getApplicationContext());

    mVibrator = (Vibrator) getApplicationContext().getSystemService(Service.VIBRATOR_SERVICE);

    // initMap();

  }
示例#16
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.aty_location);
    et_searchkey = (EditText) findViewById(R.id.et_searchkey);

    Frg_LocationHistory locationHistory = new Frg_LocationHistory();
    getSupportFragmentManager().beginTransaction().replace(R.id.ll_frg, locationHistory).commit();

    et_searchkey.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (s.length() <= 0) {
              Frg_LocationHistory locationHistory = new Frg_LocationHistory();
              getSupportFragmentManager()
                  .beginTransaction()
                  .replace(R.id.ll_frg, locationHistory)
                  .commit();
            } else {
              Frg_LocationNow locationNow = new Frg_LocationNow();
              getSupportFragmentManager()
                  .beginTransaction()
                  .replace(R.id.ll_frg, locationNow)
                  .commit();
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {}
        });
  }
示例#17
0
  @Override
  public void onCreate() {

    // 应用程序入口处调用,避免手机内存过小,杀死后台进程后通过历史intent进入Activity造成SpeechUtility对象为null
    // 注意:此接口在非主进程调用会返回null对象,如需在非主进程使用语音功能,请增加参数:SpeechConstant.FORCE_LOGIN+"=true"
    // 参数间使用“,”分隔。
    super.onCreate();
    SpeechUtility.createUtility(this, "appid=" + getString(R.string.app_id));

    /*
     * 百度地图SDK初始化
     *
     * 初始化全局 context,指定 sdcard 路径,若采用默认路径,请使用initialize(Context context)
     * 重载函数 参数:
     *
     * sdcardPath - sd 卡路径,请确保该路径能正常使用 context - 必须是 application context,SDK
     * 各组件中需要用到。
     */
    try {
      SDKInitializer.initialize(Constant.Path.SD_CARD_INTERNAL, getApplicationContext());
    } catch (Exception e) {

    }
  }
示例#18
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   // 在使用SDK各组件之前初始化context信息,传入ApplicationContext
   // 注意该方法要再setContentView方法之前实现
   SDKInitializer.initialize(getApplicationContext());
   setContentView(R.layout.activity_main);
   fragments = new Fragment[4];
   fmanager = getSupportFragmentManager();
   fragments[0] = fmanager.findFragmentById(R.id.fragment_help);
   fragments[1] = fmanager.findFragmentById(R.id.fragment_report);
   fragments[2] = fmanager.findFragmentById(R.id.fragment_more);
   fragments[3] = fmanager.findFragmentById(R.id.fragment_personal);
   ftransaction =
       fmanager
           .beginTransaction()
           .hide(fragments[0])
           .hide(fragments[1])
           .hide(fragments[2])
           .hide(fragments[3]);
   ftransaction.show(fragments[0]).commit();
   setFragmentIndicator();
 }
示例#19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_main);

    tanchu = (Button) findViewById(R.id.tanchu);
    mapview = (MapView) findViewById(R.id.bmapView);
    this.context = this;
    MapStatusUpdate chengdu = MapStatusUpdateFactory.zoomTo(15.0f);

    mapdu = mapview.getMap();
    mapdu.setMapStatus(chengdu);
    tanchu.setOnClickListener(this);
    initLocation();
    initMapWu();

    mapdu.setOnMarkerClickListener(
        new OnMarkerClickListener() {

          public boolean onMarkerClick(Marker marker) {
            // TODO Auto-generated method stub
            Bundle bundle = marker.getExtraInfo(); // 获得Marker中的信息
            //	   info    dedao       =  (info) bundle.getSerializable("info");
            //	   Toast.makeText(context, dedao.getName(), 0).show();
            Intent intent = new Intent();
            intent.setClass(context, detail_content.class);
            intent.putExtras(bundle); // 传递bundle的值
            /* 点击添加物,显示添加物的地理位置
            InfoWindow  infowindow ;
            TextView  text = new TextView(context);
            text.setBackgroundResource(getResources().getDrawable(R.drawable.));
               text.setPadding(30, 20, 30, 50);
               info    dedao       =  (info) bundle.getSerializable("info");
             text.setText(dedao.getName());
             //final常量不能被更改
             final    LatLng  latlng =  marker.getPosition();   //得到此标记的经纬度
              	Point  p  = mapdu.getProjection().toScreenLocation(latlng)	; //将经纬度转化成屏幕上的点
              p.y -= 47;
             LatLng   ii = mapdu.getProjection().fromScreenLocation(p);  //把点转化成经纬度
               infowindow = new InfoWindow(text, ii,  (Integer) null);*/

            startActivity(intent);

            return true;
          }
        });
    /*	  mapdu.setOnMapClickListener(new OnMapClickListener() {

    	public boolean onMapPoiClick(MapPoi arg0) {
    		// TODO Auto-generated method stub
    		return false;
    	}

    	public void onMapClick(LatLng arg0) {
    		// TODO Auto-generated method stub
    		        MarkerLinear.setVisibility(View.INVISIBLE);   //消失
    	}
    });*/
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_main);
    this.context = this;
    mapView = (MapView) findViewById(R.id.bmapView);
    // 设置初始的地图比例  500米
    mBaiduMap = mapView.getMap();
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f);
    mBaiduMap.setMapStatus(msu);
    // 初始化定位
    initLocation();

    initMarker();

    mBaiduMap.setOnMarkerClickListener(
        new OnMarkerClickListener() {

          @Override
          public boolean onMarkerClick(Marker marker) {
            Bundle extraInfo = marker.getExtraInfo();
            Info info = (Info) extraInfo.getSerializable("info");
            ImageView iv = (ImageView) mMarkerLy.findViewById(R.id.id_info_img);
            TextView distance = (TextView) mMarkerLy.findViewById(R.id.id_info_distance);
            TextView name = (TextView) mMarkerLy.findViewById(R.id.id_info_name);
            TextView zan = (TextView) mMarkerLy.findViewById(R.id.id_info_zan);

            iv.setImageResource(info.getImgId());
            distance.setText(info.getDistance());
            name.setText(info.getName());
            zan.setText(info.getZan() + "");

            // 初始化一个infowindow
            InfoWindow infoWindow;
            TextView tv = new TextView(context);
            tv.setBackgroundResource(R.drawable.location_tips);
            tv.setPadding(30, 20, 30, 50);
            tv.setText(info.getName());
            tv.setTextColor(Color.parseColor("#ffffff"));

            final LatLng latLng = marker.getPosition();
            Point p = mBaiduMap.getProjection().toScreenLocation(latLng);
            p.y -= 47;
            LatLng ll = mBaiduMap.getProjection().fromScreenLocation(p);

            // 地图SDK发生更改,第一个参数要使用bitmap
            BitmapDescriptor tvBD = BitmapDescriptorFactory.fromView(tv);
            infoWindow =
                new InfoWindow(
                    tvBD,
                    ll,
                    0,
                    new InfoWindow.OnInfoWindowClickListener() {

                      @Override
                      public void onInfoWindowClick() {
                        // TODO Auto-generated method stub
                        mBaiduMap.hideInfoWindow();
                      }
                    });

            mBaiduMap.showInfoWindow(infoWindow);

            mMarkerLy.setVisibility(View.VISIBLE);
            return true;
          }
        });

    mBaiduMap.setOnMapClickListener(
        new OnMapClickListener() {

          @Override
          public boolean onMapPoiClick(MapPoi arg0) {
            // TODO Auto-generated method stub
            return false;
          }

          @Override
          public void onMapClick(LatLng arg0) {
            // TODO Auto-generated method stub
            mMarkerLy.setVisibility(View.GONE);
            mBaiduMap.hideInfoWindow();
          }
        });
  }
示例#21
0
 /**
  * 初始化百度相关sdk initBaidumap @Title: initBaidumap @Description: TODO
  *
  * @param
  * @return void
  * @throws
  */
 private void initBaidu() {
   // 初始化地图Sdk
   SDKInitializer.initialize(this);
   // 初始化定位sdk
   initBaiduLocClient();
 }
示例#22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_main);
    b = (Button) findViewById(R.id.shit);
    c = (Button) findViewById(R.id.shit2);
    n = (NumberPicker) findViewById(R.id.num);
    n.setMaxValue(5);
    n.setMinValue(0);

    ////        b.setVisibility(View.INVISIBLE);
    map = file();
    map2 = file2();
    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(10.0f);
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(new LatLng(31.083236, 121.394725)));
    mBaiduMap.animateMapStatus(u);
    b.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            heatmap.removeHeatMap();
            //                for(String name:map2.keySet()){
            //                    LatLng ptCenter=new LatLng(map2.get(name)[0],map2.get(name)[1]);
            //                    mBaiduMap.addOverlay(new MarkerOptions().position(ptCenter)
            //                            .icon(BitmapDescriptorFactory
            //
            // .fromResource(R.drawable.shit)).perspective(true));
            //                }
          }
        });
    c.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (heatmap != null) heatmap.removeHeatMap();
            int time = 0;
            switch (n.getValue()) {
              case 0:
                time = 4;
                break;
              case 1:
                time = 8;
                break;
              case 2:
                time = 10;
                break;
              case 3:
                time = 16;
                break;
              case 4:
                time = 18;
                break;
              case 5:
                time = 22;
                break;
            }
            //                int[] DEFAULT_GRADIENT_COLORS = {Color.rgb(255, 255, 0),Color.rgb(255,
            // 200, 0),Color.rgb(255, 155, 0) ,Color.rgb(255, 100, 0),Color.rgb(255, 55,
            // 0),Color.rgb(255, 0, 0) };
            int[] DEFAULT_GRADIENT_COLORS = {Color.rgb(255, 255, 0), Color.rgb(255, 0, 0)};
            // 设置渐变颜色起始值
            float[] DEFAULT_GRADIENT_START_POINTS = {0.2f, 1f};
            //                float[] DEFAULT_GRADIENT_START_POINTS = { 0f,0.2f, 0.4f,0.6f,0.8f,1f
            // };
            // 构造颜色渐变对象1
            List<WeightedLatLng> l = new ArrayList<WeightedLatLng>();
            for (String n : map.keySet()) {
              if (!map2.containsKey(n) | !map.get(n).containsKey(time)) {
                Log.e(TAG, n);
                continue;
              }
              WeightedLatLng ll =
                  new WeightedLatLng(
                      new LatLng(map2.get(n)[0], map2.get(n)[1]), map.get(n).get(time));
              l.add(ll);
            }
            Gradient gradient =
                new Gradient(DEFAULT_GRADIENT_COLORS, DEFAULT_GRADIENT_START_POINTS);

            heatmap = new HeatMap.Builder().weightedData(l).gradient(gradient).radius(20).build();
            // 在地图上添加热力图
            mBaiduMap.addHeatMap(heatmap);
          }
        });
    // 设置渐变颜色值

  }
 @Override
 public void preSetContentView(Bundle savedInstanceState) {
   // TODO Auto-generated method stub
   SDKInitializer.initialize(getApplicationContext());
 }
示例#24
0
 private void initMap() {
   SDKInitializer.initialize(getApplicationContext());
 }
示例#25
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    requestWindowFeature(Window.FEATURE_NO_TITLE); // 去掉标题栏
    super.onCreate(savedInstanceState);

    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.navigate);
    // 地图初始化
    mMapView = (MapView) findViewById(R.id.mapview_navi);
    mBaiduMap = mMapView.getMap();
    mMapView.showZoomControls(false);
    mMapView.showScaleControl(true);
    // 开启定位图层
    mBaiduMap.setMyLocationEnabled(true);
    // 开启罗盘
    mBaiduMap.getUiSettings().setCompassEnabled(true);
    // 定位初始化
    mLocClient = new LocationClient(this);
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true); // 打开gps
    option.setCoorType("bd09ll"); // 设置坐标类型为百度经纬度坐标
    option.setScanSpan(1000);
    mLocClient.setLocOption(option);
    mLocClient.start();

    mBaiduMap.setOnMapLongClickListener(MyLongClickListener);

    // 初始化导航引擎
    //       BaiduNaviManager.getInstance().initEngine(this, getSdcardDir(),
    //       		mNaviEngineInitListener,ACCESS_KEY,mKeyVerifyListener);
    /*
            BaiduNaviManager.getInstance().initEngine(this, getSdcardDir(),
            mNaviEngineInitListener, new LBSAuthManagerListener() {
                @Override
                public void onAuthResult(int status, String msg) {
                    String str = null;
                    if (0 == status) {
                        str = "key校验成功!";
                    } else {
                        str = "key校验失败, " + msg;
                    }
                    Toast.makeText(NavigateActivity.this, str,
                            Toast.LENGTH_LONG).show();
                }
            });
    */
    boolean isInitSuccess =
        BaiduNaviManager.getInstance().checkEngineStatus(getApplicationContext());
    Toast.makeText(NavigateActivity.this, "isInitSuccess" + isInitSuccess, Toast.LENGTH_LONG)
        .show();

    // 设置策略
    TextView SetStrategy = (TextView) findViewById(R.id.tvStrategy);
    SetStrategy.setOnClickListener(
        new OnClickListener() {

          @SuppressWarnings("deprecation")
          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            showDialog(0);
          }
        });

    // 规划路径
    TextView CalcRoute = (TextView) findViewById(R.id.tvCalcRoutes);
    CalcRoute.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            if (hasEndpoint = true) {
              drivintResultIndex = 0;
              nextLineBtn.setEnabled(false);
              drivingSearch(drivintResultIndex); // 驾车路线规划
              // startCalcRoute(NL_Net_Mode.NL_Net_Mode_OnLine);
            } else {
              Toast.makeText(NavigateActivity.this, "请先设置终点!", Toast.LENGTH_SHORT).show();
            }
          }
        });
    routePlanSearch = RoutePlanSearch.newInstance();
    routePlanSearch.setOnGetRoutePlanResultListener(routePlanResultListener);

    // 开始导航
    TextView StartNavigate = (TextView) findViewById(R.id.tvStartNavi);
    StartNavigate.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            //		launchNavigator();
            startNaviByClient(); // 调用客户端的方式发起导航
          }
        });

    // 下一条路径
    nextLineBtn = (Button) findViewById(R.id.nextline_btn);
    nextLineBtn.setEnabled(false);
    nextLineBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            drivingSearch(++drivintResultIndex);
          }
        });
  }
示例#26
0
 private MapUtil() {
   SDKInitializer.initialize(context);
 }
示例#27
0
 @Override
 public void onCreate() {
   super.onCreate();
   context = getApplicationContext();
   SDKInitializer.initialize(getApplicationContext());
 }
示例#28
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_main);
    initView();
    map = mapView.getMap();
    setSupportActionBar(toolbar);

    locationListener = new MyLocationListener(mapView, this);

    // 地图初始化
    map.setMyLocationEnabled(true);
    locationClient = new LocationClient(this);
    locationClient.registerLocationListener(locationListener);
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true);
    option.setScanSpan(5000);
    option.setCoorType("bd09ll");
    option.setAddrType("all");

    locationClient.setLocOption(option);
    locationClient.start();
    map.setMapStatus(MapStatusUpdateFactory.zoomTo(16)); // 设置初始缩放等级
    initOrientationListener();

    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            centerToCurrentPlace();
          }
        });

    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawerLayout,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawerLayout.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    // 长按添加一个Marker
    map.setOnMapLongClickListener(
        new BaiduMap.OnMapLongClickListener() {
          @Override
          public void onMapLongClick(LatLng latLng) {
            OverlayOptions oo = new MarkerOptions().icon(bd).position(latLng);
            map.addOverlay(oo);
          }
        });

    map.setOnMapClickListener(
        new BaiduMap.OnMapClickListener() {
          @Override
          public void onMapClick(LatLng latLng) {
            map.hideInfoWindow();
          }

          @Override
          public boolean onMapPoiClick(MapPoi mapPoi) {
            return false;
          }
        });
    map.setOnMarkerClickListener(
        new BaiduMap.OnMarkerClickListener() {
          @Override
          public boolean onMarkerClick(final Marker marker) {
            Toast.makeText(
                    getApplicationContext(),
                    "点击了" + marker.getPosition().toString(),
                    Toast.LENGTH_SHORT)
                .show();
            Button button = new Button(getApplicationContext());

            button.setBackgroundResource(R.drawable.popup);
            button.setText("活动点");
            button.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                    marker.remove();
                    map.hideInfoWindow();
                  }
                });
            InfoWindow info = new InfoWindow(button, marker.getPosition(), -100);
            map.showInfoWindow(info);
            return true;
          }
        });
  }
 @Override
 public void onCreate() {
   super.onCreate();
   // 在使用 SDK 各组间之前初始化 context 信息,传入 ApplicationContext
   SDKInitializer.initialize(this);
 }