הטמעה של חיפוש מסלולי נסיעה בממשק המשתמש (גרסה 3)

אתם יכולים לשלב את התכונה 'חיפוש נסיעות' בממשק המשתמש שלכם כדי לאפשר למחפשי עבודה לחפש משרות באזור גיאוגרפי שהוגדר לפי זמן הנסיעה. החיפוש של נסיעות לעבודה מעריך את זמן הנסיעה על סמך אמצעי התחבורה שהמשתמש בחר והשעה ביום שבה הוא מתכנן לנסוע.

  1. כדי להטמיע את התכונה 'חיפוש נסיעות', צריך לקשר את Cloud Talent Solution לממשק המשתמש. כדי להגדיר את Cloud Talent Solution, תוכלו להיעזר במדריכים למתחילים.

  2. התכונה 'חיפוש נסיעה לעבודה' משתמשת בנתוני הכתובות שהעליתם עם המשרות במהלך ההטמעה של CTS כדי לחשב את זמן הנסיעה לעבודה. כדי להפעיל את התכונה הזו בממשק המשתמש הקיים של CTS, שולחים בקשת jobs.search וכוללים אובייקט CommuteFilter בשדה JobQuery.commuteFilter. השדות commuteMethod,‏ travelDuration ו-startCoordinates הם שדות חובה.

    Java

    מידע נוסף על התקנה ויצירה של לקוח Cloud Talent Solution זמין במאמר ספריות לקוח של Cloud Talent Solution.

    
    public static void commuteSearch(String companyName) throws IOException, InterruptedException {
      // Make sure to set the requestMetadata the same as the associated search request
      RequestMetadata requestMetadata =
          new RequestMetadata()
              // Make sure to hash your userID
              .setUserId("HashedUserId")
              // Make sure to hash the sessionID
              .setSessionId("HashedSessionID")
              // Domain of the website where the search is conducted
              .setDomain("www.google.com");
      JobQuery jobQuery =
          new JobQuery()
              .setCommuteFilter(
                  new CommuteFilter()
                      .setRoadTraffic("TRAFFIC_FREE")
                      .setCommuteMethod("TRANSIT")
                      .setTravelDuration("1000s")
                      .setStartCoordinates(
                          new LatLng().setLatitude(37.422408).setLongitude(-122.085609)));
      if (companyName != null) {
        jobQuery.setCompanyNames(Arrays.asList(companyName));
      }
    
      SearchJobsRequest searchJobsRequest =
          new SearchJobsRequest()
              .setJobQuery(jobQuery)
              .setRequestMetadata(requestMetadata)
              .setJobView("JOB_VIEW_FULL")
              .setRequirePreciseResultSize(true);
      SearchJobsResponse response =
          talentSolutionClient
              .projects()
              .jobs()
              .search(DEFAULT_PROJECT_ID, searchJobsRequest)
              .execute();
      Thread.sleep(1000);
      System.out.printf("Search jobs for commute results: %s\n", response);
    }

    Python

    מידע נוסף על התקנה ויצירה של לקוח Cloud Talent Solution זמין במאמר ספריות לקוח של Cloud Talent Solution.

    def commute_search(client_service, company_name):
        request_metadata = {
            "user_id": "HashedUserId",
            "session_id": "HashedSessionId",
            "domain": "www.google.com",
        }
        start_location = {"latitude": 37.422408, "longitude": -122.085609}
        commute_preference = {
            "road_traffic": "TRAFFIC_FREE",
            "commute_method": "TRANSIT",
            "travel_duration": "1000s",
            "start_coordinates": start_location,
        }
        job_query = {"commute_filter": commute_preference}
        if company_name is not None:
            job_query.update({"company_names": [company_name]})
        request = {
            "job_query": job_query,
            "request_metadata": request_metadata,
            "job_view": "JOB_VIEW_FULL",
            "require_precise_result_size": True,
        }
        response = (
            client_service.projects().jobs().search(parent=parent, body=request).execute()
        )
        print(response)
    
    

    Go

    מידע נוסף על התקנה ויצירה של לקוח Cloud Talent Solution זמין במאמר ספריות לקוח של Cloud Talent Solution.

    
    // commuteSearch searches for jobs within commute filter.
    func commuteSearch(w io.Writer, projectID, companyName string) (*talent.SearchJobsResponse, error) {
    	ctx := context.Background()
    
    	client, err := google.DefaultClient(ctx, talent.CloudPlatformScope)
    	if err != nil {
    		return nil, fmt.Errorf("google.DefaultClient: %w", err)
    	}
    	// Create the jobs service client.
    	service, err := talent.New(client)
    	if err != nil {
    		return nil, fmt.Errorf("talent.New: %w", err)
    	}
    
    	jobQuery := &talent.JobQuery{
    		CommuteFilter: &talent.CommuteFilter{
    			RoadTraffic:    "TRAFFIC_FREE",
    			CommuteMethod:  "TRANSIT",
    			TravelDuration: "1000s",
    			StartCoordinates: &talent.LatLng{
    				Latitude:  37.422408,
    				Longitude: -122.085609,
    			},
    		},
    	}
    	if companyName != "" {
    		jobQuery.CompanyNames = []string{companyName}
    	}
    
    	parent := "projects/" + projectID
    	req := &talent.SearchJobsRequest{
    		// Make sure to set the RequestMetadata the same as the associated
    		// search request.
    		RequestMetadata: &talent.RequestMetadata{
    			// Make sure to hash your userID.
    			UserId: "HashedUsrId",
    			// Make sure to hash the sessionID.
    			SessionId: "HashedSessionId",
    			// Domain of the website where the search is conducted.
    			Domain: "www.googlesample.com",
    		},
    		// Set the actual search term as defined in the jobQuery.
    		JobQuery: jobQuery,
    		// Set the search mode to a regular search.
    		SearchMode:               "JOB_SEARCH",
    		RequirePreciseResultSize: true,
    	}
    	resp, err := service.Projects.Jobs.Search(parent, req).Do()
    	if err != nil {
    		return nil, fmt.Errorf("failed to search for jobs with commute filter: %w", err)
    	}
    	return resp, nil
    }
    

    Ruby

    מידע נוסף על התקנה ויצירה של לקוח Cloud Talent Solution זמין במאמר ספריות לקוח של Cloud Talent Solution.

    # project_id              = "Id of the project"
    # commute_method          = "The method of transportation for which to calculate the commute time"
    # travel_duration         = "The maximum travel time in seconds"
    # start_coordinates       = "The latitude and longitude of the location from which to calculate the commute time"
    
    require "google/apis/jobs_v3"
    
    jobs = Google::Apis::JobsV3
    talent_solution_client = jobs::CloudTalentSolutionService.new
    # @see https://developers.google.com/identity/protocols/application-default-credentials#callingruby
    talent_solution_client.authorization = Google::Auth.get_application_default(
      "https://www.googleapis.com/auth/jobs"
    )
    
    # Make sure to set the request_metadata the same as the associated search request
    request_metadata = jobs::RequestMetadata.new user_id:    "HashedUserId",
                                                 session_id: "HashedSessionId",
                                                 domain:     "www.google.com"
    # Set location filter
    commute_filter = jobs::CommuteFilter.new road_traffic:      "TRAFFIC_FREE",
                                             commute_method:    commute_method,
                                             travel_duration:   travel_duration,
                                             start_coordinates: start_coordinates
    # Perform a search for analyst  related jobs
    search_jobs_request =
      jobs::SearchJobsRequest.new request_metadata:            request_metadata,
                                  job_query:                   (jobs::JobQuery.new commute_filter: commute_filter),
                                  job_view:                    "JOB_VIEW_FULL",
                                  require_precise_result_size: true
    search_jobs_response = talent_solution_client.search_jobs project_id, search_jobs_request
    puts search_jobs_response.to_json
    search_jobs_response

