ember-google-map
An Ember addon to include a google-map Ember friendly component in your apps.
This is a work in progress, plan is to other tools provided by google-map API.
What is implemented for now:
Here is what is working for now:
lat
andlng
: bindings or static coordinates of the center (required)zoom
: binding to the current zoomtype
: binding to the type of map (can be found withimport {MAP_TYPES} from 'google-map/components/google-map';
)markerController
: theObjectController
to use as a marker controller, must extend fromgoogle-map/controllers/marker
markerInfoWindowTemplateName
: default template for a marker info-windowmarkerHasInfoWindow
: whether to disable all markers info window or notmarkers
: binding to an array of markers (all properties are bound back an forth)lat
andlng
: coordinates of the marker position (required)isClickable
: if the marker is clickableisVisible
: marker visibilityisDraggable
: marker draggabilitytitle
: marker's titleopacity
: marker's opacityicon
: marker's iconzIndex
: marker's z-indexgoogleEvents
: an object with a mapping from google event to an Ember action name (string) or a function to be runhasInfoWindow
: whether it has an info window or notdescription
: What to how in the info window if no template specifiedisInfoWindowVisible
: whether the info window is visible initially or notinfoWindowTemplateName
: the template name for the info window
infoWindowTemplateName
: default template to use for all info-windowsinfoWindows
: bindings to an array of info-windows (not attached to any marker)isVisible
: whether the info-window is visible or not (default to true)lat
andlng
: coordinates of the info-window position (required)zIndex
: info-window's z-indextitle
: if using the default templatedescription
: if using the default templatetemplateName
: the name of the template to use with this info-window
TODO:
-
Implement an auto-complete input for an address:
-
Write unit tests!!!
Installation
npm install --save-dev ember-google-map
Google Api key configuration
The google map script tag will be inserted in the head section of your index.html.
Also, if you define a ENV.googleMapKey
variable in your Ember CLI project's configuration (config/environment.js
), it will be used as an API Key within this script tag.
Here is an example :
ENV.googleMapKey = 'AbCDeFgHiJkLmNoPqRsTuVwXyZ'
Using
Here is a very basic example:
// app/controllers/application.js
import Ember from 'ember';
import {MAP_TYPES} from 'google-map/components/google-map';
export default Ember.Controller.extend({
lat: 0,
lng: 0,
zoom: 5,
type: 'road',
mapTypes: MAP_TYPES,
});
GitHub pages of this repository:
Here is anotehr example, corresponding to what is on the// app/controllers/application.js
import Ember from 'ember';
import {MAP_TYPES} from 'google-map/components/google-map';
export default Ember.Controller.extend({
lat: 0,
lng: 0,
zoom: 5,
type: 'road',
mapTypes: MAP_TYPES,
markers: [
{title: 'one', lat: 5, lng: 5, description: 'hello 1', isDraggable: true},
{title: 'two', lat: 5, lng: 0, hasInfoWindow: false},
{title: 'three', lat: 0, lng: 5, infoWindowTemplateName: 'marker-info-window', helloWorld: 'Hello World!'}
],
infoWindows: [
{title: 'some info window', lat: -5, lng: -5, description: 'hello everybody!'}
],
actions: {
addMarker: function () {
this.get('markers').addObject({title: 'new', lat: 0, lng: 0, isDraggable: true});
},
removeMarker: function (marker) {
this.get('markers').removeObject(marker);
},
addInfoWindow: function () {
this.get('infoWindows').addObject({title: 'new iw', description: 'hello', lat: -5, lng: 0});
},
removeInfoWindow: function (marker) {
this.get('infoWindows').removeObject(marker);
}
}
});