2017 © Pedro Peláez
 

library google-js-api

Composer library for Google API browser helpers (javascript) ; ECMASCRIPT 5+ required

image

net-tools/google-js-api

Composer library for Google API browser helpers (javascript) ; ECMASCRIPT 5+ required

  • Monday, May 21, 2018
  • by nettools.ovh
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

net-tools/google-js-api

Interface to some Google APIs

This packages contains :, (*1)

  • maps.js : a helper class nettools.google.maps.MapManager to provide useful methods to display maps, routes, and markers.

Setup instructions

To install net-tools/google-js-api package, just require it through composer and insert any script tag required in the HEAD section (replace file.js with any of the above packages) :, (*2)

<script src="/path_to_vendor/net-tools/google-js-api/src/api/file.js"></script>

Reference

nettools.google.maps.MapManager class

The MapManager class makes it possible to display a map, routes and markers in a simpler way. For example, any marker created is stored in the MapManager class, so that they could be later removed from the map with a call to raz() method., (*3)

First, create an object of nettools.google.maps.MapManager class ; required constructor parameters are : - mapdiv : the ID of the DOM element to display the map into or the DOM node, - centerpoint : a google.maps.LatLng object or a litteral object {lat:value, lng:value} with the desired default display coordinates, - mapOpt : a litteral object with any of google.maps.Map available options (such as mapTypeId), - directionsRendererOpt : a litteral object with any of google.maps.DirectionsRenderer available options., (*4)

var mm = new nettools.google.maps.MapManager(
          // mapdiv
          "map_canvas2",

          // centerpoint
          {lat:45.763691, lng:3.119431}, 

          // mapOpt : options for google.maps.Map
          {
              // default zoom
              zoom: 2,

              // streetview widget off
              streetViewControl : false
          }
      );

MapManager class provides the following members : - map : property to access the underlying google.maps.Map object, - raz() : method to clear the map ; it removes markers, routes and reset default options (such as centerpoint), - getDirectionsRenderer() : method to get the google.maps.DirectionsRenderer object ; useful to get info about a computed route, - getDirectionsService() : method to get the google.maps.DirectionsService object, - getInfoWindow() : method to get the google.maps.InfoWindow object (one per map), - createMarkers(Object[]) : method to create a lot of markers at a time ; the expected parameter is an array of litteral objects describing the markers (usually {position:{lat:xxx, lng:xxx}, map:mm.map, title:'Marker here!'}), - createMarker(Object) : method to create a single marker ; marker parameters are set in the litteral object expected - route(point1, point2, options, callback_ok, callback_ko) : method to compute and display a route between two points. Parameters are : - the first two parameters set the start and end coordinates (the type expected can be a string, google.maps.LatLng objects, litteral objects {lat, lng} or google.maps.Place objects), - a litteral options object to give parameters to DirectionsService class (such as directionsTravelMode, etc.) - callbacks for successful result or failure (see sample file for detail, (*5)

The Versions

21/05 2018

dev-master

9999999-dev

Composer library for Google API browser helpers (javascript) ; ECMASCRIPT 5+ required

  Sources   Download

MIT

by Avatar Pierre

04/07 2017

1.0.4

1.0.4.0

Composer library for Google API browser helpers (javascript) ; ECMASCRIPT 5+ required

  Sources   Download

MIT

by Avatar Pierre

04/07 2017

1.0.3

1.0.3.0

Composer library for Google API browser helpers (javascript) ; ECMASCRIPT 5+ required

  Sources   Download

MIT

by Avatar Pierre

02/07 2017

1.0.2

1.0.2.0

Composer library for Google API browser helpers (javascript)

  Sources   Download

MIT

by Avatar Pierre

25/06 2017

1.0.1

1.0.1.0

Composer library for Google API browser helpers (javascript)

  Sources   Download

MIT

by Avatar Pierre

24/06 2017

1.0.0

1.0.0.0

Composer library for Google API browser helpers (javascript)

  Sources   Download

MIT

by Avatar Pierre