Saturday 28 April 2018

javascript - Using CARTO VL on local Ubuntu installation


I'm trying to use CARTO VL on local Ubuntu 16.04 installation. To connect to local CARTO installation, I used the following config in my index.html:


carto.setDefaultConfig({
serverURL: 'http://me.localhost.lan:3000'
});

and then simply connect to dataset like this:


const source = new carto.source.Dataset('compact_regions');


I used "me" as the subdomain here and I can use the same dataset from my trial CARTO account but I can't do the same with my local CARTO. Could anyone please give me some hints or what not? Do I need to do anything with config / https to make this work?



Answer



Assumming the account in your local installatioin is named me, you can try to define your source like this, which I hope works for you:


const source = new carto.source.Dataset(
'compact_regions', {
user: 'me',
apiKey: 'default_public'
}, {
serverURL: 'http://me.localhost.lan:8181'

}
);

If the dataset is not public you'll need to provide a valid apiKey.


Explanation:


You're right that, with a local installation, you need to provide the serverURL parameter, so that CARTO VL can access the Maps API to fetch the data from a CARTO account.


But this parameter cannot be set in the setDefaultConfig function at the moment; you'll need to use the third argument to the carto.source.Dataset or carto.source.SQL constructors for that. (the second argument is the same authentication options you pass to setDefaultConfig).


Also, since in a local installation you're probably not using the same routing that the CARTO public SAAS provides, you'll need to direct the requests directly to the Maps API, which by default is running in the port 8181.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...