GPS mobile application with polyline

0

Do you have a working mobile gps application tutorial based on Delphi? I mean with LocationSensor that is correctly waiting for a real gps signal, then put a marker on a TMapView component. If the marker is moving then draw a continous polyline on the map? I can create polyline, but after it's created I cannot add a new point. How can I wait for the GPS signal?  

Responses (1)
  • Accepted Answer

    Monday, January 09 2017, 12:35 AM - #Permalink
    0

    Here you can get a small tutorial using TLocationSensor and TViewMap in Android:

    http://neftali.clubdelphi.com/visualizando-y-utilizando-mapas-componente-tmapview/

    It's in spanish, but you can use authomatic translation and see the code.

    You can move a Marker, deleting an existing and create a new one in the new location. Unfortunally thera are a small error in the opolylines and you can't not to this with polylines. See this error:

    https://quality.embarcadero.com/browse/RSP-10364

    You can test the state of the sensor using the property:

      case LocationSensor1.Sensor.State of
        TSensorState.Added:         Log('   State: Added');
        TSensorState.Removed:       Log('   State: Removed');
        TSensorState.Initializing:  Log('   State: Initializing');
        TSensorState.Ready:         Log('   State: Ready');
        TSensorState.NoData:        Log('   State: NoData');
        TSensorState.AccessDenied:  Log('   State: Access denied');
        TSensorState.Error:         Log('   State: Error');
      end;



    Your GPS position can be calculated using GPS or WIFI. I use this procedure to know if the providers of positioning are actives:

    {$IFDEF ANDROID}
    
    function IsProviderEnabled(const Provider: JString): Boolean;
    var
      LocationManagerObj: JObject;
      LocationManager: JLocationManager;
    begin
      try
        LocationManagerObj := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.LOCATION_SERVICE);
        LocationManager := TJLocationManager.Wrap(LocationManagerObj);
        Result := LocationManager.isProviderEnabled(Provider);
      except
        on E:Exception do begin
          Log('Error: ' + E.Message);
        end;
      end;
    end;
    {$ENDIF}
    
    begin
    {$IFDEF ANDROID}
      LocationGPSActive := IsProviderEnabled(TJLocationManager.JavaClass.GPS_PROVIDER);
      LocationWIFIActive := IsProviderEnabled(TJLocationManager.JavaClass.NETWORK_PROVIDER);
    {$ENDIF}
    
    {$IFDEF WINDOWS}
      LocationGPSActive := True;
      LocationWIFIActive := True;
    {$ENDIF}
    end;



     

    The reply is currently minimized Show
Your Reply

Please login to post a reply