1313// limitations under the License.
1414import { Component } from '@angular/core' ;
1515import { FormBuilder } from '@angular/forms' ;
16+ import { DomSanitizer , SafeUrl } from '@angular/platform-browser' ;
1617import { Platform } from 'ionic-angular' ;
1718import { Geolocation , GeolocationOptions } from '@ionic-native/geolocation' ;
1819import { AddonModDataFieldPluginComponent } from '../../../classes/field-plugin-component' ;
@@ -30,8 +31,11 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
3031 north : number ;
3132 east : number ;
3233
33- constructor ( protected fb : FormBuilder , private platform : Platform , private geolocation : Geolocation ,
34- private domUtils : CoreDomUtilsProvider ) {
34+ constructor ( protected fb : FormBuilder ,
35+ protected platform : Platform ,
36+ protected geolocation : Geolocation ,
37+ protected domUtils : CoreDomUtilsProvider ,
38+ protected sanitizer : DomSanitizer ) {
3539 super ( fb ) ;
3640 }
3741
@@ -58,16 +62,19 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
5862 * @param east Degrees East.
5963 * @return Link to maps depending on platform.
6064 */
61- getLatLongLink ( north : number , east : number ) : string {
65+ getLatLongLink ( north : number , east : number ) : SafeUrl {
6266 if ( north !== null || east !== null ) {
63- const northFixed = north ? north . toFixed ( 4 ) : '0.0000' ,
64- eastFixed = east ? east . toFixed ( 4 ) : '0.0000' ;
67+ const northFixed = north ? north . toFixed ( 4 ) : '0.0000' ;
68+ const eastFixed = east ? east . toFixed ( 4 ) : '0.0000' ;
69+ let url ;
6570
6671 if ( this . platform . is ( 'ios' ) ) {
67- return 'http://maps.apple.com/?ll=' + northFixed + ',' + eastFixed + '&near=' + northFixed + ',' + eastFixed ;
72+ url = 'http://maps.apple.com/?ll=' + northFixed + ',' + eastFixed + '&near=' + northFixed + ',' + eastFixed ;
73+ } else {
74+ url = 'geo:' + northFixed + ',' + eastFixed ;
6875 }
6976
70- return 'geo:' + northFixed + ',' + eastFixed ;
77+ return this . sanitizer . bypassSecurityTrustUrl ( url ) ;
7178 }
7279 }
7380
0 commit comments