Skip to content

Commit f743d52

Browse files
committed
issue allenhwkim#334, fixed JSON object string with number in it, which automatically converted to a number, to keep it as it is as a string
1 parent f67fbe9 commit f743d52

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

config/protractor.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
exports.config = {
33
seleniumServerJar: __dirname +
44
'/../node_modules/gulp-protractor' +
5-
'/node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar',
5+
'/node_modules/protractor/selenium/selenium-server-standalone-2.47.1.jar',
66

77
browserName: 'chrome',
88

services/attr2_options.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
}
7979
else if (output === Object(output)) { // JSON is an object (not array or null)
8080
// check for nested hashes and convert to Google API options
81-
output = getOptions(output, options);
81+
output = getOptions(output, options, true);
8282
}
8383
} catch(err2) {
8484
// 3. Object Expression. i.e. LatLng(80,-49)
@@ -204,7 +204,7 @@
204204
* @param {scope} scope angularjs scope
205205
* @returns {Hash} options converted attributess
206206
*/
207-
var getOptions = function(attrs, scope) {
207+
var getOptions = function(attrs, scope, doNotConverStringToNumber) {
208208
var options = {};
209209
for(var key in attrs) {
210210
if (attrs[key]) {
@@ -217,7 +217,11 @@
217217
if (typeof attrs[key] !== 'string') {
218218
options[key] = attrs[key];
219219
} else {
220-
options[key] = toOptionValue(attrs[key], {scope:scope, key: key});
220+
if (doNotConverStringToNumber && attrs[key].match(/^[0-9]+$/)) {
221+
options[key] = attrs[key];
222+
} else {
223+
options[key] = toOptionValue(attrs[key], {scope:scope, key: key});
224+
}
221225
}
222226
}
223227
} // if (attrs[key])

testapp/marker_with_label.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!doctype html>
2+
<html>
3+
4+
<head>
5+
<script src="http://code.angularjs.org/1.4.6/angular.js"></script>
6+
<script src="http://maps.google.com/maps/api/js"></script>
7+
<!--
8+
<script src="../build/scripts/ng-map.min.js"></script>
9+
-->
10+
<script src="../app.js"></script>
11+
<script src="../directives/map_controller.js"></script>
12+
<script src="../directives/map.js"></script>
13+
<script src="../directives/marker.js"></script>
14+
<script src="../directives/shape.js"></script>
15+
<script src="../services/geo_coder.js"></script>
16+
<script src="../services/navigator_geolocation.js"></script>
17+
<script src="../services/attr2_options.js"></script>
18+
<script>
19+
var app = angular.module('myApp', ['ngMap']);
20+
21+
app.controller('MapCtrl', function($scope) {
22+
$scope.results = [
23+
{
24+
id: "ChIJmzrzi9Y0K4gRgXUc3sTY7RU", // This fails
25+
lat: 57.479541,
26+
lng: -4.225208
27+
}
28+
];
29+
});
30+
</script>
31+
</head>
32+
33+
<body ng-app="myApp">
34+
<map ng-controller="MapCtrl" center="57.5,-4" zoom="8">
35+
<marker
36+
id="{{info.id}}"
37+
ng-repeat="info in results"
38+
position="{{info.lat}}, {{info.lng}}"
39+
label='{ text: "3" }'></marker>
40+
</map>
41+
</body>
42+
43+
</html>

0 commit comments

Comments
 (0)