|
2016 | 2016 | } |
2017 | 2017 | }, |
2018 | 2018 |
|
2019 | | - addPoint : function(geopoint, async) { |
| 2019 | + savePoint : function(geopoint, async) { |
2020 | 2020 | if (geopoint.latitude === undefined || geopoint.longitude === undefined) { |
2021 | 2021 | throw 'Latitude or longitude not a number'; |
2022 | 2022 | } |
2023 | 2023 | geopoint.categories = geopoint.categories || ['Default']; |
2024 | 2024 | geopoint.categories = Utils.isArray(geopoint.categories) ? geopoint.categories : [geopoint.categories]; |
2025 | 2025 |
|
| 2026 | + var objectId = geopoint.objectId; |
| 2027 | + var method = objectId ? 'PATCH' : 'PUT', |
| 2028 | + url = this.restUrl + '/points'; |
| 2029 | + |
| 2030 | + if (objectId) { |
| 2031 | + url += '/' + objectId; |
| 2032 | + } |
| 2033 | + |
2026 | 2034 | var responder = extractResponder(arguments); |
2027 | 2035 | var isAsync = responder != null; |
2028 | 2036 | var responderOverride = function(async) { |
|
2048 | 2056 | responder = responderOverride(responder); |
2049 | 2057 |
|
2050 | 2058 | return Backendless._ajax({ |
2051 | | - method : 'PUT', |
2052 | | - url : this.restUrl + '/points', |
| 2059 | + method : method, |
| 2060 | + url : url, |
2053 | 2061 | data : JSON.stringify(geopoint), |
2054 | 2062 | isAsync : isAsync, |
2055 | 2063 | asyncHandler: responder |
2056 | 2064 | }); |
2057 | 2065 | }, |
| 2066 | + |
| 2067 | + /** @deprecated */ |
| 2068 | + addPoint: function(geopoint, async) { |
| 2069 | + return this.savePoint.apply(this, arguments); |
| 2070 | + }, |
2058 | 2071 |
|
2059 | 2072 | findUtil : function(query, async) { |
2060 | 2073 | var url = query["url"], |
|
4338 | 4351 | [Backendless.Logging, ['flush']], |
4339 | 4352 | [Messaging.prototype, ['publish', 'sendEmail', 'cancel', 'subscribe', 'registerDevice', |
4340 | 4353 | 'getRegistrations', 'unregisterDevice']], |
4341 | | - [Geo.prototype, ['addPoint', 'findUtil', 'loadMetadata', 'getClusterPoints', 'addCategory', |
| 4354 | + [Geo.prototype, ['addPoint', 'savePoint', 'findUtil', 'loadMetadata', 'getClusterPoints', 'addCategory', |
4342 | 4355 | 'getCategories', 'deleteCategory', 'deletePoint']], |
4343 | 4356 | [UserService.prototype, ['register', 'getUserRoles', 'roleHelper', 'login', 'describeUserClass', |
4344 | 4357 | 'restorePassword', 'logout', 'update', 'isValidLogin', 'loginWithFacebookSdk', |
|
4472 | 4485 | } |
4473 | 4486 | }; |
4474 | 4487 |
|
4475 | | - var GeoPoint = function() { |
| 4488 | + var GeoPoint = function(args) { |
| 4489 | + args = args || {}; |
4476 | 4490 | this.___class = "GeoPoint"; |
4477 | | - this.categories = undefined; |
4478 | | - this.latitude = undefined; |
4479 | | - this.longitude = undefined; |
4480 | | - this.metadata = undefined; |
4481 | | - this.objectId = undefined; |
| 4491 | + this.categories = args.categories; |
| 4492 | + this.latitude = args.latitude; |
| 4493 | + this.longitude = args.longitude; |
| 4494 | + this.metadata = args.metadata; |
| 4495 | + this.objectId = args.objectId; |
4482 | 4496 | }; |
4483 | 4497 |
|
4484 | | - var GeoCluster = function() { |
4485 | | - this.categories = undefined; |
4486 | | - this.latitude = undefined; |
4487 | | - this.longitude = undefined; |
4488 | | - this.metadata = undefined; |
4489 | | - this.objectId = undefined; |
4490 | | - this.totalPoints = undefined; |
4491 | | - this.geoQuery = undefined; |
| 4498 | + var GeoCluster = function(args) { |
| 4499 | + args = args || {}; |
| 4500 | + this.categories = args.categories; |
| 4501 | + this.latitude = args.latitude; |
| 4502 | + this.longitude = args.longitude; |
| 4503 | + this.metadata = args.metadata; |
| 4504 | + this.objectId = args.objectId; |
| 4505 | + this.totalPoints = args.totalPoints; |
| 4506 | + this.geoQuery = args.geoQuery; |
4492 | 4507 | }; |
4493 | 4508 |
|
4494 | 4509 | var PublishOptionsHeaders = { //PublishOptions headers namespace helper |
|
0 commit comments