Code Monkey home page Code Monkey logo

google-map-markers's Introduction

Google Maps Plugin

This plugin will create an interactive map using Google's Maps JavaScript API v3. It will create a map in the specified HTML element, center the map on the specified Lat/Long coordinates, plot a marker for each valid marker supplied (and add in an infowindow if supplied), and will number each marker.

Implementing

First, source the Google Maps API script with your API Key (optional, depending on needs) and source the plugin JS file:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=[YOUR_KEY_HERE]"></script>
<script type="text/javascript" src="path/to/map-plugin.js"></script>

Next, add an emtpy HTML element for the map and some small CSS:

<div id="map-holder"></div>
#map-holder {
  display: block;
  margin: 0 auto;
  width: 600px;
  height: 100%;
  max-height: 600px;
}

Last, include the initialization command mapPlugin.createMap() at the bottom of the HTML before the closing </body> tag to create the map with markers:

<script>
  var markers = [
                {
                  lat:40.7412541,
                  long:-74.0031284,
                  infoContent:'<p>This is <a href="https://google.com">Google</a></p>',
                  maxWidth: 150
                },
                {
                  lat:40.7638337,
                  long:-73.9729656,
                  infoContent:'<p>This is <a href="https://apple.com">Apple</a></p>',
                  maxWidth: 500
                }
              ];

mapPlugin.createMap('map-holder',
                    37.09024, -95.71289100000001,
                    markers,
                    true
                    )
  );
</script>

google-map-markers's People

Contributors

paulmolluzzo avatar

Stargazers

 avatar

Watchers

James Cloos 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.