An ember-cli add-on for easy integration with Google Maps.
Each object displayed on map is inserted via child component,
so you can easily declare which marker and when to display on map
using {{#if}} and {{#each}} on template level.
ember install ember-g-map
You must define the size of the canvas in which the map is displayed. Simply add something similar to this to your styles:
.g-map-canvas {
width: 600px;
height: 400px;
}In config/environment.js you can specify additional Google Maps libraries
to be loaded along with this add-on (check the full list here)
and optional API key for your application (additional info could be found here).
ENV['g-map'] = {
libraries: ['places', 'geometry'],
key: 'your-unique-google-map-api-key'
}Any custom options
(except for center and zoom to avoid conflicts) could be set for
Google Map object on creation and updated on change.
Mandatory context attribute ties child-elements
with the main g-map component. You can set simple title appearing on click
using title attribute and marker label using label.
These Info Windows will be open right after component is rendered
and will be closed forever after user closes them. You can specify
optional onClose action to tear down anything you need when Info Window
has been closed by user.
markersFitMode attribute overrides lat, lng, zoom settings.
markersFitMode value can be one of:
- 'init' - which will make the map fit the markers on creation.
- 'live' - which will keep the map keep fitting the markers as they are added, removed or moved.
Markers can have bound Info Windows activated on click.
To properly bind Info Window with Marker you should call g-map-marker
in block form and set context of Info Window to the one provided by Marker.
Additionally you can specify parameter group which ensures that only
one Info Window is open at each moment for Markers of each group.
Proxy g-map-address-marker component takes address string as parameter
and translates it to lat/lng under the hood.
Optional onLocationChange action hook will send you back coordinates
of the latest address search result and the raw array of
google.maps.places.PlaceResult objects provided by places library.
Other optional parameters are the same as for g-map-marker.
Requires places library to be specified in environment.js.
ENV['g-map'] = {
libraries: ['places']
}actions: {
onLocationChangeHandler(lat, lng, results) {
Ember.Logger.log(`lat: ${lat}, lng: ${lng}`);
Ember.Logger.debug(results);
}
}Using Google Maps Directions service.
http://asennikov.github.io/ember-g-map/
- Auto-closing Info Windows
- Polylines & Polygons
- Google Maps events
ember server- Visit your app at http://localhost:4200.
ember testember test --server
ember build
For more information on using ember-cli, visit http://www.ember-cli.com/.