GithubHelp home page GithubHelp logo

googlemap-manager's Introduction

googlemap-manager

Usage

1. Add the latest googlemap-manager javascript file

<script src="/path/to/googlemap-manager.js"></script>

<!-- optional -->
<!-- required if markers.cluster is used  -->
<script src="/path/to/markerclusterer.js"></script>
<!-- required if markers.infoBubble is used  -->
<script src="/path/to/infobubble.js"></script>

2. Create a element with an unique ID

<div id="myCustomMap"></div>

3. Initialize a new GoogleMapManager instance

var newMap = new GoogleMapManager('myCustomMap', {
    // Settings
});

Settings

Name Type Description
googleMap object Support all the same options as a normal google map.
markers object An object regrouping all the below settings.
markers.closeOthers boolean
Default:true
Determine if all other markers should close when a new one is opened.
markers.cluster object When use enable the markerclusterer.js extension. Support all the options of the plugin.
markers.infoBubble object When use enable the infobubble.js extension. Support all the options of the plugin.
styles object An object representing the colors and elements to show on the map. Can be generated online on a site like Snazzy Maps.

Methods

newMap.addMarker({
    id: 1,
    title: "My marker",
    lat: 45,
    lng: -73,
    template: "<div>Content of the infowindow...</div>",
    categories: ["sushi"]
});
Name Options Description
on eventName, callback Listen to an event by name
zoomIn number
optional
Increase the zoom by the amount specified.
zoomOut number
optional
Decrease the zoom by the amount specified.
boundZoom - Set the zoom of the map so that all markers fit in the view.
addMarker id:number
title:string
lat:number
lng:number
icon:path
template:string
categories:array
Add a marker to the map. If no template is passed the title will be used.
getMarker id Retrieve a marker by ID.
showMarker id or marker Make the marker visible on the map.
hideMarker id or marker Make the marker invisible on the map.
openMarker id or marker Open the infowindow associated to the marker.
filterMarkers category Show only the marker that have the category.
getInfowindow id Retrieve an infowindow by marker ID.
trigger EventName, data Trigger an event by name

Events

All the event receive the manager has this. Example:

newMap.on('markerOpened', function(marker) {
    this.zoomIn();
    this.map.panTo(marker.getPosition());
});
Name Callback Description
markerOpened (marker) Triggered when the marker infowindow as been opened.
markerClosed (marker) Triggered when the marker infowindow as been closed.
boundZoomed - Triggered when the method boundZoom is called.

googlemap-manager's People

Contributors

aleveille-penega avatar aleveille92 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.