Giter Site home page Giter Site logo

cartodb.js's Introduction

cartodb.js

This library allows to embed you visualizations created with CartoDB in your map or website in a simple way.

quick start

  1. add cartodb.js and css to your site (and google maps if you are using it):
```html

    <link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v2/themes/css/cartodb.css" />
    <!--[if lte IE 8]>
        <link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v2/themes/css/cartodb.ie.css" />
    <![endif]-->

    <script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script src="http://libs.cartocdn.com/cartodb.js/v2/cartodb.js"></script>

    <!-- use these links if you are using https -->
    <!--

    <link rel="stylesheet" href="https://d3voyrscnb0slx.cloudfront.net/cartodb.js/v2/themes/cartodb.css" />
    <!--[if lte IE 8]>
        <link rel="stylesheet" href="https://d3voyrscnb0slx.cloudfront.net/cartodb.js/v2/themes/css/cartodb.ie.css" />
    <![endif]-->

    <script src="https://d3voyrscnb0slx.cloudfront.net/cartodb.js/v2/cartodb.js"></script>
    -->
```
  1. create the map and add the layer
**gmaps**

```javascript

    // create google map
    var map;
    var mapOptions = {
      zoom: 7,
      center: new google.maps.LatLng(43, -68),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('map'),  mapOptions);

    // add the cartodb layer
    // you can find this url in CartoDB interface:
    // - go to map
    // - click on share
    // - API tab
    var layerUrl = 'http://examples-beta.cartodb.com/api/v1/viz/219/viz.json';
    cartodb.createLayer(map, layerUrl, function(layer) {
        map.overlayMapTypes.setAt(0, layer);
    });

```

**leaflet**

```javascript
  var map = L.map('map').setView([0, 0], 3);

  // set a base layer 
  L.tileLayer('http://a.tile.stamen.com/toner/{z}/{x}/{y}.png', {
    attribution: 'stamen http://maps.stamen.com/'
  }).addTo(map);
  
  // add the cartodb layer
  var layerUrl = 'http://examples-beta.cartodb.com/api/v1/viz/219/viz.json';
  cartodb.createLayer(map, layerUrl, function(layer) {
    map.overlayMapTypes.setAt(0, layer);
  });
```

next steps

how to build

```
open test/SpecRunner.html
make release
```

cartodb.js's People

Contributors

andrewxhill avatar javierarce avatar javisantana avatar johnhackworth avatar luisbosque avatar saleiva avatar tokumine avatar xavijam avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.