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

Enable library for frameworks via NPM modules #129

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

alasarr
Copy link
Contributor

@alasarr alasarr commented Aug 26, 2020

This PR brings support to use the library via npm.

With this branch, I've been able to include the SDK in a react project (I know I'm not using the DeckGL react component, just want to try if I can ingest the library via npm without importing the umd by hand).

It should work on Angular or Vue, but we should try it.

import React from 'react';
import { auth, viz } from '@carto/web-sdk';

class Map extends React.Component {
  map = null

  componentDidMount() {
    auth.setDefaultCredentials({ username: 'public' });
    this.map = viz.createMap();
    const ports = new viz.Layer('world_ports');
    ports.addTo(this.map);
  }

  render() {
    return (
      <div id='map'>
        Map
      </div>
    )
  }
}

export default Map;

It also removes the dependency of DeckGL because it's only available via Scripting API and it includes a dependency for Mapbox GL, so we don't need to add the link to mapbox CDN.

TODO: remove all the links to Mapbox at the examples.

@vercel
Copy link

vercel bot commented Aug 26, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/carto-frontend/web-sdk/bfrrq4ae1
✅ Preview: https://web-sdk-git-alasarr-createmap-modules.carto-frontend.vercel.app

@alasarr alasarr changed the title Mapbox basemap available via npm modules Enable library for frameworks via NPM modules Aug 26, 2020
@VictorVelarde
Copy link
Contributor

I have just updated the typings after your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants