org.mapsforge.core.model.LatLong Java Examples
The following examples show how to use
org.mapsforge.core.model.LatLong.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HomeActivity.java From EasyVPN-Free with GNU General Public License v3.0 | 7 votes |
private void initDetailsServerOnMap() { if (markerList != null && markerList.size() > 0) { for (Marker marker : markerList) { layers.remove(marker); } } List<Server> serverList = dbHelper.getServersWithGPS(); markerList = new ArrayList<Marker>(); for (Server server : serverList) { LatLong position = new LatLong(server.getLat(), server.getLon()); Bitmap bitmap = AndroidGraphicFactory.convertToBitmap(ContextCompat.getDrawable(this, getResources().getIdentifier(ConnectionQuality.getSimplePointIcon(server.getQuality()), "drawable", getPackageName()))); Marker serverMarker = new Marker(position, bitmap, 0, 0); markerList.add(serverMarker); layers.add(serverMarker); } }
Example #2
Source File: MapCreator.java From EasyVPN-Free with GNU General Public License v3.0 | 6 votes |
private void createPolygons(JSONArray coordinates) { Polygon polygon = new Polygon(paintFill, paintStroke, AndroidGraphicFactory.INSTANCE); List<LatLong> polygonList = polygon.getLatLongs(); for (int j = 0; j < coordinates.length(); j++) { try { JSONArray arrLatLong = new JSONArray(coordinates.get(j).toString()); polygonList.add(new LatLong(arrLatLong.getDouble(1), arrLatLong.getDouble(0))); } catch (JSONException e) { e.printStackTrace(); } } layers.add(polygon); }
Example #3
Source File: MapsforgeNwwLayer.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
public MapsforgeNwwLayer(String layerName, File[] mapsforgeFiles, Integer tileSize, Float scaleFactor) throws Exception { super(makeLevels(layerName, getTilegenerator(mapsforgeFiles, tileSize, scaleFactor), tileSize)); this.layerName = layerName; this.setUseTransparentTextures(true); MultiMapDataStore mapDatabase = new MultiMapDataStore(DataPolicy.RETURN_ALL); for (int i = 0; i < mapsforgeFiles.length; i++) mapDatabase.addMapDataStore(new MapFile(mapsforgeFiles[i]), false, false); BoundingBox boundingBox = mapDatabase.boundingBox(); LatLong centerPoint = boundingBox.getCenterPoint(); centerCoordinate = new Coordinate(centerPoint.longitude, centerPoint.latitude); mapDatabase.close(); }
Example #4
Source File: MapsforgeSimpleViewer.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unused") private static TileDownloadLayer createTileDownloadLayer( TileCache tileCache, IMapViewPosition mapViewPosition, TileSource tileSource ) { return new TileDownloadLayer(tileCache, mapViewPosition, tileSource, GRAPHIC_FACTORY){ @Override public boolean onTap( LatLong tapLatLong, Point layerXY, Point tapXY ) { System.out.println("Tap on: " + tapLatLong); return true; } }; }
Example #5
Source File: MapsforgeSimpleViewer.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
private static TileRendererLayer createTileRendererLayer( TileCache tileCache, MapDataStore mapDataStore, IMapViewPosition mapViewPosition ) { TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore, mapViewPosition, false, true, false, GRAPHIC_FACTORY){ @Override public boolean onTap( LatLong tapLatLong, Point layerXY, Point tapXY ) { System.out.println("Tap on: " + tapLatLong); return true; } }; tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.DEFAULT); return tileRendererLayer; }
Example #6
Source File: MapSectionFragment.java From satstat with GNU General Public License v3.0 | 5 votes |
@Override public void onStop() { LatLong center = mapMap.getModel().mapViewPosition.getCenter(); byte zoom = mapMap.getModel().mapViewPosition.getZoomLevel(); SharedPreferences.Editor spEditor = mainActivity.mSharedPreferences.edit(); spEditor.putFloat(Const.KEY_PREF_MAP_LAT, (float) center.latitude); spEditor.putFloat(Const.KEY_PREF_MAP_LON, (float) center.longitude); spEditor.putInt(Const.KEY_PREF_MAP_ZOOM, zoom); spEditor.commit(); super.onStop(); }
Example #7
Source File: HomeActivity.java From EasyVPN-Free with GNU General Public License v3.0 | 4 votes |
private void initServerOnMap(Layers layers) { Type listType = new TypeToken<ArrayList<Country>>(){}.getType(); countryLatLonList = new Gson().fromJson(LoadData.fromFile(COUNTRY_FILE_NAME, this), listType); for (Server server : countryList) { for (Country country : countryLatLonList) { if (server.getCountryShort().equals(country.getCountryCode())) { LatLong position = new LatLong(country.getCapitalLatitude(), country.getCapitalLongitude()); Bitmap bitmap = AndroidGraphicFactory.convertToBitmap(ContextCompat.getDrawable(this, getResources().getIdentifier(ConnectionQuality.getPointIcon(server.getQuality()), "drawable", getPackageName()))); MyMarker countryMarker = new MyMarker(position, bitmap, 0, 0, server) { @Override public boolean onTap(LatLong geoPoint, Point viewPosition, Point tapPoint) { if (contains(viewPosition, tapPoint)) { onSelectCountry((Server)getRelationObject()); return true; } return false; } }; layers.add(countryMarker); String localeCountryName = localeCountries.get(country.getCountryCode()) != null ? localeCountries.get(country.getCountryCode()) : country.getCountryName(); Drawable drawable = new BitmapDrawable(getResources(), BitmapGenerator.getTextAsBitmap(localeCountryName, 20, ContextCompat.getColor(this,R.color.mapNameCountry))); Bitmap bitmapName = AndroidGraphicFactory.convertToBitmap(drawable); Marker countryNameMarker = new Marker(position, bitmapName, 0, bitmap.getHeight() / 2); layers.add(countryNameMarker); } } } }
Example #8
Source File: MapSectionFragment.java From satstat with GNU General Public License v3.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mainActivity = (MainActivity) this.getContext(); View rootView = inflater.inflate(R.layout.fragment_main_map, container, false); float density = this.getContext().getResources().getDisplayMetrics().density; String versionName; try { versionName = mainActivity.getPackageManager().getPackageInfo(mainActivity.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { versionName = "unknown"; } mapReattach = (ImageButton) rootView.findViewById(R.id.mapReattach); mapAttribution = (TextView) rootView.findViewById(R.id.mapAttribution); mapReattach.setVisibility(View.GONE); isMapViewAttached = true; OnClickListener clis = new OnClickListener () { @Override public void onClick(View v) { if (v == mapReattach) { isMapViewAttached = true; mapReattach.setVisibility(View.GONE); updateMap(); } } }; mapReattach.setOnClickListener(clis); // Initialize controls mapMap = new MapView(rootView.getContext()); ((FrameLayout) rootView).addView(mapMap, 0); mapMap.setClickable(true); mapMap.getMapScaleBar().setVisible(true); mapMap.getMapScaleBar().setMarginVertical((int)(density * 16)); mapMap.setBuiltInZoomControls(true); mapMap.getMapZoomControls().setZoomLevelMin((byte) 10); mapMap.getMapZoomControls().setZoomLevelMax((byte) 20); mapMap.getMapZoomControls().setZoomControlsOrientation(Orientation.VERTICAL_IN_OUT); mapMap.getMapZoomControls().setZoomInResource(R.drawable.zoom_control_in); mapMap.getMapZoomControls().setZoomOutResource(R.drawable.zoom_control_out); mapMap.getMapZoomControls().setMarginHorizontal((int)(density * 8)); mapMap.getMapZoomControls().setMarginVertical((int)(density * 16)); providerLocations = new HashMap<String, Location>(); mAvailableProviderStyles = new ArrayList<String>(Arrays.asList(Const.LOCATION_PROVIDER_STYLES)); providerStyles = new HashMap<String, String>(); providerAppliedStyles = new HashMap<String, String>(); providerInvalidationHandler = new Handler(); providerInvalidators = new HashMap<String, Runnable>(); onlineTileSource = new OnlineTileSource(Const.TILE_SERVER_OSM, 80); onlineTileSource.setUserAgent(String.format("%s/%s (%s)", "SatStat", versionName, System.getProperty("http.agent"))); onlineTileSource.setName(Const.TILE_CACHE_OSM) .setAlpha(false) .setBaseUrl(Const.TILE_URL_OSM) .setExtension(Const.TILE_EXTENSION_OSM) .setParallelRequestsLimit(8) .setProtocol("http") .setTileSize(256) .setZoomLevelMax((byte) 18) .setZoomLevelMin((byte) 0); GestureDetector gd = new GestureDetector(rootView.getContext(), new GestureDetector.SimpleOnGestureListener() { public boolean onScroll (MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { mapReattach.setVisibility(View.VISIBLE); isMapViewAttached = false; return false; } } ); mapMap.setGestureDetector(gd); mainActivity.mapSectionFragment = this; float lat = mainActivity.mSharedPreferences.getFloat(Const.KEY_PREF_MAP_LAT, 360.0f); float lon = mainActivity.mSharedPreferences.getFloat(Const.KEY_PREF_MAP_LON, 360.0f); if ((lat < 360.0f) && (lon < 360.0f)) { mapMap.getModel().mapViewPosition.setCenter(new LatLong(lat, lon)); } int zoom = mainActivity.mSharedPreferences.getInt(Const.KEY_PREF_MAP_ZOOM, 16); mapMap.getModel().mapViewPosition.setZoomLevel((byte) zoom); createLayers(true); return rootView; }
Example #9
Source File: MapSectionFragment.java From satstat with GNU General Public License v3.0 | 4 votes |
/** * Called when a new location is found by a registered location provider. * Stores the location and updates GPS display and map view. */ public void onLocationChanged(Location location) { // some providers may report NaN for latitude and longitude: // if that happens, do not process this location and mark any previous // location from that provider as stale if (Double.isNaN(location.getLatitude()) || Double.isNaN(location.getLongitude())) { markLocationAsStale(providerLocations.get(location.getProvider())); applyLocationProviderStyle(this.getContext(), location.getProvider(), Const.LOCATION_PROVIDER_GRAY); return; } if (providerLocations.containsKey(location.getProvider())) providerLocations.put(location.getProvider(), new Location(location)); LatLong latLong = new LatLong(location.getLatitude(), location.getLongitude()); Circle circle = mapCircles.get(location.getProvider()); Marker marker = mapMarkers.get(location.getProvider()); if (circle != null) { circle.setLatLong(latLong); if (location.hasAccuracy()) { circle.setVisible(true); circle.setRadius(location.getAccuracy()); } else { Log.d("MainActivity", "Location from " + location.getProvider() + " has no accuracy"); circle.setVisible(false); } } if (marker != null) { marker.setLatLong(latLong); marker.setVisible(true); } applyLocationProviderStyle(this.getContext(), location.getProvider(), null); Runnable invalidator = providerInvalidators.get(location.getProvider()); if (invalidator != null) { providerInvalidationHandler.removeCallbacks(invalidator); providerInvalidationHandler.postDelayed(invalidator, PROVIDER_EXPIRATION_DELAY); } // redraw, move locations into view and zoom out as needed if ((circle != null) || (marker != null) || (invalidator != null)) updateMap(); }
Example #10
Source File: MyMarker.java From EasyVPN-Free with GNU General Public License v3.0 | 2 votes |
/** * @param latLong the initial geographical coordinates of this marker (may be null). * @param bitmap the initial {@code Bitmap} of this marker (may be null). * @param horizontalOffset the horizontal marker offset. * @param verticalOffset the vertical marker offset. */ public MyMarker(LatLong latLong, Bitmap bitmap, int horizontalOffset, int verticalOffset, Object relationObject) { super(latLong, bitmap, horizontalOffset, verticalOffset); this.relationObject = relationObject; }