המלצות לממשק המשתמש

  1. ב-Cloud Talent Solution אי אפשר לחפש לפי מרחק (באמצעות מסנן המיקום של CTS) וגם לפי זמן נסיעה. כדי לאפשר למועמדים לעבודה לגשת לשתי האפשרויות, אפשר להשתמש בגישה של 2 כרטיסיות או בגישה דומה.

  2. משנים את החלק החזיתי של האפליקציה כך שכאשר מחפשי עבודה מבקשים לחפש לפי נסיעה, החלק האחורי יאכלס את המידע הרלוונטי במסנן הנסיעה ויפעיל את ה-API כמו בבקשת חיפוש רגילה.

  3. כוללים את הפריטים החדשים שנוספו בממשק המשתמש:

    • אפשרות לבחור אם מדובר בחיפוש מרחק או בחיפוש נסיעה. לדוגמה, ממשק המשתמש של החיפוש יכול להיראות כמו הדוגמה הבאה:

    • תפריט נפתח עם אפשרויות לשיטת הנסיעה.

    • אפשרות לשנות את מצב התנועה.

    • זמן הנסיעה הכולל (זמן הנסיעה המקסימלי שנתמך הוא 60 דקות).

    • שעת ההתחלה של הנסיעה היומית.

  4. אחרי כן, המידע על זמן הנסיעה שמוחזר מה-API משמש להצגת מידע לחיפוש העבודה. ברשימת התוצאות מוצגות רק משרות רלוונטיות שנמצאות באזור שמוגדר כזמן הנסיעה. במסמכים בנושא שיטות מומלצות לחיפוש עבודה מוסבר איך לשנות את הסדר ואת מספר המשרות שמוצגות באזור הזה.

אתם יכולים להשתמש ב-Maps API כדי ליצור מפה על סמך המידע על זמן הנסיעה לעבודה שמוחזר מ-CTS API ולהטמיע אותה בתוצאות שמוחזרות למי שמחפש עבודה. חבילת Maps API כוללת כמה אפשרויות להצגת המפה. חלק מהאפשרויות של Maps API יעילות יותר מאחרות. לדוגמה, הדמיה של מפת חום ב-JavaScript של מפות Google בשילוב עם אשכול סמנים היא דרך מצוינת להדמיה של המשרות הרלוונטיות שמוצגות למי שמחפש עבודה באזור שנקבע לפי העדפות הנסיעה שלו. לעומת זאת, במצב 'הוראות הגעה' לא מוצגות כל המשרות שמוחזרות בבקשת חיפוש, ולכן לא מומלץ להשתמש בו.

מידע נוסף על הטמעה של חיפוש לפי נסיעה לעבודה זמין במדריך בנושא חיפוש לפי נסיעה לעבודה.