@@ -440,6 +440,8 @@ exports.default = {
440440 } ) ;
441441 } ,
442442 addControls : function addControls ( map ) {
443+ var _this2 = this ;
444+
443445 //Nav Control
444446 if ( this . navControl . show ) {
445447 var nav = new mapboxgl . NavigationControl ( ) ;
@@ -450,6 +452,22 @@ exports.default = {
450452 if ( this . geolocateControl . show ) {
451453 var geolocate = new mapboxgl . GeolocateControl ( this . geolocateControl . options ) ;
452454 map . addControl ( geolocate , this . geolocateControl . position ) ;
455+
456+ geolocate . on ( 'geolocate' , function ( position ) {
457+ _this2 . $emit ( 'geolocate-geolocate' , geolocate , position ) ;
458+ } ) ;
459+
460+ geolocate . on ( 'trackuserlocationstart' , function ( ) {
461+ _this2 . $emit ( 'geolocate-trackuserlocationstart' , geolocate ) ;
462+ } ) ;
463+
464+ geolocate . on ( 'trackuserlocationend' , function ( ) {
465+ _this2 . $emit ( 'geolocate-trackuserlocationend' , geolocate ) ;
466+ } ) ;
467+
468+ geolocate . on ( 'error' , function ( positionError ) {
469+ _this2 . $emit ( 'geolocate-error' , geolocate , positionError ) ;
470+ } ) ;
453471 }
454472
455473 //Scale Control
@@ -539,6 +557,18 @@ var app = new Vue({
539557 var features = map . queryRenderedFeatures ( e . point , { layers : [ 'points' ] } ) ;
540558 map . getCanvas ( ) . style . cursor = features . length ? 'pointer' : '' ;
541559 } ,
560+ geolocate : function geolocate ( control , position ) {
561+ console . log ( 'User position: ' + position . coords . latitude + ', ' + position . coords . longitude ) ;
562+ } ,
563+ geolocateError : function geolocateError ( control , positionError ) {
564+ console . log ( positionError ) ;
565+ } ,
566+ geolocateStart : function geolocateStart ( control ) {
567+ console . log ( 'geolocate started' ) ;
568+ } ,
569+ geolocateEnd : function geolocateEnd ( control ) {
570+ console . log ( 'geolocate ended' ) ;
571+ } ,
542572 addPopUp : function addPopUp ( map , e ) {
543573 var features = map . queryRenderedFeatures ( e . point , { layers : [ 'points' ] } ) ;
544574 if ( ! features . length ) {
0 commit comments