private TileRendererLayer createTileRendererLayer(
     TileCache tileCache,
     MapViewPosition mapViewPosition,
     boolean isTransparent,
     boolean renderLabels,
     String mapFile,
     String rendererFile) {
   TileRendererLayer tileRendererLayer =
       new TileRendererLayer(
           tileCache,
           new MapFile(mapFile),
           mapViewPosition,
           isTransparent,
           renderLabels,
           GRAPHIC_FACTORY);
   tileRendererLayer.setXmlRenderTheme(new MapsForgeFileXmlRenderTheme(rendererFile));
   return tileRendererLayer;
 }
 private TileRendererLayer createTileRendererLayerWithString(
     TileCache tileCache,
     MapViewPosition mapViewPosition,
     boolean isTransparent,
     boolean renderLabels,
     String mapFile,
     String xml,
     String fileLocation) {
   TileRendererLayer tileRendererLayer =
       new TileRendererLayer(
           tileCache,
           new MapFile(mapFile),
           mapViewPosition,
           isTransparent,
           renderLabels,
           GRAPHIC_FACTORY);
   tileRendererLayer.setXmlRenderTheme(new MapsForgeStringXmlRenderTheme(xml, fileLocation));
   return tileRendererLayer;
 }
Пример #3
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);
  }