Download OpenAPI specification:Download
The alfred24 API provides logistics and ecommerce partners with access to the extensive alfred24 network, which includes smart lockers, pick-up/drop-off (PUDO) points, 7-Eleven, Circle-K, Hongkong Post iPostal Station, Hongkong Post Office, Kerry MTR lockers, and door to door delivery service.
To access the alfred24 API, you will need a developer account, which can be obtained through your alfred24 representative. This account will allow you to obtain a bearer token for authentication with the system.
By using the alfred24 API, you can easily create and assign shipments to your desired alfred24 locations.
If you require any assistance, please don't hesitate to contact us at: sales-hk@alfred24.com.
Environment | URL |
---|---|
Staging | https://api-staging.alfred24.com.hk |
Production | https://api.alfred24.com.hk |
HTTP Status Code | Description |
---|---|
2xx Success | The request was successfully received and proccessed by alfred24 |
4xx Client Error | This indicates there is an error in the payload |
5xx Server Error | This error occurs when alfred24 is unable to carry out an action |
More detailed error messages are listed under each endpoint.
This method authenticates a user with a username and password and generates an access token.
Success
Unauthorized
Unsupported Media Type
{- "username": "Partner",
- "password": "888888"
}
{- "username": "Partner",
- "token": "FeimhHNjeqDoS0KBUze8VSraUgTlp1jwHDPwb7jrdOk279AlqwmaMEvf3NLvRIOD",
- "role": [
- {
- "roleName": "alfred24 user",
- "roleId": "23634280-8c19-49c2-b0ec-785a5e0ac994"
}
], - "company": [
- {
- "companyName": "Sample Company",
- "companyId": "f8907275-0763-47d4-92ec-1b5fe925fda3"
}
]
}
The "Get Locations" method retrieves locations from the system and supports pagination using offset or limit parameters.
Successful
[- {
- "limit": 10,
- "offset": 0,
- "currentPage": 1,
- "pageCount": 1,
- "totalCount": 20,
- "pagination": [
- {
- "locationId": "P2034871334",
- "locationName": "測試櫃",
- "locationEn": "test locker",
- "locationTypeCn": "alfred24智能櫃",
- "locationType": "ALFRED_LOCKER",
- "services": [
- {
- "name": "Pickup service 自提點派送",
- "serviceKey": "SELFPICKUP"
}
], - "longitude": 114.6295727,
- "latitude": 22.0788713,
- "country": "Hong Kong SAR",
- "countryCn": "香港",
- "province": "Hong Kong Island",
- "provinceCn": "港島",
- "city": "Southern",
- "cityCn": "南區",
- "district": "Aberdeen",
- "districtCn": "香港仔",
- "postalCode": "",
- "address1": "香港仔南寧街9號香港仔中心商場二期2樓10A號舖",
- "address1En": "Shop 10A, 2/F ,Aberdeen Centre Phase 2 ,9 Nam Ning St, Aberdeen, HK",
- "address2": "",
- "address2En": "",
- "availableCompartments": 46,
- "operatingTime": "星期一 - 星期日: 10:00 - 22:00",
- "displayHours": "Mon - Sun: 10:00 - 22:00",
- "displayHoursCn": "星期一 - 星期日: 10:00 - 22:00",
- "displayHoursSimplifiedCn"": "星期一至日10:00-22:00",
- "specialHolidays": "",
- "specialHolidaysCn": "",
- "unformattedHours": "Mon - Sun: 10:00 - 22:00",
- "unformattedHoursCn": "星期一 - 星期日: 10:00 - 22:00",
- "detailHours": [
- {
- "closing1": "2200",
- "opening1": "1000",
- "weekday": "Mon"
}, - {
- "closing1": "2200",
- "opening1": "1000",
- "weekday": "Tue"
}, - {
- "closing1": "2200",
- "opening1": "1000",
- "weekday": "Wed"
}, - {
- "closing1": "2200",
- "opening1": "1000",
- "weekday": "Thu"
}, - {
- "closing1": "2200",
- "opening1": "1000",
- "weekday": "Fri"
}, - {
- "closing1": "2200",
- "opening1": "1000",
- "weekday": "Sat"
}, - {
- "closing1": "2200",
- "opening1": "1000",
- "weekday": "Sun"
}
]
}
]
}
]
This API facilitates the creation of an order with alfred24 by generating a unique tracking number and providing a corresponding waybill label. These elements serve the purpose of facilitating the shipment process and serve as reference information for tracking and logistics management.
OK
Bad Request
Unauthorized
Not Found
[- {
- "serviceKey": "SELFPICKUP",
- "trackingNumber": "YOUR_ORDER_REFERENCE",
- "locationId": "TEST001",
- "senderName": "Sender Name",
- "senderPhone": "87654321",
- "senderEmail": "sender@email.com",
- "senderAddress": "10 Sender Road, City, Province",
- "recipientName": "Recipient Name",
- "recipientPhone": "87654321",
- "recipientEmail": "recipient@email.com",
- "recipientAddress": "11 Recipient Road, City, Province",
- "note": "Delivery with care",
- "weight": 2.25,
- "length": 10,
- "width": 20,
- "height": 30
}
]
{- "NOT_PERMISSION": [ ],
- "SUCCEED": [
- {
- "shipmentId": "8a876ae8-658d-4ab5-bb31-d88e767a394e",
- "orderId": "ORDERNUMBER04",
- "trackingNumber": "M002799893",
- "additionalTrackingNumber": null,
- "errorMessage": null,
- "qrCodeLink": null
}
], - "BAD_PARAMETER": [ ],
- "ALREADY_EXIST": [ ]
}
This API method allows you to retrieve the latest shipment information. You can search by order number or tracking number, and apply filters based on specific status or timeframes. Use this method to fetch the most up-to-date details about shipments according to your search criteria.
The statuses returned are as follows:
Status Code | Status value | Status Description | Remarks |
---|---|---|---|
Normal statuses |
|||
1001 | CREATED | Created | The shipment record has been created in the system and is ready for further processing. |
2001 | PICKUP_REQUESTED | Pickup requested | The order has been scheduled for a courier pickup from the sender's or merchant's address. |
2002 | DROP_OFF_REQUESTED | Delivery Requested | The order has been successfully notified for drop-off to the warehouse. |
3002 | ARRIVED_AT_WAREHOUSE | Inbound | The shipment has been successfully checked into the warehouse. |
3012 | ARRIVED_AT_PARTNER_WAREHOUSE | Arrived at partner warehouse | The shipment has been successfully checked into the partner's warehouse. |
3003 | READY_FOR_DISPATCH | Ready for dispatch | The shipment is prepared for dispatch. |
3004 | OUT_FOR_DELIVERY | Out for delivery | The shipment is currently in transit for delivery. |
4001 | COURIER_STORED | Courier stored | The shipment has successfully reached the designated pickup location. |
5001 | CUSTOMER_COLLECTED | Delivered | The recipient has successfully collected the shipment at the pickup location. |
5002 | COMPLETED | Completed | The shipment has been successfully confirmed as delivered and received by the recipient. |
0001 | CANCELLED | Cancelled | The order has been cancelled |
Abnormal statuses |
|||
5011 | RECREATED | Recreated | A new tracking number has already been obtained for the shipment, it will be used for the subsequent delivery attempt. |
E2001 | PICKUP_FAILURE | Pickup failure | Failed to pick up from sender |
E4001 | STORE_FAILURE | Store failure | Failed to store at the pickup location |
7001 | RETURNED_TO_COURIER | Returned to courier | The expired shipment has been collected by the courier. |
7002 | RETURNED_TO_WAREHOUSE | Returned to warehouse | The shipment has been returned to the warehouse. |
5021 | SCHEDULED_FOR_DELIVERY | Change to delivery | The shipment has been rescheduled for delivery to a new address. |
5031 | RETURNED_TO_MERCHANT | Returned to merchant | The shipment has been returned to the sender. |
6002 | OPERATOR_COLLECTED | Operator collected | The operator has collected the shipment from the pickup location. |
E3004 | DELIVERY_FAILURE | Delivery failure | The shipment failed to be delivered to the pickup location or the recipient address. |
Status Code | Status value | Status Description | Remarks |
---|---|---|---|
Normal statuses |
|||
1001 | CREATED | Created | The shipment record has been created in the system and is ready for further processing. |
4002 | CUSTOMER_STORED | Customer stored | The shipment has been stored at the drop-off location. |
6001 | COURIER_COLLECTED | Courier collected | The courier has collected the shipment from the drop-off location. |
7002 | RETURNED_TO_WAREHOUSE | Returned to warehouse | The shipment has been returned to the warehouse. |
5031 | RETURNED_TO_MERCHANT | Returned to merchant | The shipment has been returned to merchant. |
Status Code | Status value | Status Description | Remarks |
---|---|---|---|
Normal statuses |
|||
1001 | CREATED | Created | The shipment record has been created in the system and is ready for further processing. |
2003 | PICKUP_ARRANGED | Pickup arranged | The courier scheduled for pickup at sender's address. |
2004 | OUT_FOR_PICKUP | Out for pickup | The courier en route for pickup at sender's address. |
2005 | PICKED_UP_FROM_SENDER | Picked up from sender | The courier has already collected the shipment from the sender's address. |
3012 | ARRIVED_AT_PARTNER_WAREHOUSE | Arrived at partner warehouse | The shipment has been successfully checked into the partner's warehouse. |
5031 | RETURNED_TO_MERCHANT | Returned to merchant | The shipment has been sent back to the original sender or merchant. |
0001 | CANCELLED | Cancelled | The order has been cancelled |
Abnormal statuses |
|||
E2001 | PICKUP_FAILURE | Pickup failure | Failed to pick up from sender |
Failure reason code ("orderFlagCode") | Remarks |
---|---|
FR001 | Recipient not available / No one responded |
FR002 | Customer requested a change of delivery/pick up time |
FR003 | Customer refused / claimed there was nothing to pick up |
FR005 | Incorrect address |
FR007 | Restricted zone |
Success
Unauthorized
[- {
- "limit": "1",
- "offset": "1",
- "currentPage": "1",
- "pageCount": "10",
- "totalCount": "10",
- "content": [
- {
- "trackingNumber": "ALFREDPP201907161042TEST",
- "referenceNumber": "ecommerce_reference_number",
- "additionalTrackingNumber": "PP201907161042",
- "status": "COURIER_STORED",
- "statusDescription": "Courier stored",
- "statusTime": "2019-06-01T12:30:00.000Z",
- "statusTimeStamp": "1571986363517",
- "weight": "2.25",
- "length": 10,
- "width": 20,
- "height": 30,
- "accessCode": "123456",
- "createTime": "2023-05-09T21:18:01+08:00",
- "overDueFlag": "true",
- "serviceType": "DELIVERY",
- "service": "Pickup service 自提點派送",
- "compartment": "A30",
- "timeStored": "2023-05-11T13:07:04+08:00",
- "timeCollected": "null,",
- "timeOverdue": "2023-05-15T13:07:04+08:00",
- "newTrackingNumber": "NEW_ATTEMPT_TRAKCING_NUMBER",
- "oldTrackingNumber"": "ORIGINAL_ATTEMPT_TRACKING_NUMBER",
- "company": {
- "companyId": "f8907275076347d492ec1bfe25fda3",
- "companyName": "Your company name"
}, - "creator": {
- "createdBy": "CREATOR_NAME",
- "createdUserId": "64123123237126b8bf",
- "createdUserLoginName": "name@domain.com"
}, - "location": {
- "locationName": "BaoanTestLocker",
- "locationId": "TEST001",
- "boxTypeName": null,
- "boxName": null
}, - "recipient": {
- "recipientPhone": "536908434",
- "recipientMail": "recipient@domain.com",
- "recipientName": "Joey"
}, - "courier": {
- "companyId": "61e9756c0431220736f52ad",
- "companyName": "alfred24 Delivery"
}, - "storeUser": {
- "storeBy": "STORE_NAME",
- "storeUserId": "112123111246b8bf",
- "storeUserPhone": "81731672"
}, - "orderFlag": [
- "Test order",
- "overweight"
], - "events": [
- {
- "status": "CREATED",
- "statusCode": "1001",
- "statusDescription": "Created",
- "statusDescriptionCn": "已創建",
- "timestamp": 1683638281171,
- "time": "2022-11-08T11:01:40+08:00",
- "timezone": "Asia/Hong_Kong"
}, - {
- "status": "ARRIVED_AT_WAREHOUSE",
- "statusCode": "3002",
- "statusDescription": "Arrived at warehouse",
- "statusDescriptionCn": "倉庫簽入",
- "timestamp": 1683638281172,
- "time": "2022-11-10T19:01:34+08:00",
- "timezone": "Asia/Hong_Kong"
}, - {
- "status": "READY_FOR_DISPATCH",
- "statusCode": "3003",
- "statusDescription": "Ready for dispatch",
- "statusDescriptionCn": "準備出倉",
- "timestamp": 1683638281173,
- "time": "2022-11-10T21:42:10+08:00",
- "timezone": "Asia/Hong_Kong"
}, - {
- "status": "COURIER_STORED",
- "statusCode": "4001",
- "statusDescription": "Courier stored",
- "statusDescriptionCn": "已存",
- "timestamp": 1683638281174,
- "time": "2022-11-11T14:41:57+08:00",
- "timezone": "Asia/Hong_Kong"
}, - {
- "status": "CUSTOMER_COLLECTED",
- "statusCode": "5001",
- "statusDescription": "Delivered",
- "statusDescriptionCn": "已簽收",
- "timestamp": 1683638281175,
- "time": "2022-11-14T19:35:51+08:00",
- "timezone": "Asia/Hong_Kong"
}
]
}
]
}
]
This method allows you to cancel a shipment. When using the cancel order API call, please exercise caution as the cancellation is irreversible. Once the shipment is canceled, it cannot be undone, and all associated shipment information will be permanently inaccessible. To ensure accuracy, carefully review the order details before initiating the cancellation.
{- "trackingNumbers": [
- "L0013723623",
- "DE0012378233",
- "M001378218372"
]
}
{- "result": [
- {
- "trackingNumber": "L0013723623",
- "status": "DONE"
}, - {
- "trackingNumber": "DE0012378233",
- "status": "DONE"
}, - {
- "trackingNumber": "M001378218372",
- "status": "FAILED"
}
]
}
This method provides the capability to retrieve the available time slots for courier pickups or warehouse drop-offs. By making use of this API, you can access a comprehensive list of time slots specifically designated for scheduling courier pickups or arranging warehouse drop-offs.
OK
[- {
- "title": "Apr 14 AM (10:00 - 13:00)",
- "requestStartTime": 1649901600000,
- "requestEndTime": 1649912400000
}, - {
- "title": "Apr 14 PM (14:00 - 18:00)",
- "requestStartTime": 1649916000000,
- "requestEndTime": 1649930400000
}, - {
- "title": "Apr 19 AM (10:00 - 13:00)",
- "requestStartTime": 1650333600000,
- "requestEndTime": 1650344400000
}, - {
- "title": "Apr 19 PM (14:00 - 18:00)",
- "requestStartTime": 1650348000000,
- "requestEndTime": 1650362400000
}, - {
- "title": "Apr 20 AM (10:00 - 13:00)",
- "requestStartTime": 1650420000000,
- "requestEndTime": 1650430800000
}, - {
- "title": "Apr 20 PM (14:00 - 18:00)",
- "requestStartTime": 1650434400000,
- "requestEndTime": 1650448800000
}, - {
- "title": "Apr 21 AM (10:00 - 13:00)",
- "requestStartTime": 1650506400000,
- "requestEndTime": 1650517200000
}
]
This method enables you to request a courier to pick up the shipment from your specified address. It requires the use of the appropriate time slot, which can be obtained by invoking the Get Available Time Slots of Courier Pickup method. API calls made with the same time slot and pickup information will be considered as a single pickup request, and the handoverId (the ID of the pickup request) will be returned.
OK
Bad Request
{- "requestStartTime": 1629180000000,
- "requestEndTime": 1629194400000,
- "trackingNumbers": [
- "A123456",
- "B123456"
], - "pickupInfo": {
- "address": "My warehouse address",
- "contactPhone": "87654321",
- "contactName": "John",
- "buildingType": "RESIDENTIAL",
- "note": "Please pickup with pallet"
}
}
{- "NOT_PERMISSION": [ ],
- "SUCCEED": [
- {
- "trackingNumber": "A123456",
- "handoverId": "PU000001"
}, - {
- "trackingNumber": "B123456",
- "handoverId": "PU000001"
}
], - "BAD_PARAMETER": [ ],
- "ALREADY_EXIST": [ ]
}
This method enables you to submit notifications for the drop-off of your shipments to alfred24 warehouses. It requires the use of the appropriate time slot, which can be obtained by invoking the Get Available Time Slots of Warehouse Drop-off method to create a drop-off notice. API calls made with the same time slot will be considered as a single drop-off notification, and the handoverId (the ID of the drop-off notification) will be returned.
OK
{- "requestStartTime": 1629180000000,
- "requestEndTime": 1629194400000,
- "trackingNumbers": [
- "A123456",
- "B123456"
], - "note": "Total 103 pcs. Please come pick up with pallet."
}
{- "NOT_PERMISSION": [ ],
- "SUCCEED": [
- {
- "trackingNubmer": "A123456",
- "handoverId": "DF000001"
}, - {
- "trackingNubmer": "B123456",
- "handoverId": "DF000001"
}
], - "BAD_PARAMETER": [ ],
- "ALREADY_EXIST": [ ]
}
This API allows you to cancel a previously requested courier pickup or warehouse drop-off notice. By providing the order tracking number, you can initiate the cancellation process. It's important to note that once the cancellation is confirmed, it cannot be undone. Please ensure that you have the correct information and intent before proceeding with the cancellation.
OK
Bad Request
{- "trackingNumber": "M00137821783"
}
{- "status": "success"
}
This method allows for the creation of sub-accounts under your primary account.
Success
{- "merchantName": "My company",
- "accountType": "BUSINESS",
- "serviceType": "PICKUP",
- "firstName": "John",
- "lastName": "Lee",
- "initialUserEmail": "test@test.com",
- "webPassword": "Ab1234567890",
- "initialUserMobile": "87654321",
- "streetAddress": "111 Parliament Road, City",
- "website": "string",
- "monthlyVolume": 1000,
- "companyName": "Company BR name",
- "businessRegistration": "12345678",
- "collectionAreaType": "COMMERCIAL",
- "level3AriaId": "灣仔",
- "warehouseAddress": [
- "The parcel pickup address"
], - "promoCode": "string"
}
{- "code": 0,
- "message": "string",
- "data": {
- "token": "string",
- "companyName": "string",
- "companyID": "string",
- "parentCompany": "string"
}
}
The webhook module facilitates the transmission of callback information from alfred24 to partners, triggered by specific events. To enable this functionality, partners are required to furnish alfred24 with a secure webhook notification URL.
Below is a sample webhook response that alfred24 will send on event trigger.
Event | Status | Remarks |
---|---|---|
Normal events: |
||
ARRIVED_AT_WAREHOUSE | Arrived at warehosue | This event is triggered when a shipment is scanned into an affiliated warehouse. |
COURIER_STORED | Courier stored | This event is triggered when a shipment has been stored at an alfred24 location by an operator or courier. This event will trigger a notification to a customer if it is enabled. |
DELIVERED | Delivered | This event is triggered when a customer has collected their shipment. |
Abnormal events: |
||
COURIER_COLLECTED | Courier collected | This event is triggered when a shipment has been removed from an alfred24 location and to be returned to the logistics service provider. This event will trigger a notification to the customer if it is enabled. |
OPERATOR_COLLECTED | Operator collectecd | This event is triggered when a shipment has been removed from an alfred24 location and to be returned to the locker operator. This event will trigger a notification to the customer if it is enabled. |
DELIVERY_FAILURE | Delivery failure | The shipment has some issue on the delivery, and will be returning back to the warehouse. |
RECREATED | Recreated | This event is triggered when the shipment is going to apply for a new tracking number and make another attempt for the delivery. |
RETURNED_TO_WAREHOUSE | Returned to warehouse | The shipment has returned to warehouse. |
RETURNED_TO_MERCHANT | Returned to merchant | The shipment has been returned back to merchant. |
DISPOSED | Disposed | The shipment has been disposed. |
LOST | Lost | The shipment is lost. |
Event | Status | Remarks |
---|---|---|
Normal events: |
||
CUSTOMER_STORED | Customer stored | For "RETURN"/"MRETURN" orders only. This event is triggered when a shipment has been deposited by a customer. |
COURIER_COLLECTED | Courier collected | For "RETURN"/"MRETURN" orders only. This event is triggered when a shipment has been collected by a courier. |
RETURNED_TO_WAREHOUSE | Returned to warehouse | The shipment has returned to warehouse. |
RETURNED_TO_MERCHANT | Returned to merchant | The shipment has been returned back to merchant. |
Event | Status | Remarks |
---|---|---|
Normal events |
||
PICKUP_ARRANGED | Pickup arranged | The courier scheduled for pickup at sender's address. |
OUT_FOR_PICKUP | Out for pickup | The courier en route for pickup at sender's address. |
PICKED_UP_FROM_SENDER | Picked up from sender | The courier has already collected the shipment from the sender's address. |
ARRIVED_AT_PARTNER_WAREHOUSE | Arrived at partner warehouse | The shipment has been successfully checked into the partner's warehouse. |
RETURNED_TO_MERCHANT | Returned to merchant | The shipment has been sent back to the original sender or merchant. |
CANCELLED | Cancelled | The order has been cancelled |
Abnormal event |
||
PICKUP_FAILURE | Pickup failure | Failed to pick up from sender |
Failure reason code ("orderFlagCode") | Remarks for Send from address service |
---|---|
FR001 | No one responded |
FR002 | Customer requested a change of pickup time |
FR003 | Customer claimed there was nothing to pick up |
FR005 | Incorrect pickup address |
FR007 | Restricted zone |
Success
With errors
{- "serviceType": "DELIVERY",
- "serviceKey": "SELFPICKUP",
- "trackingNumber": "CLP0007770000",
- "additionalTrackingNumber": "CLP0007770000",
- "referenceNumber": "YOUR_ORDER_REFERENCE",
- "locationId": "ALF001",
- "locationName": "alfred24 locker 1",
- "locationType": "alfred24 Locker",
- "accessCode": "77788899",
- "recipientPhone": "87654321",
- "recipientEmail": "recipient@email.com",
- "recipientAddress": "11 Recipient Street, City, Province",
- "recipientName": "Recipient Name",
- "note": "Delivery with care",
- "pickupNotes": "Please come pickup by 4pm",
- "charge": 0,
- "numberOfParcels": 1,
- "length": 10,
- "width": 10,
- "height": 10,
- "status": "Delivered",
- "statusTime": "2019-08-01T10:00:00Z",
- "statusTimestamp": "1573648442070",
- "overdueTimestamp": "1574648442070",
- "senderPhone": "536908507",
- "senderEmail": "sender@email.com",
- "senderAddress": "10 Sender Street, City, Province",
- "compartmentNumber": "E11",
- "event": "FOR_MERCHANT_STORE_CUSTOMER_TAKEN",
- "orderFlag": [
- {
- "orderFlagName": "Recipient not available",
- "orderFlagCode": "FR001"
}
], - "operator": "alfred24 HK",
- "newTrackingNumber": "M123456789",
- "oldTrackingNumber": "L123456789"
}
{- "status": "success"
}
GEOv1 (also known as alfred24 Geowidget v1) is a JavaScript widget that displays a comprehensive list of locations where alfred24 services are available. It offers the convenience of filtering the location list based on location type, region, district, and area, allowing users to view only the relevant listings. As a widget-based solution, the entire code and processing are hosted on alfred24 servers, requiring external clients to simply link to the code and configure it according to their system requirements. To begin integrating GEOv1, please reach out to alfred24 at sales-hk@alfred24.com to obtain a Geowidget account.
Add <script>
in header tag. Change source path to the link below:
<script src="https://alfred-geowidget.s3-ap-southeast-1.amazonaws.com/cdn-scripts/geoWidget.js"></script>
Add div with id mapBox and class mapBox in the body:
(Note: The following initialization pertains to all types of usage except for Modal , which is explained in point 5 below)
<div id="mapsPlaceHolder">
<div class="loader" id="loader"> </div>
<div id="mapBox" class="mapBox"> </div>
</div>
Parameter name | Description | Defaults |
---|---|---|
mapBoxClassName | The class name given to the mapBox div. This is where the Geowidget will render | mapBox |
defaultLocation | Which location to use for the Geowidget | HK |
mapType | Whether to render Google Maps (use gmap ) or Openstreet Map (use osm ) Available: gmap , osm For Google Maps option apiKey is required. |
osm |
locale | Select which language to init Geowidget with. Available: en , zh |
en |
mode | Select which mode to open the Geowidget in. Available: basic , modal , dropdown |
basic |
filter | A javascript object that will filter out all non-matching items from the API call. E.g. filter: { locationType: ["ALFRED_LOCKER"] } This will only display locker with location type ALFRED_LOCKER. |
|
searchBar | Whether the widget should be intialised with a searchbar displaying. Available: true , false |
false |
apiKey | The Google Maps API key | |
onSelect | The call back that returns the selected location | onSelect |
userAuthObject | A javascript object with username and password that connets to the alfred24 API: e.g. userAuthObject: { username: "your username", password: "your password", }, |
<script>
const getData = (arg) => {//get selected location data
console.log(arg)
};
geoWidget.init({
mapType: "osm",
defaultLocation: "HK",
onSelect: getData,
userAuthObject: {
username: "username",
password: "password",
},
});
</script>
Map type options are 1) “osm” for openstreet map and 2) “gmap” for Google Maps.
Add api key, username and password as above.
The selected location data can be retrieved from the getData method.
Click here to see example 1: Basic Integration (https://geowidget.alfred.delivery/basic.html)
We can also filter out initial values from the Api based on search filters; E.g. in this case we only show results from alfred24 locker. If we want to filter services / operating time etc; it can be done passing the parameters as an object.
<script>
geoWidget.init({
mapType: "osm",
defaultLocation: "HK",
userAuthObject: {
username: "username",
password: "password",
},
filter: {
locationType: ["ALFRED_LOCKER"],
},
onSelect: getData,
});
</script>
Click here to see example 2: With Initial Value filtering (shows alfred24 Lockers with service: Returns) (https://geowidget.alfred.delivery/withfilter.html)
<script>
geoWidget.init({
mapType: "osm",
defaultLocation: "HK",
mode: "dropdown",
userAuthObject: {
username: "username",
password: "password",
},
onSelect: getData,
});
</script>
By adding a mode object; and setting mode to “dropdown” we can initialize the geo widget to display in dropdown mode.
Click here to see example 3: With Dropdown filtering (https://geowidget.alfred.delivery/dropdown.html)
By switching map mode to “gmap” we can display Google Maps instead of Open Street Maps:
<script>
geoWidget.init({
mapType: "gmap",
defaultLocation: "HK",
apiKey: "Your Google Maps Apikey",
locale: "en",
onSelect: getData,
userAuthObject: {
username: "username",
password: "password",
},
});
</script>
Click here to see example 4: Enable Google Maps (https://geowidget.alfred.delivery/googlemaps.html)
To open the map as modal we need to do 2 things;
a. Change mode to modal as below:
<script>
geoWidget.init({
mapType: "osm",
defaultLocation: "HK",
mode: "modal",
locale: "en",
userAuthObject: {
username: "username",
password: "password",
},
onSelect: getData,
});
</script>
b. Wrap the map box div inside a modal parent div and provide a button to open the modal like below:
<button id="modalOpenBtn">Open Modal</button>
<div id="modal" class="modal">
<div id="mapWrapper" class="mapWrapper">
<div class="loader" id="loader"></div>
<div id="mapBox" class="mapBox"></div>
</div>
</div>
Click here to see example 5: Modal without filtering (https://geowidget.alfred.delivery/modal.html)
To use Geowidget as a search bar, we provide a searchBar object and set it to true as below:
<script>
geoWidget.init({
mapType:"osm",
defaultLocation: "HK",
locale: "en",
onSelect: getData,
userAuthObject:{
username: "username",
password: "password"
},
searchBar: true
});
</script>
Click here to see example 6: With Search bar (https://geowidget.alfred.delivery/withSearchBar.html)
Example 1: Basic Integration (https://geowidget.alfred.delivery/basic.html)
Example 2: With initial value filtering (shows alfred24 lockers with service: Returns) (https://geowidget.alfred.delivery/withfilter.html)
Example 3: With dropdown filtering (https://geowidget.alfred.delivery/dropdown.html)
Example 4: Enable Google Maps (https://geowidget.alfred.delivery/googlemaps.html)
Example 5: Modal without filtering (https://geowidget.alfred.delivery/modal.html)
Example 6: With search bar (https://geowidget.alfred.delivery/withSearchBar.html)