Well, thats the question, I thought that it would be possible to do something like map.setSatellite(true); but is not possible in OSMdroid.
Another trouble is if its possible to download maps, because I need to work offline, and my boss says that it should be possible to download the maps.
The only way I know to use offline maps is making the maps with mobac and then manually store them to consult.
I have read something about using bing, but im not sure, do you know another way to do it?, I guess I will need to be online to work with bing libraries. Am I right?
I know it's too late to post this answer but for others, it will help
OpenStreetMap(OSM) does not offer any aerial imagery layer(satellite view). But using MAPBOX we can achieve satellite view in OSM.
To do this use the following code snippet:
Add this meta data in AndroidManifest
<meta-data
android:name="MAPBOX_MAPID"
android:value="satellite-streets-v11"/>
<meta-data
android:name="MAPBOX_ACCESS_TOKEN"
android:value="PUT_YOUR_MAPBOX_ACCESS_TOKEN"/>
Create MapBoxTileSourceFixed.java class as follow
//waiting for osmdroid #1718 to be fixed:
class MapBoxTileSourceFixed extends MapBoxTileSource {
MapBoxTileSourceFixed(String name, int zoomMinLevel, int zoomMaxLevel, int tileSizePixels) {
super(name, zoomMinLevel, zoomMaxLevel, tileSizePixels, "");
}
#Override public String getTileURLString(final long pMapTileIndex) {
StringBuilder url = new StringBuilder("https://api.mapbox.com/styles/v1/mapbox/");
url.append(getMapBoxMapId());
url.append("/tiles/");
url.append(MapTileIndex.getZoom(pMapTileIndex));
url.append("/");
url.append(MapTileIndex.getX(pMapTileIndex));
url.append("/");
url.append(MapTileIndex.getY(pMapTileIndex));
//url.append("#2x"); //for high-res
url.append("?access_token=").append(getAccessToken());
String res = url.toString();
return res;
}
}
And finally set MapBoxTileSource in mapview as follow
OnlineTileSourceBase MAPBOXSATELLITELABELLED = new MapBoxTileSourceFixed("MapBoxSatelliteLabelled", 1, 19, 256);
((MapBoxTileSource) MAPBOXSATELLITELABELLED).retrieveAccessToken(this);
((MapBoxTileSource) MAPBOXSATELLITELABELLED).retrieveMapBoxMapId(this);
TileSourceFactory.addTileSource(MAPBOXSATELLITELABELLED);
map.setTileSource(MAPBOXSATELLITELABELLED);
map.getOverlayManager().getTilesOverlay().setColorFilter(null);
Output:
see original repository here
Enjoy coding :)
You can use this code for google map satellite view
getMap().setMapType( GoogleMap.MAP_TYPE_SATELLITE );
and you can take refrence from this link also for implementing google map
https://code.tutsplus.com/tutorials/getting-started-with-google-maps-for-android-basics--cms-24635
and for the google map download you can use this reference
https://stackoverflow.com/a/19184812/6869491
I hope it will help you
You can use MapBoxTileSource, with mapbox.streets-satellite as MAPBOX_MAPID.
You will have to request an Access Token on MapBox site.
OnlineTileSourceBase MAPBOXSATELLITELABELLED = new MapBoxTileSource("MapBoxSatelliteLabelled", 1, 19, 256, ".png");
((MapBoxTileSource) MAPBOXSATELLITELABELLED).retrieveAccessToken(this);
((MapBoxTileSource) MAPBOXSATELLITELABELLED).retrieveMapBoxMapId(this);
TileSourceFactory.addTileSource(MAPBOXSATELLITELABELLED);
mapView.setTileSource(MAPBOXSATELLITELABELLED);
And in the manifest:
<meta-data
android:name="MAPBOX_MAPID"
android:value="mapbox.streets-satellite"/>
<meta-data
android:name="MAPBOX_ACCESS_TOKEN"
android:value="... YOUR MAPBOX ACCESS TOKEN HERE ..."/>
Related
I am attempting to show the title of a map marker using Here Maps.
According to this SO question, the showInfoBubble() is deprecated. And the link it contains goes 404.
However, the official documentation does not show it as deprecated.
My map will always just show two or less locations. And I wanted to show the info bubble with the title. However, showInfoBubble() isn't a method of the MapMarker class despite being shown as one.
I have searched the official GitHub for examples, however I cannot find anything on showing the title.
Has anyone figured this out? Or can you point me to an example or the correct documentation?
private void addMarkerAtPlace(GeoCoordinate marker, String title, String description, Image icon) {
MapMarker mapMarker = new MapMarker();
mapMarker.setIcon(icon);
mapMarker.setCoordinate(new GeoCoordinate(marker));
mapMarker.setTitle(title);
mapMarker.setDescription(description);
m_map.addMapObject(mapMarker);
m_mapObjectList.add(mapMarker);
//Show Title can only be shown after being added to the map
//however this doesn't work!!!
mapMarker.showInfoBubble();
}
Summary: A comment about the deprecation: You refer to the Starter SDK version 3.x, but the linked SO question was about the Premium SDK. Two different products at the moment. Deprecation seems to be the case only for the Premium edition (where MapOverlays have been introduced, what's also not available in Starter as far as I can see).
See current overview for the SDKs over here: https://developer.here.com/products/here-sdk
I'm novice at Xamarin and I'm trying to use ShinobiCharts in Xamarin.Android to show candlestick data on it.
Code from .axml:
<fragment
class="com.shinobicontrols.charts.ChartFragment"
android:id="#+id/chart"
android:layout_width="match_parent"
android:layout_height="match_parent" />
This is fragment where should be shown chart.
var chartFragment = (ChartFragment)FragmentManager.FindFragmentById(Resource.Id.chart);
var chart = chartFragment.ShinobiChart;
chart.SetLicenseKey("license_key");
chart.AddXAxis(new DateTimeAxis
{
GesturePanningEnabled = true,
GestureZoomingEnabled = true
});
chart.AddYAxis(new NumberAxis
{
GesturePanningEnabled = true,
GestureZoomingEnabled = true
});
var dataPoints =
quotes.Select(
quoteCandle =>
new MultiValueDataPoint(DateUtils.ConvertToJavaDate(TimeStamp.UnixToDate(quoteCandle.Timestamp)),
(double) quoteCandle.Low, (double) quoteCandle.High,
(double) quoteCandle.Open, (double) quoteCandle.Close)).ToList();
var series = new OHLCSeries { DataAdapter = new SimpleDataAdapter() };
series.DataAdapter.AddAll(dataPoints);
chart.AddSeries(series);
chart.XAxis.Style.GridlineStyle.GridlinesShown = true;
chart.YAxis.Style.GridlineStyle.GridlinesShown = true;
chart.RedrawChart();
This is code of creating ShinobiCharts.
The problem is that added series are not shown in chart. Style changed, but there are no series. What do I do wrong? I hope anyone can help.
Sorry for question, Candlestickes are not available for trial version of ShinobiControls, only for premium version.
As sammyd said, CandlestickSeries are available in the trial version of ShinobiCharts for Android (as are all the other premium features). Have you managed to get the CandlestickChart sample running? The sample is included in the download bundle.
On the face of it your code looks fine (without seeing the rest of it) but there are a couple of things I'd recommend checking:
Have you replaced the string license_key with the trial license key we would have emailed you when you downloaded the bundle? The trial license key is a a really long string of characters and digits.
Is your data coming in as expected and does it make sense (e.g. are your low values less than your open values etc.)?
I'm not sure it'll make much difference, as they're pretty much interchangeable, but you're actually creating an OHLCSeries in code but mention a CandlestickSeries
Have you set the series' style object in a way that would stop it from showing i.e. have you set it to be transparent in colour?
Are you getting an actual error, and if so what message is being logged?
Hopefully the above will help you get your candlestick chart up and running!
Edit:
If you're using the Android Emulator, your AVD needs to have GPU emulation turned on (as we use OpenGL ES 2.0 for rendering the charts). There's more information on using the emulator with OpenGL on the Android developer site.
Disclaimer: I work for ShinobiControls
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
How can i display MapBox tiles on Android ? I tried using it with OSMDroid, and Nutiteq with no success. Is there a android library for MapBox ?
For example i used this code to implement MapBox on OSMDroid : http://blog.spatialnetworks.com/post/2012/07/using-mbtiles-on-android-with-osmdroid
XYTileSource MBTILESRENDER = new XYTileSource("mbtiles", ResourceProxy.string.offline_mode, 1, 20, 256, ".png", "http://example.org/");
DefaultResourceProxyImpl mResourceProxy = new DefaultResourceProxyImpl(this.getApplicationContext());
SimpleRegisterReceiver simpleReceiver = new SimpleRegisterReceiver(this.getActivity());
File f = new File(Environment.getExternalStorageDirectory(), "mymbtilesfile.mbtiles");
IArchiveFile[] files = { MBTilesFileArchive.getDatabaseFileArchive(f) };
MapTileModuleProviderBase moduleProvider = new MapTileFileArchiveProvider(simpleReceiver, MBTILESRENDER, files);
MapTileProviderArray mProvider = new MapTileProviderArray(MBTILESRENDER, null, new MapTileModuleProviderBase[] { moduleProvider });
this.mMapView = new MapView(this, 256, mResourceProxy, mProvider);
But it didn't work, i want to load MbTiles directly from the web.
Edit
Official Mapbox Android SDK is released.
Also, see Mapbox's answer.
To people who downvote, I answered the question before the sdk exists.
=============================================
I think Nutiteq looks pretty promising. Their API has a lot of features. Also, their demo projects are inline commented. You can check out this project. Especially, MBTilesMapActivity might be something that you're looking for. The class shows how to work with mbtiles:
// 1. Get the MapView from the Layout xml
mapView = (MapView) findViewById(R.id.mapView);
// 2. create and set MapView components
Components components = new Components();
mapView.setComponents(components);
// 3. Define map layer for basemap
MBTilesMapLayer dbLayer = new MBTilesMapLayer(new EPSG3857(), 0, 19, file.hashCode(), file, this);
mapView.getLayers().setBaseLayer(dbLayer);
...
// 4. Start the map - mandatory
mapView.startMapping();
// 5. zoom buttons using Android widgets - optional
// get the zoomcontrols that was defined in main.xml
ZoomControls zoomControls = (ZoomControls) findViewById(R.id.zoomcontrols);
You can also take a look at my toy project which is modified from their demo. Basically, my app allows the user to input a url of a mbtiles file. Then, it downloads the file and loads it to the MapView.
If you really have to stick with OSMDroid, this might be helpful. I haven't had a chance to try it though.
Hope this helps.
Is there a android library for MapBox ?
The best way to use Mapbox on Android is the Mapbox Android SDK! It's the official codebase, an open source project that supports vector tiles, map animation, and a bunch else - and it's also designed to be easy to transition to from the system default maps.
Re:
But it didn't work, i want to load MbTiles directly from the web.
Since an MBTiles file is a bundle of tiles that's usually quite large - and can't be requested individually - you usually won't load it directly just to show a map. The approach that the SDK takes is dynamic caching, as shown in this example. The example uses Mapbox, but the caching mechanism is general and would work with any tile server.
Disclosure: I work for Mapbox, and occasionally work on the core of our native code, including the Android SDK.
Did you know that with the Google Maps API v2, you can use your own tiles provider?
See TileProvider and UrlTileProvider.
Mapbox team has started pre-alfa release of Mapbox maps on Android, so I would like to recommend it, just to try. I assume it's good to know that they have heard prayers of android developers.
Mapbox for Android on Github
OSMDroid is terribly documented, but the way they designed it makes it very flexible and self-explanitory if you look at the implementable methods. Here is how you use Mapbox tiles with OSMDroid as of January 2015.
mvMap = (MapView) rootView.findViewById(R.id.mapview);
String mapCode = "mapbox.streets";
final String accessToken = "myAccessToken";
OnlineTileSourceBase customTileSource = new XYTileSource("MapBoxSatelliteLabelled",
ResourceProxy.string.mapquest_aerial, 1, 19, 256, ".png", new String[]{
"http://a.tiles.mapbox.com/v4/" + mapCode + "/",
"http://b.tiles.mapbox.com/v4/" + mapCode + "/",
"http://c.tiles.mapbox.com/v4/" + mapCode + "/",
"http://d.tiles.mapbox.com/v4/" + mapCode + "/"}){
#Override
public String getTileURLString(MapTile aTile) {
String str = super.getTileURLString(aTile) + "?access_token=" + accessToken;
return str;
}
};
TileSourceFactory.addTileSource(customTileSource);
mvMap.setTileSource(customTileSource);
Quick tip: If you're using Android Studio, use break points to get the value of any variable. This helps with debugging and understanding unfamiliar code. That's how I figured out that getTileURLString() returns the full URL of the tile.
I am trying to develop an offline android map that makes use of OSM map tiles of a particular zoom level, For this purpose I used an open source library : Osmdroid
Now, I am looking into the possibility of creating an offline geocoding/ reverse geocoding for a single city that can be integrated with my application,
can I use Osm xml data for that purpose? if so , then can anyone suggest/explain how to use it to create SQlite db.. to be used with my app
I read here and also here about Spatialite
But cannot quite understand its working and implementation
Thanks
With the Skobbler SDK you have offline maps and (reverse) geocoding.
This has an answer in here
https://stackoverflow.com/a/64811929/13794189
and goes as follows:
To use Open Street Maps (OSM) in offline mode you need to first implement a download manager like the one shown here on the post liked bellow. It has resume capabilities which is good for very large files :
https://stackoverflow.com/a/64811752/13794189
next you can load the downloaded OSM maps file in to a mapView like this:
org.osmdroid.config.IConfigurationProvider osmConf = org.osmdroid.config.Configuration.getInstance();
File basePath = new File(SessionData.offlineMapsDirectoryPath, "osmdroid");
osmConf.setOsmdroidBasePath(basePath);
File tileCache = new File(SessionData.offlineMapsDirectoryPath, "tile");
osmConf.setOsmdroidTileCache(tileCache);
map = (MapView) getActivity().findViewById(R.id.map); // create basic map
//map.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
map.setTilesScaledToDpi(true);
map.setMultiTouchControls(true);
map.setUseDataConnection(false);
// add compass to map
//CompassOverlay compassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), map);
//compassOverlay.enableCompass();
//map.getOverlays().add(compassOverlay);
//attach listeners
MapEventsOverlay mapEventsOverlay = new MapEventsOverlay(this);
map.getOverlays().add(0, mapEventsOverlay);
In the code above, SessionData.offlineMapsDirectoryPath is the path where the downloaded file is saved.
Don't forget to add in your gradle file the following implementations:
implementation 'org.osmdroid:osmdroid-android:6.1.0'
implementation 'com.github.MKergall:osmbonuspack:6.6.0'
I'm making an app on android, using webview to load google map (using this url for my webview: http://gmaps-samples.googlecode.com/svn/trunk/articles-android-webmap/simple-android-map.html).
but i can't put a marker on that webview, can't somebody tell me how?
http://maps.google.com/maps?saddr=37.423156,-122.084917
The above simply shows the directions screen with missing destination field. If you want the pin to show on a simple map screen do this instead:
http://www.google.com/maps?q=37.423156,-122.084917
Clearly lots of ways to skin a cat - but I am loving the Google Static Maps API.
It generates a standard image (of desired size) and you can add points/lines/polygons all from a URL.
Whilst I haven't checked the terms, it is clearly possible to cache/store the result.
Documentation: http://code.google.com/apis/maps/documentation/staticmaps/
Example: http://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Ccolor:red%7Clabel:C%7C40.718217,-73.998284&sensor=false
http://maps.google.com/maps?saddr=NJ
load URL like this pass address where you want to put the pin