import Utils from './Utils' ; export class LocationData { module : string ; type : string ; adcode : string ; nation : string ; province : string ; city : string ; district : string ; addr : string ; lat : number ; lng : number ; accuracy : number ; } const targetOrigin = 'https://apis.map.qq.com' ; var iframe = document . createElement ( "iframe" ) ; class Locator { public static getLocation ( ) { iframe . contentWindow . postMessage ( 'getLocation' , targetOrigin ) ; } public static getRobustLocation ( ) { iframe . contentWindow . postMessage ( 'getLocation.robust' , targetOrigin ) ; } public static watchPosition ( ) { iframe . contentWindow . postMessage ( 'watchPosition' , targetOrigin ) ; } public static clearWatch ( ) { iframe . contentWindow . postMessage ( 'clearWatch' , targetOrigin ) ; } } ( function ( ) { window . addEventListener ( 'message' , function ( event ) { var data = event . data ; if ( data && data . module === 'geolocation' ) { Utils . publish ( 'location' , event . data ) ; } } , false ) ; iframe . setAttribute ( "width" , "0" ) ; iframe . setAttribute ( "height" , "0" ) ; iframe . setAttribute ( "frameborder" , "0" ) ; iframe . setAttribute ( "scrolling" , "no" ) ; iframe . style . display = "none" ; iframe . setAttribute ( "src" , `${ targetOrigin }/tools/geolocation?key=YLZBZ-XDPKU-LWMV6-2WNPB-PL5W5-H6BGL&referer=WebGlobe` ) ; document . body . appendChild ( iframe ) ; } ) ( ) ; export default Locator ;