public void onDestroy() { super.onDestroy(); WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE); final String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()); deleteMarqueurBDD(ip); // Delete tout les marqueurs de la session mapView.destroyAll(); }
public MapZoomControls(Context context, final MapView mapView) { this.mapView = mapView; this.zoomControls = new ZoomControls(context); this.showMapZoomControls = true; this.zoomLevelMax = DEFAULT_ZOOM_LEVEL_MAX; this.zoomLevelMin = DEFAULT_ZOOM_LEVEL_MIN; this.zoomControls.setVisibility(View.GONE); this.zoomControlsGravity = DEFAULT_ZOOM_CONTROLS_GRAVITY; this.zoomControls.setOnZoomInClickListener( new ZoomInClickListener(mapView.getModel().mapViewPosition)); this.zoomControls.setOnZoomOutClickListener( new ZoomOutClickListener(mapView.getModel().mapViewPosition)); this.zoomControlsHideHandler = new ZoomControlsHideHandler(this.zoomControls); this.mapView.getModel().mapViewPosition.addObserver(this); int wrapContent = android.view.ViewGroup.LayoutParams.WRAP_CONTENT; LayoutParams layoutParams = new LayoutParams(wrapContent, wrapContent); this.mapView.addView(this.zoomControls, layoutParams); }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); AndroidGraphicFactory.createInstance(this.getApplication()); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); mapView = new MapView(this); setContentView(this.mapView); mapView.setClickable(true); mapView.setBuiltInZoomControls(true); mapView.getMapZoomControls().setZoomLevelMin((byte) 17); mapView.getMapZoomControls().setZoomLevelMax((byte) 20); tileCache = AndroidUtil.createTileCache( this, "mapcache", mapView.getModel().displayModel.getTileSize(), 1f, mapView.getModel().frameBufferModel.getOverdrawFactor()); }
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); }