Giter VIP home page Giter VIP logo

control-js's Introduction

Synopsis

Add custom controls to Google Maps with ease.

Custom copyrights and logos should be added to Google Maps via custom controls vs simple CSS positioning.

Control.js is an add-on JavaScript library of custom control methods with IDE intellisense/auto-complete showing control positioning to Google Maps via the Javascript API.

Code Example

//Apply CSS Id's and Classes as normal
var html0 = '<a href="http://www.rack.pub"><img src="http://www.rack.pub/favicons/android-chrome-192x192.png" alt="logo" class="logo"></a>';
var html1 = '<a href="http://www.rack.pub" class="copyright">&#169; My Copyright</a>';

//Global method that is fired when the Google Maps API is loaded and ready
function initMap () {
    map = new google.maps.Map(document.getElementById("map"), mapOptions);
    //intelliSense/Auto-complete works on IDE's
    control.topCenter.add(html0);
    control.bottomLeft.add(html1);
};

screenshot

## Motivation

The Official Google Maps JavaScript API custom controls example example is not easy and the number of control positions are difficult to remember.

The official examples use JavaScript to dynamically create HTML and CSS which are then passed to a constructor function. This add-on makes adding custom controls easy.

Installation

๐Ÿ Load via rack.pub's global CDN

<script src="https://rack.pub/control.min.js"></script>

๐Ÿš€ Embed control.min.js in your javascript when putting in production for best page loading performance.

API Reference

Simply hand one of the methods a valid HTML string as an argument. CSS can be inline or referenced as usual. Using intellesense in your IDE is recommended as it remonds you of the possible location options for your new custom control.

    control.topCenter.add(html)
    control.topLeft.add(html)
    control.topRight.add(html)
    control.leftTop.add(html)
    control.rightTop.add(html)
    control.leftCenter.add(html)
    control.rightCenter.add(html)
    control.leftBottom.add(html)
    control.rightBottom.add(html)
    control.bottomCenter.add(html)
    control.bottomLeft.add(html)
    control.bottomRight.add(html)

Contributors

Ron Royston

License

Ron Royston, https://rack.pub, MIT License

control-js's People

Stargazers

 avatar  avatar  avatar  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.