Skip to content

Commit

Permalink
Mouse events support added
Browse files Browse the repository at this point in the history
  • Loading branch information
SamvelRaja.S committed Jul 26, 2015
1 parent c00e9e8 commit 16ff1c8
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 10 deletions.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,32 @@ That's it, Google maps addon ready to use.

mapOptions is a object that with your, **latitude**,**longitude** and **zoom**

```js
mapOptions : {
latitude : 'your latitude',
longitude : 'your longitude',
zoom : 'prefered zooming',
//Mouse events
click : function (event){
//your code here
}
}
```
Supported Mouse events

```js
'click',
'dblclick',
'drag',
'dragend',
'dragstart',
'mousemove',
'mouseout',
'mouseover',
'rightclick'
```
Next update would be,

Googlemaps events
Loader support and few code enhancements

For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).
1 change: 1 addition & 0 deletions addon/components/google-maps-addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default Ember.Component.extend({
//Setting up the map_element in the context
if(map_element){
this.set('map_element',map_element);
Helpers.initializeMouseEventCallbacks(this);
}
} else {
//Assert it if the hero(googlemaps js) is unavail
Expand Down
49 changes: 42 additions & 7 deletions addon/helpers.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,64 @@
/**
@var mouseEvents
@type array
Supported mouse events by googlemaps
ref 'https://developers.google.com/maps/documentation/javascript/reference#events_50'
**/
var mouseEvents = [
'click',
'dblclick',
'drag',
'dragend',
'dragstart',
'mousemove',
'mouseout',
'mouseover',
'rightclick'
];

export default{
/***
/**
@method initializeOptions
@param context
@usage
To initialize the `MapOptions` as `context' properties`
***/
initializeOptions : function(context){
**/
initializeOptions : function(context) {
let map_options = context.get('MapOptions');
context.setProperties({
lat : map_options.latitude || '0',
lng : map_options.longitude || '0',
latitude : map_options.latitude || '0',
longitude : map_options.longitude || '0',
zoom : map_options.zoom || 8
});
},
/**
@method initializeMouseEventCallbacks
@param context
@usage
To initialize the `mouseevents` to the `map_element`
**/
initializeMouseEventCallbacks : function(context) {
let map_options = context.get('MapOptions');
var map_element = context.get('map_element');
mouseEvents.forEach(function(event) {
if(map_options[event]){
if(typeof map_options[event] === 'function'){
google.maps.event.addListener(map_element, event, map_options[event]);
}
}
});
},
/**
@method createMapElement
@param context
@usage
To create a map element using mapOptions
It creates the map element in the $(div.map-canvas)
@return map (google map element for other handlings)
**/
createMapElement : function(context){
createMapElement : function(context) {
let mapOptions = {
center: new google.maps.LatLng(context.get('lat');, context.get('lng')),
center: new google.maps.LatLng(context.get('latitude'), context.get('longitude')),
zoom: context.get('zoom'),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "google-maps-addon",
"version": "0.0.1",
"version": "0.0.2",
"description": "A thin wrapper around the Google Maps API",
"directories": {
"doc": "doc",
Expand Down Expand Up @@ -35,7 +35,8 @@
},
"keywords": [
"ember-addon",
"google-map-wrapper"
"google-maps-wrapper",
"google-maps-ember-addon"
],
"dependencies": {
"ember-cli-babel": "^5.0.0"
Expand Down

0 comments on commit 16ff1c8

Please sign in to comment.