I am using custom pin markers. I have two pin icons, one for error and one for ok (red and green). Since I cannot find a way to databing to IconFile, I am using two lists. One error and one ok list. My problem is that, first time I get data from server, markings are shown correct with errors and ok, but when I refresh data from server, the error and ok markings are tangled, so some of the error markings are shown with OK, and vise versa.
One extra problem is that the blue “my location” icon is sometimes replaces with one of the markins!
Problem on both physical device and emulator. I have not tried on Android.
Fusetools: 0.35.0 (Build 10867)
IOS: 9.3.2 (13F69), emulator: 10.2 (14C89)
<NativeViewHost ux:Name="viewHost" Opacity="0">
<ErrorPanel Show="{showError}" ErrorMessage="{errorMessage}" />
<MapView ux:Name="map" Latitude="{location.latitude}" Longitude="{location.longitude}" Zoom="15" ShowMyLocation="true" ShowMyLocationButton="true" Style="Satellite">
<Each Items="{okList}">
<MapMarker Latitude="{latitude}" Longitude="{longitude}" Label="{pinLabel}" IconFile="../Assets/marker_green_32.png" IconAnchorY="1" />
</Each>
<Each Items="{errorList}">
<MapMarker Latitude="{latitude}" Longitude="{longitude}" Label="{pinLabel}" IconFile="../Assets/marker_red_32.png" IconAnchorY="1" />
</Each>
</MapView>
<WhileActive>
<WhileActive>
<Change viewHost.Opacity = 1 />
</WhileActive>
</NativeViewHost>
var okList = Observable();
var errorList = Observable();
function getData() {
if(isBusy.value === true) return;
isBusy.value = true;
showError.value = false;
setTimeout(function () {
//debugger;
fetch("XXX")
.then(function(response) { return response.json(); })
.then(function(responseObject) {
var items = [];
var okList = [];
var errorList = [];
for (var i in responseObject.obj) {
var obj = new obj(responseObject.obj[i]);
if(obj.ok) {
okList.push(obj);
} else {
errorList.push(obj);
}
items.push(obj);
}
data.replaceAll(items);
okList.replaceAll(okList);
errorList.replaceAll(errorList);
}).then(function () {
isBusy.value = false;
}).catch(function(err) {
isBusy.value = false;
showError.value = true;
errorMessage.value = err.message;
});
}, 1000);
}