Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where to get already packed MBTiles? Or how to generate them? #188

Closed
carlos-mg89 opened this issue Feb 27, 2018 · 9 comments
Closed

Where to get already packed MBTiles? Or how to generate them? #188

carlos-mg89 opened this issue Feb 27, 2018 · 9 comments

Comments

@carlos-mg89
Copy link

Hello,

I've tried to load vector MBTiles from https://openmaptiles.com/ and they looked unstyled (I applied the CARTO_BASEMAP_STYLE_DEFAULT style). Am I doing something wrong here?

Perhaps those MBTiles aren't appropriate for the Carto SDK. If that's the case...it will be fine if someone points out a way to do it. I can investigate and do it by myself.

I have been doing research about this topic for a lot of months with no luck. And I really love the Carto SDK. I'd even consider using the paid plan, but it's too expensive at least at the beginning for me.

This is the main code of my Android activity:

addBaseLayer(CartoBaseMapStyle.CARTO_BASEMAP_STYLE_DEFAULT);
TileDataSource source = createTileDataSource();
MBVectorTileDecoder decoder = getDecoderFromCurrentLayer();
clearLayers();
addNewLayer(source, decoder);

private void addBaseLayer(CartoBaseMapStyle style)
{
        CartoOnlineVectorTileLayer base = new CartoOnlineVectorTileLayer(style);
        mapView.getLayers().add(base);
}

private TileDataSource createTileDataSource()
{
    MBTilesTileDataSource tileDataSource = null;
    try {
            String localDir = getExternalFilesDir(null).toString();
            String path = localDir + "/" + "2017-07-03_spain_barcelona.mbtiles";
            tileDataSource = new MBTilesTileDataSource(path);
    } catch (IOException e) {
            // Handle exception
    }
}

private MBVectorTileDecoder getDecoderFromCurrentLayer() {
        return (MBVectorTileDecoder)((VectorTileLayer)mapView.getLayers().get(0)).getTileDecoder();
}

private void clearLayers()
{
        mapView.getLayers().clear();
}

private void addNewLayer(TileDataSource source, MBVectorTileDecoder decoder)
{
        VectorTileLayer layer = new VectorTileLayer(source, decoder);
        mapView.getLayers().insert(0, layer);
}

Attached you'd find 3 screenshots of what I see from different zoom levels:

screenshot_20180227-105625
screenshot_20180227-105635
screenshot_20180227-105645

@jaakla
Copy link
Contributor

jaakla commented Feb 27, 2018

It seems that you use older SDK version, you should use 4.1.0 or newer for openmaptiles styling.

@carlos-mg89
Copy link
Author

carlos-mg89 commented Feb 27, 2018

That's actually correct @jaakla . I was using the previous 4.0.0 version. As soon as I've updated it, it worked like a charm. Thanks!

Are there any other styles aside from the packed ones?

  • CARTO_BASEMAP_STYLE_VOYAGER
  • CARTO_BASEMAP_STYLE_POSITRON
  • CARTO_BASEMAP_STYLE_DARKMATTER

It would be wonderful if I could use the ones listed by OpenMaptiles over here https://github.com/openmaptiles/openmaptiles

@mtehver
Copy link
Contributor

mtehver commented Feb 27, 2018

With some work you could use 'MapBox Studio Classic' styles from https://github.com/openmaptiles/openmaptiles.

But they will probably need manual fixing and will not run as fast and will not look as nice as our built-in styles. No continous handling of line widths, for example.

@carlos-mg89
Copy link
Author

Would you kindly tell me how should I pack one of these MapBox Studio Classic styles to be compatible with CartoDB please? I assume I should load an AssetPackage, or a ZippedAssetPackage. But haven't found the way to do that.

@mtehver
Copy link
Contributor

mtehver commented Feb 28, 2018

@carlos-mg89 I will add a section to the Wikipage with instructions. This question has been asked several times before, so I think some guide is useful. I will send a link once the wikipage is up.

@mtehver
Copy link
Contributor

mtehver commented Feb 28, 2018

@carlos-mg89 The preliminary info about creating custom styles is here

@farfromrefug
Copy link
Contributor

@mtehver great stuff!
I actually managed to find prebuild mapbox studio classic versions here:
https://mapbox.s3.amazonaws.com/mapbox-studio/index.html
And it's really easy to work with carto sources using this:
http://mobile-api.carto.com/maps/v2/carto.streets/1/tiles.json

Wouldn't it be to actually fork mapbox-studio-classic to create a carto version?
It should be fairly easy. And you could even easily add support for Carto specific CSS properties.
And have custom export/save.

@jaakla
Copy link
Contributor

jaakla commented Mar 12, 2018

This would be technically possible, but we don't have it as high priority for now.

@jaakla
Copy link
Contributor

jaakla commented Mar 12, 2018

Closing this as it is duplicate of #174

@jaakla jaakla closed this as completed Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants