jeudi 5 mars 2015

Xamarin.Android -coordinates from SQLite are not drawn on Google maps

I'm trying to implement Google maps markers using C#.I have lat/long values saved into my SQLite db which i then read and want to display on the map.There's an option on the action bar 'Load Points' that should call a method 'ReadPointsFromDb()' where i create the new Markers.i have tried a couple of examples with no difference,although drawing Markers on a map is pretty standard and i think I've done it correctly,except there's no effect when i click on Load points.Nothing changes.No markers are drawn on the map each time.


This is what the method looks like :



//retrieve a list of all the contents of receiverpoint table items
public void ReadPointsFromDb()
{


double lat = 0;
double lon = 0;

int count = dataManager.GetAllReceiverPoints ().Count;

foreach(ReceiverPointTable item in dataManager.GetAllReceiverPoints ())
{
lat = item.LATITUDE;

lon = item.LONGITUDE;
}

if(map != null){



RunOnUiThread (new Action (delegate {

map.Clear ();

receiver_point = new LatLng (lat, lon);

var markerOpt1 = new MarkerOptions();
markerOpt1.SetTitle("Test point");
markerOpt1.SetPosition (receiver_point);
markerOpt1.InvokeIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueMagenta));
map.AddMarker(markerOpt1);
}));

}

}

Aucun commentaire:

Enregistrer un commentaire