1414
1515angular . module ( 'mm.addons.mod_data' )
1616
17+ . filter ( 'mmaModDataFieldLatLongFormat' , function ( ) {
18+ return function ( value ) {
19+ var north = ( value && parseFloat ( value . content ) ) || "" ,
20+ east = ( value && parseFloat ( value . content1 ) ) || "" ;
21+
22+ if ( north !== '' || east !== '' ) {
23+ north = north ? north . toFixed ( 4 ) : '0.0000' ;
24+ east = east ? east . toFixed ( 4 ) : '0.0000' ;
25+
26+ var latitude = north < 0 ? - north + '°S' : north + '°N' ,
27+ longitude = east < 0 ? - east + '°W' : east + '°E' ,
28+ link = ionic . Platform . isAndroid ( ) ? 'geo:' + north + ',' + east :
29+ 'http://maps.apple.com/?ll=' + north + ',' + east + '&near=' + north + ',' + east ;
30+
31+ return '<a href="' + link + '">' + latitude + ' ' + longitude + '</a>' ;
32+ }
33+ } ;
34+ } )
35+
1736/**
1837 * Directive to render data latlong field.
1938 *
@@ -29,22 +48,9 @@ angular.module('mm.addons.mod_data')
2948 link : function ( scope ) {
3049 scope . mode = scope . mode == 'list' ? 'show' : scope . mode ;
3150 if ( scope . value ) {
32- scope . north = ( scope . value && parseFloat ( scope . value . content ) ) || "" ;
33- scope . east = ( scope . value && parseFloat ( scope . value . content1 ) ) || "" ;
34-
35- if ( scope . mode == 'show' ) {
36- if ( scope . north != "" || scope . east != "" ) {
37- scope . north = scope . north ? parseFloat ( scope . north ) . toFixed ( 4 ) : '0.0000' ;
38- scope . east = scope . east ? parseFloat ( scope . east ) . toFixed ( 4 ) : '0.0000' ;
39- scope . latitude = scope . north < 0 ? - scope . north + '°S' : scope . north + '°N' ;
40- scope . longitude = scope . east < 0 ? - scope . east + '°W' : scope . east + '°E' ;
41-
42- if ( ionic . Platform . isIOS ( ) ) {
43- scope . link = "http://maps.apple.com/?ll=" + scope . north + "," + scope . east + "&near=" + scope . north + "," + scope . east ;
44- } else {
45- scope . link = "geo:" + scope . north + "," + scope . east ;
46- }
47- }
51+ if ( scope . mode == 'edit' ) {
52+ scope . north = ( scope . value && parseFloat ( scope . value . content ) ) || "" ;
53+ scope . east = ( scope . value && parseFloat ( scope . value . content1 ) ) || "" ;
4854 }
4955 }
5056 }
0 commit comments