1.0.0-alpha.9 • Published 3 years ago

beneroch-gmap v1.0.0-alpha.9

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

Gmap

JavaScript library for working with the Google Maps API.

  • Description
  • Objects / Classes
    • BB.base
    • BB.data
    • BB.gmap.controller
    • BB.gmap.infobox
    • BB.gmap.obj
    • BB.gmap.line
    • BB.gmap.polygon
    • BB.gmap.marker
  • Examples beneroch.com/gmap
    • Map initialization
    • Add place
      • Marker
      • Line
      • Polygon
    • Add place by address
    • Change styles
    • Add callback functions for events
      • click
      • mouseover / mouseout

Description

This is a set of classes built to manager the google objects easily, with a controller. This allows to keep track of items on the map, make them editable or selectable and do pretty much whatever you want.

This plugin does not require jQuery

The only dependencies are:

Objects / Classes

  • BB.base
  • BB.data
  • BB.gmap.controller
  • BB.gmap.infobox
  • BB.gmap.obj
  • BB.gmap.line
  • BB.gmap.polygon
  • BB.gmap.marker

BB.base

Base Class for all Gmap objects. This allows all objects to have some basic methods:

MethodParamDescription
set_data{Object} dataSets the data for hte object. Accepts JSON object
data{String} key (falcultative)Returns the data pointed by the key param. If no key param specified, returns all the data as set by the set_data methods
remove_data{String} key (falcultative)Removes the data pointed by the key param. If no key specified, resets the data to {}
sanitizenullEscape all data in order to prevent bugs caused by unescaped caracters such as \. Call the native escape() javascript function recursively on all datas
unsanitizenullUnescape all data. Exact opposite of sanitize()
identnullReturns the ident of the object.
set_ident{String} IdentSets the ident of the object
error{String} error_msgIf the BB_DEBUG is set to true, throw an error with the message.
is_empty_object{Object} objCheck if the object is empty, using the hasOwnProperty javascript method
extend{Object} Defaults - {Object} optionsMerge objects together, override data with the options param

BB.data

This class is used internally to store the object data. There is certainly no reason to use it anywhere else.

BB.gmap.controller

The controller is the main piece of the plugin. It allows the user to have control on every items on the map, keep track by adding listeners and accessing the different places easily

MethodParamDescription
constructor{DOMElement} container - {Object} dataCall the plugin by creating a new BB.gmap.controller( DOMObject, data).

Getters

MethodParamDescription
mapnullReturns the associated map {google.maps.Map}
containernullReturns the associated container passed in the constructor {DOMElement}
get_place{string} IdentReturns the matching object according to the ident specified, or undefined
get_placesnullReturns a list of all objects on the map, separated by types. { markers:{}, lines:{}, polygons:{} }
focusednullReturns the currently focused item on the map. Clicking on an item sets the focus on that item.
get_all_markersnullUsed for the markerclusterer. Returns all markers on the map
clusterernullReturns the markerclusterer object associated with the controller, if one.

Setters

MethodParamDescription
set_styles{Object} StylesSets the styles for the map and automatically refreshes the map if it's instanciated
set_place{String} type, {String} ident, {Object} dataSet a place in the controller memory. This should not be used. @todo Make that one protected, private, or whatever
set_focus{BB.gmap.object} itemSets the focus on the current object, blurs the previously focused item
set_zoom{int} zoomSets the zoom of the map. Same as calling self.map().setZoom( zoom )

Other methods

MethodParamDescription
add_place{String} ident, {Object} dataAdds a place on the map, as long as the data are filled up. You need the exact coordinates to use this method
add_place_by_address{String} ident, {String} address, {Object} dataAdds a place by geolocating the specified address. If the address is invalid, chances are that the marker is gonna be added in the Indian Ocean (0, 0). This method is asynchronus, it looks for the geocode with the google api geocoder before adding the marker to the map.
geocode_address{String} address, {Function} callbackGeocodes an address and then uses the callback function to do what you wanted with the address
translate_coords{Array} coords lat, lonReturns a google.maps.LatLng() object with the specified coords
create_new{String} identSets the listeners to add points on the map byclicking. The type has to be defined
_loop_all{Function} callbackLoops through all objects instanciated in that controller. Calls the callback function on each of them with the place as argument
fit_boundsnullFit bounds to all objects on the map. Call after "Ready"
ready{Function}Callback function called after everything is loaded on the map

Options

NameTypeDescription
map{Array}Map options passed to the map instance. @see https://developers.google.com/maps/documentation/javascript/tutorial#MapOptions
places{Array}Places to be found on the map. 3 types availables: Marker, Line, Polygon. @see options for all BB.gmap.object, BB.gmap.marker, BB.gmap.line, BB.gmap.polygon
use_clusterer{Boolean}Map uses or not the clusterer (unfinished)
max_fitbounds_zoom{Boolean}Max zoom value when asking a "fit_bounds", not to be confused with map.maxZoom
default_styles{Array}Default polygon and line styles. @see BB.gmap.line styles

BB.gmap.object

MethodParamDescription
1.0.0-alpha.9

3 years ago

1.0.0-alpha.8

4 years ago

1.0.0-alpha.7

4 years ago

1.0.0-alpha.6

4 years ago

0.3.1

4 years ago

1.0.0-alpha.5

4 years ago

1.0.0-alpha.4

4 years ago

1.0.0-alpha.3

4 years ago

1.0.0-alpha.2

4 years ago

1.0.0-alpha.1

4 years ago

1.0.0-alpha

4 years ago

0.3.0

6 years ago

0.2.0

6 years ago

2.0.0

7 years ago