Location
Represents a location.
addTask(name, parse)
Adds a new task to this location.
Parameters
nameThe name of the new task. Cannot be empty or contain only whitespace.
parseOptionaltrueto use Smart Add to process the task name,falseotherwise.
Return value
The newly added Task.
Example
// Adds a new task "Plan summer vacation" to Home location.
const home = rtm.getLocations()
.find(location => location.getName() === 'Home');
if (home != null) {
const task = home.addTask('Plan summer vacation');
console.log('Added "%s" task to "%s" location.',
task.getName(), home.getName());
} else {
console.log('"Home" location not found.');
}
delete()
Deletes the location. Any tasks with this location will no longer have a location set.
Return value
undefined
Example
// Deletes "Work" location.
const work = rtm.getLocations()
.find(location => location.getName() === 'Work');
if (work != null) {
work.delete();
console.log('Deleted "%s" location.', work.getName());
} else {
console.log('"Work" location not found.');
}
getAddress()
Gets a human-readable address of this location.
Return value
The human-readable address or null if it's missing.
Example
// Outputs the addresses of all locations.
rtm.getLocations().forEach(location =>
console.log("%s - %s", location.getName(), location.getAddress()));
getCreatedDate()
Gets the date the location was created.
Return value
Example
// Outputs all locations and their created dates.
rtm.getLocations().forEach(location =>
console.log("%s - %s", location.getName(), location.getCreatedDate()));
getId()
Gets the ID of the location.
Return value
string
getLatitude()
Gets the latitude of this location.
Return value
The number of degrees of latitude.
Example
// Outputs all locations and their coordinates.
rtm.getLocations().forEach(location => console.log("%s: %d, %d",
location.getName(), location.getLatitude(), location.getLongitude()));
getLongitude()
Gets the longitude of this location.
Return value
The number of degrees of longitude.
Example
// Outputs all locations and their coordinates.
rtm.getLocations().forEach(location => console.log("%s: %d, %d",
location.getName(), location.getLatitude(), location.getLongitude()));
getModifiedDate()
Gets the date the location was last modified.
Return value
Example
// Outputs all locations and their modified dates.
rtm.getLocations().forEach(location =>
console.log("%s - %s", location.getName(), location.getModifiedDate()));
getName()
Gets the name of this location.
Return value
The name of the Location.
Example
// Outputs all locations.
rtm.getLocations().forEach(location => console.log(location.getName()));
getPermalink()
Gets a permalink for this location.
Return value
String
Example
// Outputs the list of locations and their permalinks.
rtm.getLocations().forEach(location =>
console.log("%s - %s", location.getName(), location.getPermalink()));
getTasks(filter)
Gets all tasks in this location.
Parameters
filterOptionalIf specified, only tasks matching the given criteria are returned.
Return value
The list of Tasks in this location.
Example
// Outputs the number of incomplete tasks in your "Office" location.
const office = rtm.getLocations()
.find(location => location.getName() === 'Office');
if (office != null) {
console.log('Incomplete tasks in your "%s" location: %d',
office.getName(), office.getTasks('status:incomplete').length);
} else {
console.log('"Office" location not found.');
}
isFavorite()
Determines whether the location is marked as a favorite.
Return value
true if the location is marked as a favorite, false otherwise.
Example
// Outputs all favorite locations.
rtm.getLocations().forEach(location => {
if (location.isFavorite()) {
console.log(location.getName());
}
});
setFavorite(favorite)
Sets whether the location is marked as a favorite.
Parameters
favoritetrueto mark the location as a favorite,falseotherwise.
Return value
The updated Location.
Example
// Favorites "Home" location.
const home = rtm.getLocations()
.find(location => location.getName() === 'Home');
if (home != null) {
home.setFavorite(true);
console.log('Marked "%s" location as a favorite.', home.getName());
} else {
console.log('"Home" location not found.');
}
setName(name)
Sets the location name.
Parameters
nameThe new name of the location. Cannot be empty or contain only whitespace.
Return value
The renamed Location.
Example
// Renames "Office" location.
const office = rtm.getLocations()
.find(location => location.getName() === 'Office');
if (office != null) {
office.setName('Home');
console.log('Renamed "Office" location');
} else {
console.log('"Office" location not found');
}