Jump to content

du1000brazil

uniGUI Subscriber
  • Posts

    10
  • Joined

  • Last visited

Posts posted by du1000brazil

  1. Hello, I created this new procedure, so that there is no waypoint limit, google limits it by 25 points.

    Only I can not remove after I have created. can you help me?? To remove all created routes. With the procedure "RemoveAllRoutes" deletes only the last route created ..

     

    procedure TUniGMap.RouteUnlimitedWaypoints(DirectionsRequest: TDirectionsRequest);

    var

      Script: string;

      tm: string; // travelmode

      us: string; // unitSystem

    begin

     

      case DirectionsRequest.travelMode of

        tmDRIVING: tm := 'DRIVING';

        tmBICYCLING: tm := 'BICYCLING';

        tmTRANSIT: tm := 'TRANSIT';

        tmWALKING: tm := 'WALKING';

      else

        tm := 'DRIVING';

      end;

     

      case DirectionsRequest.unitSystem of

        usMETRIC: us := 'METRIC';

        usIMPERIAL: us := 'IMPERIAL';

      else

        us := 'METRIC';

      end;

     

      Script :=

      'var service = new google.maps.DirectionsService;  '+

      'var stations = [@waypoints@];'+

      'var lngs = stations.map(function(station) { return station.lng; });'+

      'var lats = stations.map(function(station) { return station.lat; });'+

      '@googleMap@.fitBounds({'+

          'west: Math.min.apply(null, lngs),'+

          'east: Math.max.apply(null, lngs),'+

          'north: Math.min.apply(null, lats),'+

          'south: Math.max.apply(null, lats),'+

      '});              '+

      '    '+

      'for (var i = 0, parts = [], max = 25 - 1; i < stations.length; i = i + max)'+

              'parts.push(stations.slice(i, i + max + 1));    '+

      ''+

      'var service_callback = function(response, status) {'+

          'if (status != "OK") {'+

              'console.log("Directions request failed due to " + status);'+

              'return;'+

          '}'+

          'directionsDisplay = new google.maps.DirectionsRenderer;'+

          'directionsDisplay.setMap(@googleMap@);'+

          'directionsDisplay.setOptions({ draggable: @draggable@, suppressMarkers: @suppressMarkers@, preserveViewport: true });'+

          'directionsDisplay.setDirections(response);'+

      '};'+

      ''+

      ''+

      ''+

      'for (var i = 0; i < parts.length; i++) {'+

      '   '+

      '    var waypoints = [];'+

          'for (var j = 1; j < parts.length - 1; j++)'+

              'waypoints.push({location: parts[j], stopover: false});'+

      '   '+

      '    var service_options = {'+

              'origin                   : parts[0],'+

              'destination              : parts[parts.length - 1],'+

              'travelMode               : google.maps.DirectionsTravelMode.@travelMode@,'+

              'unitSystem               : google.maps.UnitSystem.@unitSystem@,'+

              'waypoints                : waypoints,'+

              'avoidHighways            : @avoidHighways@,   '+

              'provideRouteAlternatives : false,   '+

              'avoidTolls               : @avoidTolls@'+

          '};'+

      ''+

          'service.route(service_options, service_callback);  '+

      ' '+

      '}';

     

    //  myTextReplace(Script, '@origin@', DirectionsRequest.origin);

    //  myTextReplace(Script, '@destination@', DirectionsRequest.destination);

      myTextReplace(Script, '@waypoints@', DirectionsRequest.waypoints);

      myTextReplace(Script, '@travelMode@', tm);

      myTextReplace(Script, '@unitSystem@', us);

      myTextReplace(Script, '@avoidHighways@', LowerCase(BoolToStr(DirectionsRequest.avoidHighways, true)));

      myTextReplace(Script, '@avoidTolls@', LowerCase(BoolToStr(DirectionsRequest.avoidTolls, true)));

      myTextReplace(Script, '@draggable@', LowerCase(BoolToStr(DirectionsRequest.draggable, true)));

      myTextReplace(Script, '@suppressMarkers@', LowerCase(BoolToStr(DirectionsRequest.suppressMarkers, true)));

    //  myTextReplace(Script, '@EventHandler@', EventHandler);

     

      ExecJScript(Script);

     

    end;
  2. When the component is being created, it adds the necessary paths in ServerModule.CustomFiles.

    So, there must be an instance of uniGmap on your FIRST form.

     

    I always suggest to place an invisible uniGmap on your MainForm or LoginForm.

     

    Thank you very much Motto, great work! I'll try.

×
×
  • Create New...