Skip to content
This repository was archived by the owner on May 25, 2019. It is now read-only.

Commit 51ea1b9

Browse files
committed
[M] Update to be a bit more useful...
There is still a lot to describe around the use of UI.Event and all...
1 parent 1a68065 commit 51ea1b9

File tree

1 file changed

+108
-39
lines changed

1 file changed

+108
-39
lines changed

README.md

+108-39
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,142 @@
1-
# AngularUI - The companion suite for AngularJS
1+
# UI.Map [![Build Status](https://secure.travis-ci.org/angular-ui/ui-map.png)](http://travis-ci.org/angular-ui/ui-map)
22

3-
***
3+
This directive allows you to add [Google Maps Javascript API](https://developers.google.com/maps/) elements.
44

5-
[![Build Status](https://secure.travis-ci.org/angular-ui/ui-map.png)](http://travis-ci.org/angular-ui/ui-map)
5+
## Requirements
6+
7+
- AngularJS
8+
- [UI.Event](https://github.com/angular-ui/ui-utils/blob/master/modules/event/event.js)
9+
- [Google Maps Javascript API 3.x](https://developers.google.com/maps/documentation/javascript/)
610

711
## Usage
812

9-
### Requirements
13+
You can get it from [Bower](http://bower.io/)
14+
15+
```sh
16+
bower install angular-ui-map
17+
```
18+
19+
This will copy the UI.Map files into a `bower_components` folder, along with its dependencies. Load the script files in your application:
20+
21+
```html
22+
<script type="text/javascript" src="bower_components/angular/angular.js"></script>
23+
<script type="text/javascript" src="bower_components/angular-ui-utils/modules/event/event.js "></script>
24+
<script type="text/javascript" src="bower_components/angular-ui-map/src/map.js"></script>
25+
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=onGoogleReady"></script>
26+
```
27+
28+
__Make sure to listen to the [callback parameter when loading the Google Maps API](https://developers.google.com/maps/documentation/javascript/examples/map-simple-async) !
29+
The API must be fully loaded before this module !__
30+
Here we name this callback `onGoogleReady`. To load your angular app after the Google Maps API you can start it with [angular.bootsrap](http://docs.angularjs.org/api/angular.bootstrap).
31+
32+
```javascript
33+
function onGoogleReady() {
34+
angular.bootstrap(document.getElementById("map"), ['app.ui-map']);
35+
}
36+
```
37+
38+
Add the UI.Map module as a dependency to your application module :
39+
40+
```javascript
41+
var myAppModule = angular.module('app.ui-map', ['ui.map']);
42+
```
43+
44+
Finally, add the directive to tour html:
1045

11-
* **AngularJS v1.0.0+** is currently required.
12-
* **jQuery / Plugins** _(depends on directive)._ Check specific directive dependencies for more information
46+
```html
47+
<section id="map" ng-controller="MapCtrl" >
48+
<div ui-map="myMap" ui-options="mapOptions" class="map-canvas"></div>
49+
</section>
50+
```
51+
Note that `myMap` will be a [google.maps.Map class](https://developers.google.com/maps/documentation/javascript/reference#Map), and `mapOptions` a [google.maps.MapOptions object](https://developers.google.com/maps/documentation/javascript/reference#MapOptions) (see [below](#options)).
52+
53+
To see something it's better to add some CSS, like
54+
55+
```css
56+
.map-canvas { height: 400px; }
57+
```
1358

14-
## Installation
59+
## Options
1560

16-
The repository comes with the modules pre-built and compressed into the `build/` directory.
61+
[google.maps.MapOptions object](https://developers.google.com/maps/documentation/javascript/reference#MapOptions) can be passed through the main directive attribute`ui-map`.
1762

1863
```javascript
19-
angular.module('myApp', ['ui']);
64+
myAppModule.controller('MapCtrl', ['$scope', function ($scope) {
65+
$scope.mapOptions = {
66+
center: new google.maps.LatLng(35.784, -78.670),
67+
zoom: 15,
68+
mapTypeId: google.maps.MapTypeId.ROADMAP
69+
};
70+
}]);
2071
```
2172

22-
The modules can be found in the [Directives](https://github.com/angular-ui/angular-ui/tree/master/modules/directives) and [Filters](https://github.com/angular-ui/angular-ui/tree/master/modules/filters) folders. Check out the readme file associated with each module for specific module usage information.
73+
### UI.Event
2374

24-
## Development
75+
[UI.Event](http://angular-ui.github.io/ui-utils/#/event) allows you to specify custom behavior over user events. You just need to prefix the official event by __map-__ to bind a callback to it.
2576

26-
You do not need to build the project to use it - see above - but if you are working on it then this is what you need to know.
77+
For example, the _click_ or *zoom_changed* event of the [google.maps.Map class](https://developers.google.com/maps/documentation/javascript/reference#Map) can be used through the UI.Event object keys __map-click__ and **map-zoom_changed** :
78+
79+
```html
80+
<section id="map" ng-controller="MapCtrl" >
81+
<div ui-map="myMap"ui-options="mapOptions" class="map-canvas"
82+
ui-event="{'map-click': 'addMarker($event, $params)', 'map-zoom_changed': 'setZoomMessage(myMap.getZoom())' }"
83+
></div>
84+
</section>
85+
```
2786

28-
### Requirements
2987

30-
0. Install [Node.js](http://nodejs.org/) and NPM (should come with)
88+
## Testing
3189

32-
1. Install local dependencies:
90+
We use Karma and jshint to ensure the quality of the code. The easiest way to run these checks is to use grunt:
3391

34-
```bash
35-
$ npm install
92+
```sh
93+
npm install -g grunt-cli
94+
npm install && bower install
95+
grunt
3696
```
3797

38-
2. Install global dependencies `grunt`, `coffee-script`, and `testacular`:
98+
The karma task will try to open Firefox and Chrome as browser in which to run the tests. Make sure this is available or change the configuration in `test\karma.conf.js`
99+
39100

40-
```bash
41-
$ npm install -g testacular coffee-script grunt
101+
### Watch
102+
103+
You can watch files change for your tests with
104+
105+
```sh
106+
grunt watch
42107
```
43108

44-
### Build Files & Run Tests
109+
Make sure to have a Karma server available with it.
45110

46-
Before you commit, always run `grunt` to build and test everything once.
47111

48-
```bash
49-
$ grunt
112+
```sh
113+
grunt server
50114
```
51115

52-
### Test & Develop
116+
(you can force a test on this server with `grunt karma:unit:run`)
117+
118+
119+
### Local Doc
53120

54-
The modules come with unit tests that should be run on any changes and certainly before commiting changes to the project. The unit tests should also provide further insight into the usage of the modules.
121+
The documentation is generated by bower and grunt. To build it run :
55122

56-
First, start the testacular server:
57-
```bash
58-
$ grunt server
123+
```sh
124+
grunt build-doc
59125
```
60-
Then, open your browser to http://localhost:8080 and run the watch command to re-run tests on every save:
61-
```bash
62-
$ grunt watch
126+
127+
And then, launch a built-in web server on the angular-ui-docs bower module
128+
129+
```sh
130+
cd bower_components/angular-ui-docs/
131+
php -S localhost:8000
132+
or
133+
python -m SimpleHTTPServer
63134
```
64135

65-
### Publishing
136+
Then check your [http://localhost:8000/](http://localhost:8000/)
66137

67-
For core team: if you wish to publish a new version follow these steps:
138+
**Tips for fast development** : Inline everything
68139

69-
1. Bump the version number inside `package.json`
70-
2. Build and test
71-
3. Commit the updated `package.json` and `build/` folder on their own commit
72-
4. Tag the commit: `git tag v[maj].[min].[patch]`
73-
5. Push the tag: `git push [angular-ui] master --tags`
140+
```sh
141+
grunt build-doc && cd bower_components/angular-ui-docs/ && php -S localhost:8000 && cd ../..
142+
```

0 commit comments

Comments
 (0)