Links

Obtain distance from a section

cURL
iOS SDK
Android SDK
PHP SDK
JS SDK
Flutter SDK
curl https://mburger.cloud/api/blocks/<id>/sections?distance=latitude,longitude
-H "Accept: application/json"
-H "X-MBurger-Token: <token>"
-H "X-MBurger-Version: 3"
struct LocationParamter: MBParameter {
let location: CLLocationCoordinate2D!
func parameterRepresentation() -> [String: Any] {
return [
"latitude": location.latitude,
"longitude": location.longitude
]
}
}
​
​
...
​
let locationParameter = LocationParamter(location: CLLocationCoordinate2D(lat, lng))
MBClient.getSection(withId: SECTION_ID,
parameters: [locationParameter],
success: { section in
},
failure: { error in
})
val arrayParameters = ArrayList<Any>()
arrayParameters.add(MBGeneralParameter(key = "latitude", value = THE_LATITUDE))
arrayParameters.add(MBGeneralParameter(key = "longitude", value = THE_LONGITUDE))
​
val sectionsListener = object: MBSectionsResultListener{
override fun onSectionsApiError(error: String) {
}
​
override fun onSectionsApiResult(sections: ArrayList<MBSection>,
block_id: Long,
paginationInfos: MBPaginationInfo) {
}
}
MBurgerTasks.askForSections(context = applicationContext,
block_id = BLOCK_ID,
filters = arrayParameters,
getElements = true,
listener = sectionsListener)
$response = (new MBurger())->distance(float $latitude, float $longitude)->getSections();
const mburger = require('mburger');
​
const instance = mburger.createClient({
api_key: "12578sdfghjkl",
});
​
let latitude = 44.542,
longitude = 10.452;
​
// Retrieve a specific block
instance.getBlock({
block_id: 884,
locale: 'it',
original_media: false,
filter: {
'distance': latitude + ',' + longitude
}
}).then(result => console.log(result));
​
class LocationParameter extends MBParameter {
final double latitude;
final double longitude;
​
LocationParameter(this.latitude, this.longitude);
​
@override
Map<String, String> get representation {
return {
'latitude': latitude.toString(),
'longitude': longitude.toString(),
};
}
}
​
...
​
MBFilterParameter locationParameter = LocationParameter(LAT, LNG);
MBSection section = await MBManager.shared.getSection(
sectionId: SECTION_ID,
includeElements: true,
parameters: [locationParameter],
);
​