gmaps.js is the easiest way to use the Google Maps API

Hello!

I’ll tell you about one small (~ 30kb) JS library for convenient work with the Google Maps API called gmaps.js .
Since the library was created to accelerate the process of web development, then I will not delay you. As the name implies, it does nothing more than simplify interaction with the Google Maps API . Many of you worked with the API, and probably each time you had to sweat to rummage through the documentation and implement, for example, your own description of the mark on the map. Or subscribe to an event of interaction with the card ...

So, it has not yet acquired a single major version, but currently has version 0.1.12.3 . Distributed under the MIT License and is being developed by the whole community (and you too can help with this).

Feature Examples


Map creation

new GMaps({
  div: '#map',
  lat: -12.043333,
  lng: -77.028333
});

And you can add options zoom , width , height . Although, according to the standard, the width and height of the card will fit the container.

Developments

map = new GMaps({
  div: '#map',
  zoom: 16,
  lat: -12.043333,
  lng: -77.028333,
  click: function(e) {
    alert('click');
  },
  dragend: function(e) {
    alert('dragend');
  }
});

All Maps API events are supported.

Geolocation

GMaps.geolocate({
  success: function(position) {
    map.setCenter(position.coords.latitude, position.coords.longitude);
  },
  error: function(error) {
    alert('Geolocation failed: '+error.message);
  },
  not_supported: function() {
    alert("Your browser does not support geolocation");
  },
  always: function() {
    alert("Done!");
  }
});

Well, isn't it cute?

Add Marker

map.addMarker({
  lat: -12.043333,
  lng: -77.028333,
  title: 'Lima',
  click: function(e) {
    alert('You clicked in this marker');
  },
  infoWindow: {
    content: '

Home, sweet home...

' } } });


And everything, everything, everything!

The library supports almost the full functionality of the Maps API, including the output of static maps (as a picture), layering, laying out routes, drawing polygons, drawing your own controls, GeoRSS and all the rest ...

Please read the library website: http://hpneo.github.com / gmaps / and start creating.
And immediately fork the repository on Github: https://github.com/HPNeo/gmaps

UPD: KidsKilla suggests that, in principle, according to the Maps API ToS, no one has the right to create their wrappers (shells) on top of the existing API until they get Google's official permission. ( https://developers.google.com/maps/terms, paragraph 10.2). To which the developer (Gustavo Leon) replied that he would do two things: 1) request permission from Google 2) a ticket has already been opened to connect not only the Google Maps API, but also OpenStreetMap. This is happiness!

Also popular now: