Coder Social home page Coder Social logo

cartodb-embeds's Introduction

CartoDB Embeds

These CartoDB embeds balance all the free things you get when using a CartoDB "Visualization embed" (legends, address search field, tile layer loading spinners), with the ability to customize a zoom and starting lat/lng and a few other ideas in the works.

Usage

Check out the example for all options.

Installation

The dist/ folder contains two files

  • cartodb-embeds.js The minified version of just this library. You'll need to load your own CartoDB.js. Note: this library has only been tested with CartoDB.js 3.15.1
  • cartodb-embeds.pkgd.min.js The same as above packaged with CartoDB.js 3.15.1.

Example usage

<!-- Vanilla embed, latlng and zoom are as described in viz -->
<div class="CDBE-embed" data-embed-link="link-goes-here" style="width: 100%; height: 500px;"></div>
	
<!-- Custom zoom -->
<div class="CDBE-embed" data-embed-link="link-goes-here" data-zoom="14" style="width: 100%; height: 500px;"></div>

<!-- Custom latlng and zoom -->
<div class="CDBE-embed" data-embed-link="link-goes-here" data-latlng="33.9436333,-118.4906967" data-zoom="9" style="width: 100%; height: 500px;"></div>

<!-- Custom mobile latlng, mobile zoom and mobile breakpoint -->
<div class="CDBE-embed" data-embed-link="link-goes-here" data-latlng="33.9436333,-118.4906967" data-zoom="9" data-mobile-zoom="3" data-mobile-latlng="33.8,-119" data-mobile-breakpoint="500px" style="width: 100%; height: 500px;"></div>

<!-- Include script -->
<script src="cartodb-embeds.pkgd.min.js"></script>

Developing

This projects uses bower and gulp, which are NodeJS tools. If you don't have them, install with:

npm install bower -g
npm install gulp -g

Then, in this project folder run

bower install
npm install

To package the JavaScript to the dist/ folder, simply run gulp.

Other handy things

If you want to repackage the JavaScript as you're working, use the gulp dev command, which will watch the project folder and rerun the gulp tasks when it detects changes.

If you're not used to writing Vanilla JavaScript (i.e. not using jQuery), the site "You might not need jQuery" has a lot of equivalencies. I'm currently setting it to the "Support IE9" level.

Future features

Check the Issue Tracker for progress. A few ideas are:

  • Mobile latlng
  • Mobile zoom
  • Baselayer swap out based on zoom

cartodb-embeds's People

Contributors

mhkeller avatar

Stargazers

Travis Taylor avatar Carl V. Lewis avatar

Watchers

Carl V. Lewis 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.