MapBox mapview repeat padding in screen - android

I use MapBox Android SDK 0.7.2 to get tiles from MapBox web service:
WebSourceTileLayer webSourceTileLayer = new WebSourceTileLayer("MapBox", "http://api.tiles.mapbox.com/v4/examples.map-zr0njcqy/-73.99,40.70,13/256x256.png?access_token=<my key>");
webSourceTileLayer.setName("MapBox")
.setAttribution("© MapBox © OpenStreetMap")
.setMinimumZoomLevel(1)
.setMaximumZoomLevel(18);
mapView.setTileSource(webSourceTileLayer);
mapView.setZoom(12);
mapView.setCenter(mapView.getTileProvider().getCenterCoordinate());
so I get back a 256x256 png format tile. But the tile repeats in the screen while I suppose it should be one tile in the screen. Any suggestion is appreciated.

Are you looking to just download the one tile from the Mapbox Web Service API? If so using a regular Android HTTP client (ex: URLConnnection class) to download it and then paint it on the Canvas would serve this better. TileLayers like WebSourceTileLayer are meant to download many different tiles and display them on the MapView as described.

Related

Can Mapbox's MapSnapshotter be used to generate a bitmap containing annotations?

I'm attempting to use MapSnapshotter (a part of the Mapbox Maps SDK for Android) to generate a screenshot of a Mapbox map instance, including a single line annotation that I've added to the map.
I seem to be able to generate a static map bitmap as expected, however the image does not contain my line annotation.
Is there a way of having the line appear in the bitmap that MapSnapshotter generates, or is MapSnapshotter limited to capturing map screenshots sans annotations?
I'm using the example code provided in one of Mapbox's repositories for the moment. The only alterations that I've made are to add a new layer and source to the Mapbox map style such that it is displayed on the interactive Mapbox map.
In order to have any symbols/geometries visible on the snapshot taken with the MapSnapshotter, the desired layers would have to be added directly to the style. Alternatively, you can draw on top of the image like in this example, which adds a marker to a snapshot.
Another way is to render a normal, interactive map and take a picture of it with MapboxMap#snapshot.
Please tell how to add the desired layer directly to the style according above answer?
I added my custom symbol layer to mapbox style, but snapshot does not make bitmap with symbols.
FeatureCollection featureCollection = FeatureCollection.fromJson(geoJson);
Source source = new GeoJsonSource("my.data.source", featureCollection);
mapboxMap.addSource(source);
SymbolLayer myLayer = new SymbolLayer("my.layer.id", "my.source.id");
myLayer.withProperties(PropertyFactory.iconImage("my.image"));
mapboxMap.addLayer(myLayer);
// ...
MapSnapshotter.Options snapShotOptions = new MapSnapshotter.Options(500, 500);
snapShotOptions.withRegion(mapboxMap.getProjection()
.getVisibleRegion().latLngBounds);
snapShotOptions.withStyle(mapboxMap.getStyle().getUrl());
MapSnapshotter mapSnapshotter = new MapSnapshotter(this, snapShotOptions);
Thank you.

how to set alarm to osmdroid when closer to boundary

I am developing an application in which I need to use maps offline. I'm using osmdroid and osmbonuspack
I have implemented code to display user's current location. And display boundary by importing KML content.
How can I set alarm to notify user, when user come closer(about 50m-100m) to that boundary?Click to see the image
You can buffer the area by (50m, 100m) and use LocationManager #addProximityAlert() to set a trigger.

How to Implement Google Map Tile Provider in android?

I am working on custom map app and i want to use google map tiles for background ? There is one class TileProvider in api but i don't know how to initialize it every time i try it goes something like this ?
TileProvider tileProvider=new TileProvider() {
#Override
public Tile getTile(int i, int i2, int i3) {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
};
how to override getTile function to get tiles from google map server?
Any example will be appreciated ?I know getTile function need x,y and zoom value to return tile.
So quick answer is that you can get the Google Map tiles from the following URL:
http://mt1.google.com/vt/lyrs={t}&x={x}&y={y}&z={z}
Where {t} is the type of map (satellite, road, hybrid, etc) and the other attributes are specifying the coordinates and zoom level.
The possible values for {t} are as follows:
Default - m
Roads only - h
Roads simplified - r
Satellite - s
Satellite hybrid - y
Terrain - t
Terrain hybrid - p
That being said you do want to make sure what you're doing is NOT a violation of the terms & services. Specifically Google WILL allow you to cache their tiles provided that you are doing so ONLY in order to improve performance and that you delete their tiles at least every 30 days, and finally you don't pull down their tiles in an attempt to make your own mapping service.
You may want to read the Google Maps Terms of Service - https://developers.google.com/maps/terms - specifically section 10.1.1

Optimal path between source and destination - android

I'm new to android development and I've done some applications involving Google maps. What I'm trying to develop now is an Optimal Path Finder App. I know that there are many application already available for this purpose, but I plan to do this on my own. I'm planning to use Dijkstra's algorithm for this purpose. The initial input is the source and destination, and the output must be the optimal path drawn on a Google map between the source and destination. I've an idea about the steps needed to do this application.
Step 1 : Extract the intermediate places between the source and destination.
Step 2 : Add these nodes to a graph data structure.
Step 3 : Apply Dijkstra's Algorithm and find the path.
Step 4 : Draw the path on a Google map.
Am I thinking in the right way?
Yes you're thinking in the right way :) ! Also consider openstreetmaps for the data source and mapsforge as an offline map tile provider.
Try this:
1.put ruledijkstra.html onto folder asset
2.load using this code:
private void getLocation(){
WebSettings webSettings = mWebView.getSettings();
mWebView.loadUrl("file:///android_asset/maps.html");
String path="javascript:loadAtStart(-6.184505,106.797685,11)";
mWebView.loadUrl(path);
}
3.code for asset:
ruledijkstra.html or you can google:etc
http://www.zlink.com.br/optimap/index.php?&loc0=-7.1209077392192785,-34.9075984954834&loc1=-7.121418750873643,-34.903221130371094&loc2=-7.128828355854018,-34.93025779724121

Google Maps advanced features in a MapActivity (Google Maps API)

I wanted to load a custom KML file on the map. I chose the simple way:
Intent mapIntent = new Intent(Intent.ACTION_VIEW, url);
And it works well, but obviously I can't control various features like custom icons for overlay items, or the popup "Loading myKml.kml..." that shows everytime I start it, etc.
First question:
Aren't there any parameters to setup when I start a Google Maps Intent, to tweak my map? I can't find anything on the documentation.
So I was thinking about using the Google Maps API for my app. Well, I've managed to load my KML file parsing it with a SAX parser and creating a custom overlay for my map.
It works, but there is a great problem:
The placemarks aren't loaded dynamically in relation to my position. They are loaded from the start to the end, and are shown on the map 100 at time.
So it was going to be harder than I thought, because I'll have to get my position from the GPS and calculate only the nearest points and draw them on the map.
Second question:
Does exist a built-in function to show only near-to-me placemarks on the map?
Thank you, guys.
2nd question. No. Have a look at LocationManager.addProximityAlert(double latitude, double longitude, float radius, long expiration, PendingIntent intent).

Categories

Resources