@Override
  public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
    if (topic.equals("Likaci/MqttMap")) {
      String msg = new String(mqttMessage.getPayload());
      JSONObject json = new JSONObject(msg);
      if (!json.getString("id").equals(id)) {
        Point p =
            (Point)
                GeometryEngine.project(
                    new Point(json.getDouble("x"), json.getDouble("y")),
                    SpatialReference.create(4326),
                    SpatialReference.create(3857));

        layer.removeAll();

        SimpleMarkerSymbol markerSymbol =
            new SimpleMarkerSymbol(
                Color.parseColor("#763382"), 15, SimpleMarkerSymbol.STYLE.DIAMOND);
        layer.addGraphic(new Graphic(p, markerSymbol));

        TextSymbol textSymbol =
            new TextSymbol(
                15,
                json.getString("id"),
                Color.parseColor("#763382"),
                TextSymbol.HorizontalAlignment.CENTER,
                TextSymbol.VerticalAlignment.MIDDLE);
        textSymbol.setOffsetY(-15);
        layer.addGraphic(new Graphic(p, textSymbol));
      }
    }
  }
예제 #2
0
  private void updateToNewLocation(Location location) {
    gpsLayer.removeAll();
    double latitude = location.getLatitude();
    double longitude = location.getLongitude();

    Point ptMap1 =
        (Point)
            GeometryEngine.project(
                new Point(longitude, latitude),
                SpatialReference.create(4326),
                mMapView.getSpatialReference());

    gpsLayer.addGraphic(new Graphic(ptMap1, resultIcon));

    // mMapView.zoomToScale(ptMap1, 4223);
    // mMapView.centerAt(ptMap1, true);

  }
예제 #3
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.map_Slayer:
        isStreetMapLayer = !isStreetMapLayer;
        if (isStreetMapLayer) {
          maplayerlist.setVisibility(View.VISIBLE);
        } else {
          maplayerlist.setVisibility(View.GONE);
        }
        break;
      case R.id.map_Zlayer:
        isZtreetMapLayer = !isZtreetMapLayer;
        if (isZtreetMapLayer) {
          layer_frame.setVisibility(View.VISIBLE);
        } else {
          layer_frame.setVisibility(View.GONE);
        }
        break;
      case R.id.my_location_btn:
        if (gps) {
          openGPSSettings();
        } else {
          gpsLayer.removeAll();
          if (locationManager != null & locationListener != null) {
            try {
              locationManager.removeUpdates(locationListener);
            } catch (SecurityException e) {
              e.printStackTrace();
            }

            locationManager = null;
            locationListener = null;
          }
        }
        gps = !gps;

        break;
    }
  }