MBtiles and mapbox js - mapbox

Currently I am doing graphical information system(GIS) web application that allow user to upload their tileset eg mbtiles format to the system and view tileset using mapbox on browser. Now, I'am just use mapbox studio to upload tileset and take the sytle then copy to the code. My question is, how I want to upload mbtiles files to database and view in mapbox on browser without use mapbox studio
mapboxgl.accessToken = 'accesstoken';
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox style', // stylesheet mapbox style
center: [100.2192660726069, 6.523753293936409], // starting position [lng, lat]
// pitch: 60, // pitch in degrees
// bearing: -60,
zoom: 16 // starting zoom]
});

If your question is how to view your map in the browser outside of Mapbox Studio, you can use the code snippet you have included above and create a container div <div id="map"></div> within the HTML of your page to display the map.
If you are asking how to programmatically upload your MBTiles file and add the tileset to an existing style without the use of Mapbox Studio, you will want to look into the Uploads or Tilesets API and Styles API.
For uploading the MBTiles file, you can work with the Create an upload endpoint or the Tilesets API.
To then add the uploaded tileset to a style, you can use the Update a style endpoint or add it at runtime to the map using the addLayer GL JS method.

Related

GeoTiff style layers shows up with black borders in Android

We uploaded a set of "floor plans" to Mapbox in GeoTiff format. While layers show up fine in Mapbox Studio, the layers appear to have a huge black background surrounding it's rendered area.
This is how it looks in Studio
And this is how it appears in out app
We tried following the guide on documentation yet we don't understand it quite clearly:
This is the current code in charge of the map loading
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
#Override
public void onMapReady(#NonNull MapboxMap mapboxMap) {
mapboxMap.setStyle(new Style.Builder().fromUri("mapbox://styles/gustavjohannson/ckpzb9eop05mq18qviptlbm5d"), new Style.OnStyleLoaded() {
#Override
public void onStyleLoaded(#NonNull Style style) {
I just resolved this same exact issue. Check out this link.
https://docs.mapbox.com/help/troubleshooting/raster-transparency-issues/
It gives a useful example for android.
Basically you have to use a standard style like SATELLITE_STREETS or STREETS or whatever you choose. But do NOT embed your map overlay into the style. You want to add your overlay as a Raster Source tileset directly in your android code.
Here's what my code looks like:
mapboxMap.setStyle(Style.Builder().fromUri(Style.SATELLITE_STREETS)) {
loadedMapStyle.addSource(RasterSource("source-id",
TileSet( "tileset-id", "https://api.mapbox.com/v4/HERE I PUT MY TILESET ID/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoidG9tbXlib21iIiwiYSI6ImNqZXg5NHZlcjB6czEyd3J5MnAxZDdieGYifQ.GUqv9fHb__o5Xq8DLdNnnA"), 256))
loadedMapStyle.addLayer(RasterLayer("raster-layer", "source-id"))
}
Remember...In Mapbox Studio... Instead of creating a custom style with your map embedded, create a custom Tileset with your map and use that tileset id in your android code.

Is there a way to add a custom icon to map's Mapbox?

I might have skipped some documentation about flutter_map plugin, but I could not find any way to use a simple .png image as a custom icon for a Mapbox marker?
Should I maybe use another plugin? Or is there a way to do what I attempted to do?
You can do that with the mapbox_gl plugin by calling
MapboxMapController.addSymbol(
SymbolOptions(
geometry: LatLng(latitude, longitude),
iconImage: iconImage,
);
You can use the name of one of your asset images as iconImage or the name of one of the icons included in your style (e.g. 'defaultMarker' should be included in every style).
There is also an example of this in the place_symbol.dart file of the plugin's example project.

Open Street Map Web Wizard Usage

Why does a pink screen appear when OSM Web Wizard is invoked from SUMO?
I have attached the image below.
OSM WEB view page
There seems to be a problem with loading the OpenStreetMap tiles. We recently had a proposed fix for using https instead of http when loading the tiles. You could try to apply this patch https://github.com/eclipse/sumo/commit/3da7939ea19b246fb845267aa60f0d23ce66908a or simply replace manually in tools/webWizard/script.js
the line
map.addLayer(new OpenLayers.Layer.OSM);
with
var maplayer = new OpenLayers.Layer.OSM("OpenStreetMap",
// Official OSM tileset as protocol-independent URLs
[
'https://a.tile.openstreetmap.org/${z}/${x}/${y}.png',
'https://b.tile.openstreetmap.org/${z}/${x}/${y}.png',
'https://c.tile.openstreetmap.org/${z}/${x}/${y}.png'
], null);
map.addLayer(maplayer);

Mapbox uploading background image

I'm trying to change the background of my map and put an image instead of it.
I'm currently using map box studio so when I'm choosing a local path
(c\deskstop\toto.png), it is working on the software, so if I choose to upload my whole map style, and use my map on the internet, it doesn't work.
I choose to upload the picture in my website then I changed the URL of the path too ( toto.com\pictures\toto.png). but it is till not working
Does someone has already this problem with mapbox?

Cannot find Mapbox Vector Tile URL for my Mapbox Style map

Does anyone know how to get the URL for a Mapbox vector tile map (aka a "style")? I can only get a style address that looks like this: mapbox://styles/myusername/r3411y10ngh4sh3tc3tc, but I am using a plugin that requires a URL to integrate Mapbox's Vector Tiles with Leaflet: https://github.com/SpatialServer/Leaflet.MapboxVectorTile/blob/master/docs/configuration.md
I tried substituting the style address provided by Mapbox for the URL
var config = {
url: "mapbox://styles/myusername/fwaoij32wlfij23slkfj3",
...etc
};
var mvtSource = new L.TileLayer.MVTSource(config);
map.addLayer(mvtSource);
but I get an error where it can't read the style address as a URL. Any suggestions? Should I be using a different plugin?
Update
In short, the URL for a Mapbox style is not yet available. Here is a response I received from Mapbox:
Leaflet is not yet compatible with styles made in Mapbox Studio since these styles require a GL-based renderer. We're currently working on a new API to allow you to use your Studio style with Leaflet, we expect it to launch in a few weeks.
At this time, you can use Mapbox GL JS to load your Mapbox Studio style. You can still access raster map IDs (maps made with Mapbox Editor, Mapbox Studio Classic) to load with Leaflet - these are found under the "Classic" tab in the Studio dashboard.
The Leaflet.MapboxVectorTile plugin uses a different approach to styles than, for example, the Mapbox GL JS library does.
Styles you create in Mapbox Studio can be downloaded as JSON, but for Leaflet.MapboxVectorTile you have to create them programmatically as you can see in the documentation. You can still use their vector tile URL https://b.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/{z}/{x}/{y}.vector.pbf?access_token=<public api token>, but styles would probably have to be rewritten/done from scratch again.
You can use the Mapbox Gl Javascript to create a map with the style you created, but I don't know how extensive your current project is and if it would conflict with other (Leaflet) plugins:
mapboxgl.accessToken = '<public API token>';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/<your name>/<style id>',
center: [-74.50, 40],
zoom: 9
});