osmdroid

Add marker to map on tap

谁说我不能喝 提交于 2019-12-07 16:32:41
问题 I'm coding an application using osmdroid to show a map and i would like to add a marker to it when user taps over map, actually i have been able to do this usin motion event but this adds a marker even when user is zooming in or out the map i don't want this. This is the code i have to add the marker: @Override public boolean dispatchTouchEvent(MotionEvent ev) { int actionType = ev.getAction(); switch (actionType) { case MotionEvent.ACTION_DOWN: Projection proj = myOpenMapView.getProjection()

open street maps (osmdroid) shows grey tiles not map in PC

北城余情 提交于 2019-12-07 05:20:57
问题 I am using osmdroid to get open Street maps in my app. I had build my project with the needed jars (osmdroid) and added all needed permissions in the manifest. But when I try to debug my app in android emulator (adt eclipse) I am not able to see the map, only grey tiles. My project is working fine because if I debug in a smartphone I am able to see the map, the problem is only with the emulator. I have done some research but I only found information of google maps solutions but not open

Osmdroid and Pinch

佐手、 提交于 2019-12-07 04:27:40
问题 I'm developing an app using osmdroid (3.0.8). When I zoom using two fingers in and out, the zoom starts from the center of the map, not from the middle of the two fingers (using MapView.setMultiTouchControls(true); ). I've tried to implement the pinch (pinch) but with bad results. I've read other similar questions but without finding a good solution. Note: I MUST use OSM, and not other solutions 回答1: Osmdroid 3.0.10 includes support for zooming at the location you pinched at. The samples also

Detect if the OSM Mapview is still loading or not in android

别说谁变了你拦得住时间么 提交于 2019-12-07 02:50:51
问题 I have included Open Street Maps in my android application. In the mapview, user should be able to capture the screen after the map is fully loaded. But currently user can capture the image even when the mapview is still loading. Can someone tell me how to detect when the mapview is fully loaded? Below is my code to load the mapview: public class MainActivity extends Activity { MapView mapView; MyLocationOverlay myLocationOverlay = null; ArrayList<OverlayItem> anotherOverlayItemArray;

osmdroid displays an empty grid

非 Y 不嫁゛ 提交于 2019-12-07 01:36:54
问题 I wanted to try out having OpenStreetMap integration by osmdroid, but I got stuck at an issue where I have no idea what is missing. The scenario is as follows: Symptom: Map widget gets displayed but only with an empty grid. This is in my Activity class: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MapView mapView = new MapView(this, 256); mapView.setTileSource(TileSourceFactory.MAPNIK); mapView.setClickable(true); mapView

OSMDROID: error: incompatible types: IGeoPoint cannot be converted to GeoPoint

心已入冬 提交于 2019-12-06 17:37:33
I am building a sample OSMdroid app mixing and matching from various sources. In using this sample code , import org.osmdroid.util.GeoPoint; ... private void setOverlayLoc(Location overlayloc){ GeoPoint overlocGeoPoint = new GeoPoint(overlayloc); //--- overlayItemArray.clear(); OverlayItem newMyLocationItem = new OverlayItem( "My Location", "My Location", overlocGeoPoint); overlayItemArray.add(newMyLocationItem); } ... @Override public void draw(Canvas canvas, MapView mapview, boolean arg2) { ... //overlayItemArray have only ONE element only, so I hard code to get(0) GeoPoint in =

How to display the current position pointer in osmdroid?

点点圈 提交于 2019-12-06 12:10:37
问题 I would like to display the current position pointer using osmdroid. getController().setCenter(new GeoPoint(location)); This code does not display the pointer. So is there anything built in for osmdroid as it is for google maps? 回答1: You need to add a MyLocationOverlay somthing like the following. mMyLocationOverlay = new MyLocationOverlay(this, mOsmv, mResourceProxy); mMyLocationOverlay.disableMyLocation(); // not on by default mMyLocationOverlay.disableCompass(); mMyLocationOverlay

Setting min and max zoom levels

喜夏-厌秋 提交于 2019-12-06 12:03:04
Having trouble with the zoom interface using OSMDroid API- can not seem to get the zoom control to zoom beyond level 18. Using a local ( SD card ) custom map cache with levels 12-22. We can zoom from 12 -18, but not beyond. There doesn't seem to be any way to set the min or max zoom. Anyone have any ideas on where this setting is defined? You need to make a class extending MapView, there you can set it by overriding the getMaxZoomLevel() and getMinZoomLevel(), like this: public class CustomMapView extends MapView { /* constructors */ @Override public int getMaxZoomLevel() { return 22; }

Add marker to map on tap

丶灬走出姿态 提交于 2019-12-05 21:15:12
I'm coding an application using osmdroid to show a map and i would like to add a marker to it when user taps over map, actually i have been able to do this usin motion event but this adds a marker even when user is zooming in or out the map i don't want this. This is the code i have to add the marker: @Override public boolean dispatchTouchEvent(MotionEvent ev) { int actionType = ev.getAction(); switch (actionType) { case MotionEvent.ACTION_DOWN: Projection proj = myOpenMapView.getProjection(); GeoPoint loc = (GeoPoint) proj.fromPixels((int)ev.getX(), (int)ev.getY()); String longitude = Double

How to add a setMyLocationEnabled button on OSMap?

时光怂恿深爱的人放手 提交于 2019-12-05 20:01:16
Can we enable a 'GotoMyLocation' button on OSMDroid like mMap.setMyLocationEnabled(true); on GoogleMap? I didn't find such feature in MapView class. Create one of these org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay mylocation = new MyLocationNewOverlay(...); Add it to your MapView mMapView.getOverlays().add(mylocation); Then try mylocation.enableFollowLocation(); To set your current location use, LOCATION_SERVICE of LocationManager. This will listen your gps location and will set your center to the present location. LocationManager myLocationManager = (LocationManager)