Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Commit a9b8dea

Browse files
committed
Merge pull request #80 from dmitrybelyakov/r1-dev
[r1-dev] Get map options from scope, instead of parsing HTML-embedded JSON
2 parents 5676eff + 8b9a46c commit a9b8dea

File tree

7 files changed

+58
-50
lines changed

7 files changed

+58
-50
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ old/
66
tmp/
77
*~
88
app/components
9-
/nbproject
9+
/nbproject
10+
.idea

Gruntfile.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ module.exports = function(grunt) {
1111
grunt.loadNpmTasks('grunt-open');
1212
grunt.loadNpmTasks('grunt-mkdir');
1313
grunt.loadNpmTasks('grunt-contrib-coffee');
14-
14+
1515

1616
// Project configuration.
1717
grunt.initConfig({
18-
18+
1919
pkg: grunt.file.readJSON('package.json'),
20-
20+
2121
clean: {
2222
coffee: ['tmp/output_coffee.js'],
2323
dist: ['dist/*', 'tmp'],
2424
example: ['example/<%= pkg.name %>.js']
2525
},
26-
26+
2727
mkdir: {
2828
all: {
2929
options: {
@@ -36,7 +36,7 @@ module.exports = function(grunt) {
3636
coffee: {
3737
compile: {
3838
files: {
39-
'tmp/output_coffee.js':
39+
'tmp/output_coffee.js':
4040
['src/coffee/*.coffee',
4141
'src/coffee/oo/ng-gmap-module.coffee',
4242
'src/coffee/oo/base-object.coffee',
@@ -48,20 +48,20 @@ module.exports = function(grunt) {
4848
}
4949
}
5050
},
51-
51+
5252
concat: {
5353
options: {
5454
separator: ';'
5555
},
5656
dist: {
57-
src: ['src/js/module.js',
57+
src: ['src/js/module.js',
5858
'tmp/output_coffee.js',
59-
'src/js/utils/LatLngArraySync.js',
60-
'src/js/utils/MapEvents.js',
59+
'src/js/utils/LatLngArraySync.js',
60+
'src/js/utils/MapEvents.js',
6161
'src/js/controllers/polyline-display.js',
62-
'src/js/directives/map.js',
63-
'src/js/directives/marker.js',
64-
'src/js/directives/markers.js',
62+
'src/js/directives/map.js',
63+
'src/js/directives/marker.js',
64+
'src/js/directives/markers.js',
6565
'src/js/directives/polygon.js',
6666
'src/js/directives/polyline.js',
6767
'src/js/directives/window.js',
@@ -72,12 +72,12 @@ module.exports = function(grunt) {
7272
example: {
7373
src: ['src/js/module.js',
7474
'tmp/output_coffee.js',
75-
'src/js/utils/LatLngArraySync.js',
76-
'src/js/utils/MapEvents.js',
75+
'src/js/utils/LatLngArraySync.js',
76+
'src/js/utils/MapEvents.js',
7777
'src/js/controllers/polyline-display.js',
78-
'src/js/directives/map.js',
79-
'src/js/directives/marker.js',
80-
'src/js/directives/markers.js',
78+
'src/js/directives/map.js',
79+
'src/js/directives/marker.js',
80+
'src/js/directives/markers.js',
8181
'src/js/directives/polygon.js',
8282
'src/js/directives/polyline.js',
8383
'src/js/directives/window.js',
@@ -86,7 +86,7 @@ module.exports = function(grunt) {
8686
dest: 'example/<%= pkg.name %>.js'
8787
}
8888
},
89-
89+
9090
copy: {
9191
dist: {
9292
files: [{
@@ -95,7 +95,7 @@ module.exports = function(grunt) {
9595
}]
9696
}
9797
},
98-
98+
9999
uglify: {
100100
options: {
101101
banner: '/*! <%= pkg.name %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %>\n * <%= pkg.description %>\n * <%= pkg.repository.type %>: <%= pkg.repository.url %>\n */\n',
@@ -107,29 +107,29 @@ module.exports = function(grunt) {
107107
dest: 'dist/<%= pkg.name %>.min.js'
108108
}
109109
},
110-
110+
111111
jshint: {
112112
all: ['Gruntfile.js', 'src/js/**/*.js', 'test/js/**/*.js']
113113
},
114-
114+
115115
test: {
116-
116+
117117
},
118-
118+
119119
watch: {
120120
all: {
121121
options: { livereload: true },
122122
files: ['src/js/**/*.js','src/coffee/**/*.coffee','src/coffee/*.coffee'],
123123
tasks: ['clean:example','coffee','concat:example'],
124124
},
125125
},
126-
126+
127127
open: {
128128
example: {
129129
path: 'http://localhost:3000/example.html'
130130
}
131131
},
132-
132+
133133
connect: {
134134
server: {
135135
options: {
@@ -147,14 +147,14 @@ module.exports = function(grunt) {
147147

148148
// Default task: build a release in dist/
149149
grunt.registerTask('default', ['clean:dist',
150-
'test',
151-
'jshint',
152-
'mkdir',
150+
'test',
151+
'jshint',
152+
'mkdir',
153153
'coffee',
154-
'concat:dist',
154+
'concat:dist',
155155
'copy:dist',
156156
'uglify']);
157-
157+
158158
// Run the example page by creating a local copy of angular-google-maps.js
159159
// and running a webserver on port 3000 with livereload. Web page is opened
160160
// automatically in the default browser.

dist/angular-google-maps.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ angular.module('google-maps')
14831483
.directive('googleMap', ['$log', '$timeout', function ($log, $timeout) {
14841484

14851485
"use strict";
1486-
1486+
14871487
directives.api.utils.Logger.logger = $log;
14881488

14891489
var DEFAULTS = {
@@ -1542,7 +1542,8 @@ angular.module('google-maps')
15421542
markers: '=markers', // optional
15431543
refresh: '&refresh', // optional
15441544
windows: '=windows', // optional
1545-
events: '=events', // optional
1545+
options: '=options', // optional
1546+
events: '=events', // optional
15461547
bounds: '=bounds'
15471548
},
15481549

@@ -1587,7 +1588,7 @@ angular.module('google-maps')
15871588
// Parse options
15881589
var opts = {options: {}};
15891590
if (attrs.options) {
1590-
opts.options = angular.fromJson(attrs.options);
1591+
opts.options = scope.options;
15911592
}
15921593

15931594
if (attrs.type) {
@@ -1654,7 +1655,7 @@ angular.module('google-maps')
16541655
google.maps.event.addListener(_m, 'center_changed', function () {
16551656
var c = _m.center;
16561657

1657-
if(settingCenterFromScope)
1658+
if(settingCenterFromScope)
16581659
return; //if the scope notified this change then there is no reason to update scope otherwise infinite loop
16591660
$timeout(function () {
16601661
scope.$apply(function (s) {
@@ -1757,7 +1758,7 @@ angular.module('google-maps')
17571758

17581759
//_m.draw();
17591760
});
1760-
1761+
17611762
scope.$watch('bounds', function (newValue, oldValue) {
17621763
if (newValue === oldValue) {
17631764
return;

dist/angular-google-maps.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/example-controller.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ function ExampleController ($scope, $timeout, $log) {
2121
latitude: 45,
2222
longitude: -73
2323
},
24+
options: {
25+
streetViewControl: false,
26+
panControl: false
27+
},
2428
zoom: 3,
2529
dragging: false,
2630
bounds: {},
@@ -169,7 +173,7 @@ function ExampleController ($scope, $timeout, $log) {
169173
});
170174

171175
_.each($scope.map.markers,function(marker){
172-
marker.closeClick = function(){
176+
marker.closeClick = function(){
173177
marker.showWindow = false;
174178
$scope.$apply();
175179
};
@@ -179,7 +183,7 @@ function ExampleController ($scope, $timeout, $log) {
179183
});
180184

181185
_.each($scope.map.markers2,function(marker){
182-
marker.closeClick = function(){
186+
marker.closeClick = function(){
183187
marker.showWindow = false;
184188
$scope.$apply();
185189
};
@@ -219,7 +223,7 @@ function ExampleController ($scope, $timeout, $log) {
219223
}
220224
];
221225
_.each(dynamicMarkers,function(marker){
222-
marker.closeClick = function(){
226+
marker.closeClick = function(){
223227
marker.showWindow = false;
224228
$scope.$apply();
225229
};

example/example.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
<!--[if IE]>
99
<script>
1010
window.html5 = {
11-
'elements': 'marker window windows markers trafficlayer polyline'
11+
'elements': 'marker window windows markers trafficlayer polyline'
1212
};
1313
</script>
14-
14+
1515
<script src="es5-shim.js"></script>
1616
<script src="event-shim.js"></script>
1717
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
1818
<![endif]-->
19-
19+
2020
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
2121
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,800,600,300,700' rel='stylesheet' type='text/css'>
2222
<style>
@@ -74,7 +74,8 @@ <h1>angular-google-maps example</h1>
7474
draggable="true"
7575
dragging="map.dragging"
7676
bounds="map.bounds"
77-
events="map.events">
77+
events="map.events"
78+
options="map.options">
7879
<trafficlayer show="map.showTraffic" />
7980

8081
<markers models="map.markers2" coords="'self'" icon="'icon'" click="'onClicked'">

src/js/directives/map.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ angular.module('google-maps')
3131
.directive('googleMap', ['$log', '$timeout', function ($log, $timeout) {
3232

3333
"use strict";
34-
34+
3535
directives.api.utils.Logger.logger = $log;
3636

3737
var DEFAULTS = {
@@ -90,7 +90,8 @@ angular.module('google-maps')
9090
markers: '=markers', // optional
9191
refresh: '&refresh', // optional
9292
windows: '=windows', // optional
93-
events: '=events', // optional
93+
options: '=options', // optional
94+
events: '=events', // optional
9495
bounds: '=bounds'
9596
},
9697

@@ -135,7 +136,7 @@ angular.module('google-maps')
135136
// Parse options
136137
var opts = {options: {}};
137138
if (attrs.options) {
138-
opts.options = angular.fromJson(attrs.options);
139+
opts.options = scope.options;
139140
}
140141

141142
if (attrs.type) {
@@ -202,7 +203,7 @@ angular.module('google-maps')
202203
google.maps.event.addListener(_m, 'center_changed', function () {
203204
var c = _m.center;
204205

205-
if(settingCenterFromScope)
206+
if(settingCenterFromScope)
206207
return; //if the scope notified this change then there is no reason to update scope otherwise infinite loop
207208
$timeout(function () {
208209
scope.$apply(function (s) {
@@ -305,7 +306,7 @@ angular.module('google-maps')
305306

306307
//_m.draw();
307308
});
308-
309+
309310
scope.$watch('bounds', function (newValue, oldValue) {
310311
if (newValue === oldValue) {
311312
return;

0 commit comments

Comments
 (0)