MOGSY Posted March 22, 2018 Share Posted March 22, 2018 Hi I have the following Javascript added to get current location, and receive the Ajaxevent no problem, however the event keeps firing continuously, how is possible to control the firing of the event? regards UniSession.AddJS( 'navigator.geolocation.getCurrentPosition'+ '( '+ 'function(position)'+ '{ '+ ' ajaxRequest(navigateFrame.UnimHTMLFrame1, "_GeoLocation" ,' + ' ["lat=" + position.coords.latitude, ' + ' "lng=" + position.coords.longitude, ' + ' "acc=" + position.coords.accuracy, ' + ' "alt=" + position.coords.altitude, ' + ' "altacc=" + position.coords.altitudeAccuracy, ' + ' "head=" + position.coords.heading, ' + ' "ts=" + position.coords.timestamp ' + ' ]);' + '} '+ ', '+ 'function(error)'+ '{ '+ ' switch(error.code) '+ ' { '+ ' case 0: '+ // UnKown ' alert(error.message); '+ ' break; '+ ' case 1: '+ // Denied ' alert(error.message); '+ ' break; '+ ' case 2: '+ // UnAvailable ' alert(error.message); '+ ' break; '+ ' case 3: '+ // TimeOut ' alert(error.message); '+ ' break; '+ ' } '+ '} '+ ') ' ); procedure xxx.UnimHTMLFrame1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if SameText(EventName, 'loaded') then begin ............. end; end else if SameText(EventName, '_GeoLocation') then begin if (Params.Values['lat'] <> '') then begin Lat:= strToFloat(Params.Values['lat']); Long:= strToFloat(Params.Values['lng']); end; end; end; Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted March 22, 2018 Share Posted March 22, 2018 https://stackoverflow.com/questions/15951952/stop-execution-of-the-getcurrentposition-method 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.