示例#1
0
 private static Paint createPaintBack(GraphicFactory graphicFactory, DisplayModel displayModel) {
   Paint paint = graphicFactory.createPaint();
   paint.setColor(Color.WHITE);
   paint.setStrokeWidth(4 * displayModel.getScaleFactor());
   paint.setStyle(Style.STROKE);
   return paint;
 }
示例#2
0
  public void onStart() {
    super.onStart();
    mapView.getModel().mapViewPosition.setCenter(new LatLong(48.841751, 2.2684444)); // Center
    mapView.getModel().mapViewPosition.setZoomLevel((byte) 19); // ZoomLevel
    Intent intent = getIntent();
    String numEtage = intent.getStringExtra("numEtage"); // getNumEtage
    switch (Integer.parseInt(numEtage)) // Quel Etage ?
    {
      case 2:
        URLMap = "/Smartcampus/Salle2.map";
        break;
      case 3:
        URLMap = "/Smartcampus/Salle3.map";
        break;
      case 4:
        URLMap = "Smartcampus/Salle4.map";
        break;
    }

    file = new File(Environment.getExternalStorageDirectory(), URLMap);
    MapDataStore mapDataStore = new MapFile(file);
    Drawable drawable;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
      drawable = getDrawable(R.drawable.marqueur2);
    else drawable = getResources().getDrawable(R.drawable.marqueur2);
    final Bitmap bitmap = AndroidGraphicFactory.convertToBitmap(drawable);
    bitmap.scaleTo(60, 100);
    final ArrayList<DeviceMarker> listMarkers =
        InitMarqueur(); // Récupération des marqueurs de la BDD
    Bundle bundleObject = getIntent().getExtras();
    ArrayList<Node> listNode =
        (ArrayList<Node>)
            bundleObject.getSerializable("listNode"); // Récup la liste de Node qui forme le chemin
    tileRendererLayer =
        new TileRendererLayer(
            tileCache,
            mapDataStore,
            mapView.getModel().mapViewPosition,
            false,
            true,
            AndroidGraphicFactory.INSTANCE) {
          public boolean onLongPress(LatLong geoPoint, Point viewPosition, Point tapPoint) {
            WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE);
            final String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());

            final DeviceMarker marker =
                new DeviceMarker(
                    new LatLong(geoPoint.latitude, geoPoint.longitude),
                    bitmap,
                    0,
                    -bitmap.getHeight() / 2,
                    new Device(Build.MODEL, ip),
                    MapActivity.this);
            if (markerOnMap) {
              updateMarqueurBDD(marker);
            } else {
              addMarqueurBDD(marker); // ajout du marqueur dans la BDD
              markerOnMap = true;
            }

            //    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
            //    v.vibrate(1000);
            mapView.getLayerManager().getLayers().add(marker);
            Toast.makeText(getApplication(), "New marker " + ip, Toast.LENGTH_SHORT).show();
            return true;
          }
        };
    tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.OSMARENDER);
    mapView.getLayerManager().getLayers().add(tileRendererLayer);

    // Création des points possible à partir d'ici
    /*    marker= new DeviceMarker(new LatLong(48.8416264, 2.2689432),
            bitmap,
            0, -bitmap.getHeight() / 2,
            new Device(Build.MODEL,"192"),
            getApplicationContext());
    mapView.getLayerManager().getLayers().add(marker);*/

    for (DeviceMarker dm : listMarkers) // Ajout des marqueurs dans la mapView
    {
      Log.i("InitMarqueur", "IP marqueur : " + String.valueOf(dm.getDev().getIp()));
      mapView.getLayerManager().getLayers().add(dm);
    }
    // Creation chemin
    Paint paint = AndroidGraphicFactory.INSTANCE.createPaint();
    paint.setColor(Color.RED);
    paint.setStrokeWidth(3);
    paint.setStyle(Style.STROKE);
    Polyline polyline = new Polyline(paint, AndroidGraphicFactory.INSTANCE);
    List<LatLong> coordinateList = polyline.getLatLongs();
    for (Node n : listNode) {
      coordinateList.add(new LatLong(n.latitude, n.longitude));
    }
    mapView.getLayerManager().getLayers().add(polyline);
  }