how to export a mapbox studio map as .mbtiles file - export

So I'm guessing the answer to this is "no", but is there any way to export a map I've designed online with mapbox studio (https://www.mapbox.com/studio/) into a .mbtiles file so I can host it myself?
Honestly, I'd be willing to pay money for this (saving me the trouble of getting a world .pbf file and getting it into a postgresql db is really a pain, especially with a mediocre computer like mine)
It sounds like maybe there used to be a way to do this, but as of now it looks like they've taken away this ability. I can see a lot of different ways to use a map I've created, but everything forces me to use mapbox as the hosting service... it seems there's no way to download a map I've created.

I think your assumption is correct. It does seem MapBox wants you to use their APIs and API keys.
However, there is a partial solution with raster tiles if you can fallback to that. Or you can get vector mbtiles from OSM data instead of from mapbox servers.
mapbox offline support for android/ios
I've contacted mapbox support in April 2017, and what I've been told is that although the style files that you can download from MapBox studio don't contain tiles, there's a way to have them render offline on Android/iOS.
If you would like to use Mapbox maps offline, you would need to follow the examples shown for Android or iOS, depending on your platform. Essentially, the mobile SDKs take in a style URL that points to your custom style created in Mapbox Studio, and the SDKs handle the downloading of all other resources needed to keep the map offline (fonts, icons, tilesets, etc). Check out our guide on offline maps to read more about how this works.
Links:
Offline Maps with MapBox
Mapbox Android-SDK Offline example
Mapbox iOS-SDK Offline Example
From a quick look at the example code, it would seem that the downloading of the tiles is done within the App, but done ahead of time, for instance just after you install the app and you still have
network connectivity. I don't immediately see whether or not your Mapbox API keys are involved at all in this download, with respect to your billing concern. There is a 6000 offline tile limit per offline region.
Not for desktop: The site also mentions that offline is not an option for MapboxGl-JS, so you'd have to hack it up to make your offline region available on desktop web browsers.
mapbox studio export as mbtiles...
There was supposedly a non obvious option in settings to download your source as an mbtiles file in mapbox studio classic. A mapbox classic issue on github has a screenshot of where the button should be. It's possible that option is gone now.
That github project, https://github.com/klokantech/vector-tiles-sample, provides links to projects/tools that can break the mbtiles file into its contained pbf files, which are a protobuf compressed format for each vectorial tile (https://github.com/mapbox/mbutil). Slightly outdated.
An approach which might otherwise work, is to cache the network requests ahead of time for each tile retrieved from MapBox, and then in your APP proxy the requests to your cache. I'm not sure whether that's against the ToS though. You'd probably have to do it programmatically with all XYZ coords you wish to cache.
Taking a dive with tippecanoe to produce vector tiles
You can create vector tiles with tippecanoe (and host them yourself). It's not MapBox, I know. But it might get your farther in the long run.
Nice short blog article about it: http://fuzzytolerance.info/blog/2017/02/02/Making-your-own-tiles-with-Tippecanoe/
The mbtiles you create, you can layer them, and possibly style them with the open source maputnik (which is somewhat like the style editor of mapbox). Then you take serve mbtiles with your own server, and plug in your style into mapboxGL-js or openlayers.
TileMill -- (.mbtiles with raster tiles) fallback
There is TileMill which is still available (but deprecated), runs on the desktop, and will allow you to create maps from shapefiles (e.g. you can get openstreetmap shapefiles for single cities at https://mapzen.com/data/metro-extracts/ ).
TileMill, will give you a mbtiles file at the end of the process. Although, that mbtiles contains raster tiles, not vector tiles. Vector tiles can be styled dynamically so it's nice on mobile when you want to accommodate various situations with fonts or adapt lighting.
Raster tiles might suffice, because in your app you probably will be able to render other interactive objects on top of that base layer. OpenLayers is one portable framework where you'd be able to do that, for instance -- allowing the user to draw objects or click points of interest that you've loaded from a database separately from the map data.
Get OSM-based vector tiles instead of mapbox
There seems to be an alternative maker of Vector tiles now, http://openmaptiles.org (used to be http://osm2vectortiles.org ).
You can go here, and download an mbtiles file for a city of your choice for instance: https://openmaptiles.org/downloads/#city , then serve that file (locally) for your app with a tile server. (or use one of the tools mentioned above to break it into the individual pbf files and read the files from local disk / memory)
With this approach, you combine a vector mbtiles from OSM, with the style you've created in mapbox studio (mapbox studio lets you download a zip file with your .json style in it), and you can still use MapBoxGL to display it.
There's Maputnik http://maputnik.com/ which you can use to edit a mapboxgl style file (the editor works with local storage). and there's presumably https://github.com/boundlessgeo/ol-mapbox-style which allows you to convert that style into a piece of code suitable for OpenLayer's style API.

As far as I know Mapbox does not provide map downloads. You could download vector maps directly using their vector tiles API and be charged against your vector tile count. 200K tiles are free per month. In my experimentation, 80K tiles represent about 200 sqaure km of area. So you'd run out of free tiles very quickly for large areas and would have to pay 1$ per about every 10km more of square km area. (all very approx values based on nominal observation). Also, these leaves the challenge to actually package the .mvt files into a MBTiles format.
I suggest an alternative way instead.
You can create MBTiles from any .osm.pbf file using this tool - https://github.com/systemed/tilemaker
Download .osm.pbf file from Geofabric. To download for a custom area, you can use Protomaps or BBBike Extract
Download tilemaker
Execute the following command
tilemaker --input netherlands.osm.pbf --output netherlands.mbtiles --process resources/process-openmaptiles.lua --config resources/config-openmaptiles.json
You can read more about it in this blog post - https://blog.kleunen.nl/blog/tilemaker-generate-map
To use the same style that you created in Mapbox Studio, you can download your style's JSON file by clicking on Share -> Download. This zip will contain your JSON file which describes all the colors, etc you customised.
If you are planning to show this MBTile on Android app, you'll just have to embed this JSON that you downloaded and the MBTiles file in the app and point the JSON to the MBTiles file. I've written how to do this in this blogpost. I tried to make the JSON work but only partly succeed after some edits. However ideally it should work since its based on the openmaptiles schema.

Related

GreatMaps (GMap.net) Offline Files...To Download?

I'm trying to create a map viewer for an existing C# WinForms application. I've installed and hooked up the GreatMaps (GMap.net) controls no problem and that's all working fine. The quirk in this is that it needs to work offline (as it's an application that gets used by users who aren't always in locations where there's a mobile signal).
The offline cache mode works fine for GMap but, we've got to build the cache beforehand which we can do but, as we need the whole of the UK, will be a pain (especially as we have to go down to street level).
Does anybody know if there any existing cache files that we can download and use? I've looked at downloading OSM files but haven't got the faintest idea how to use them, convert them (into the gmdb format that GMap seems to use).
Any ideas?
Check out VectorTileRenderer (https://github.com/AliFlux/VectorTileRenderer) which has a demo for Gmap.net. All you need is an MBTiles file which you can download for free at OpenMapTiles.org (https://openmaptiles.com/downloads/europe/british-isles/)

Will CodenameOne ever support saving images and / or files to a place users can access outside the app?

I've read a few threads where this is discussed. Shai's response has always been that files can only be read, but not written into shared locations
Perhaps saving other type of files isn't so simple but shouldn't there be an option for saving pictures in CN1?
I haven't seen the Whatsapp Clone code, but if it truly is a clone shouldn't it have the option to share pictures (and possibly files). Or is it a simple text chat that perhaps shares pictures that can never be saved outside the app?
I also read somewhere (6 months ago) that Shai said that this should be a feature of CameraKit. Does this mean that this feature is in development? If so, that would be great. But having an ETA would also be great to align with our own devs
If it isn't being developed, can I at least know if this is something I can develop natively within CN1?
We expose the full file system so you can write to any place the native App can write to. Native apps don't have write access to the gallery directory and need to explicitly request it to put a file there. This can be accomplished easily in any external cn1lib (e.g. we could do it in camera kit) but haven't done it for camera kit or the whatsapp clone.
AFAIK there's no RFE open on this feature so I can't even tell you if it's assigned to a specific milestone.

OSM 3d tileset JSON file

I am using Cesium, and I would like to make a 3d city representation.
I would like to retrieve a .json of the current location I am from OpenStreetMap.
I have the position and the altitude of where I am.
The problem is that I do not understand/can't find from which url source I can retrieve buildings ID and their relative height for a defined tileset position in openstreetmap
I found a lot of exemple on internet and lib that do this, but I need to do it from source, and I do not quite know how.
Basically, how does for exemple this : https://osmbuildings.org/ get the data from
OSM has the data that's necessary to set up such a service, but the various providers use different formats as there's not really a clear standard yet (unlike with 2D raster and, arguably, vector maps). For use with Cesium, you probably want Cesium 3D Tiles.
Cesium is offering their own building layer based on OSM data, called Cesium OSM Buildings (no relationship with OSM Buildings), on their Cesium Ion platform. It does not fully support the OSM data model at this point, but the Cesium integration is obviously well done.
I'm not sure what OSM Buildings is currently using, but it does not seem to be the same as Cesium's 3D Tiles. Some older info on GitHub mentions using GeoJSON, but looking at the network traffic, it now seems to be using Mapbox Vector tiles, which is not a format specialized for 3D data, but rather a general-purpose solution for transmitting OSM data (and other data sources) as tiled vector maps. On osmbuildings.org/data, they mention that they are willing to provide data in other formats for commercial customers, though, if that's an option for you.
Finally, some people have experimented with providing OSM for Cesium using open source software (see e.g. the osm-cesium-3d-tiles and osm2cesium repos). This might be a starting point for setting up your own service if you're willing to go down that path, but it's definitely not a complete and polished solution at this point.

Hosted OSM PostGIS connection?

So I've been playing with TileMill a bit and then suddenly thought "Let's grab some OSM map tiles and make this map really nice!!"
Wait a minute. Oh darn.
I really don't want to have to download and set up my own PostGIS server (or whatever)...
Isn't there anything online I can simply point to that will give me some tiles? I'm honestly not too picky either, it'd just be nice to have place names and some roads and geography on it...
I don't think there is any open Server where you can point your Postgres requests directly.
But there are two possible solutions:
For a smaller area you can create your Layers via Overpass-Turbo. E.g. to get all buildings in the mapview: http://overpass-turbo.eu/s/5Q0
[out:json][timeout:25];
(
way["building"="yes"]({{bbox}});>;
); out;
Then you can Export this data to GeoJSON. TileMill can read this GeoJSON file as Layer.
This solution is a bit complex, because you maybe have to learn the Overpass Query Language (or using the Overpass-Turbo Wizard). But it's very flexible: You can visualize every OSM tag you need. But its also limited to smaller areas, because Overpass-Turbo can't handle so much data.
The other solution is to use Mapbox Studio instead of TileMill. It generates the Maps from OSM-Vectordata Mapbox is hosting. For MapBox Studio you will need a MapBox Account and you're limited to the tags and layers Mapbox provides. From Mapbox Studio you can export images but no tiles or Mapnik XML.
So the questions of
Hosted OSM PostGIS connection?
And
Isn't there anything online I can simply point to that will give me some tiles?
Are very different: the former doesn't exist anywhere, for a technical (it would be slow) and practical (it would be expensive) reasons. The latter exists in lots of places: commercial services like Mapbox, freemium services like MapQuest Open, and grant-funded services like Stamen Tiles all provide pre-baked OSM tiles as a service.

Mapping without Google Maps (on a stand-alone server)

I've been asked to create a stand-alone site/app that's not connected to the web (all on a local server).
One part of it is to have a map of a natural reserve with a bunch of links that will show footpaths, different animals habitat areas, visitor centres and such.
So there's a map (static picture) and when you click on it some overlay goes on top of it.
At least that's the way I see it now.
I've looked here: http://www.carto.net/williams/yosemite/ but it just looks mucho ugly.
Getting Maps Premium is not an option as it's not that cheap. And the reason they don't want to use Maps/Earth free API is because internet connection is still very slow there (sattelite internet only and when optic cable will be hooked up nobody knows).
Looking for some recommendations as to how to proceed there. Drawing paths/areas on the picture of the maps seems extremely insufficient and time consuming.
I'd need some way to use coordinates to automatically draw areas and lines over the map (and then somehow export that as a graphis file (or SVG) that'll be layered on top of original map simply using ajax.
Will ARCGIS pro edition be the way to go or should I start learning SVG. Do you know some good SVG books/tutorials (as related to mapping)? Maybe there's some other way around altogether...
They do have detailed maps of the area in ARCGIS (whatever format they are in I don't know yet).
Just looking for some ideas, any help will be appreciated. Thanks in advance.
Do you know GeoServer? More or less all-in-one, compatible with different types of datasets, widely customisable.
Starting from "raw" SVG and write the whole thing yourself will probably be prohibitively time consuming.
If you have very little data (say less than 50 geometries) that is fixed, you could also use OpenLayers without any backend server.
For the data you could use a OpenLayers.Layer.Image if your (overlay-) map consists of a small raster image. For vector data, you can use OpenLayers.Layer.Text or a OpenLayers.Layer.Vecor together with protocols OpenLayers.Layer.KML or .JSON.
You can click through the current release examples.
I admit that this is not an easy task for a beginner, but it's fun hacking the maps together.

Resources