How Can I Simplify Pins In Maps
So I have implemented Google Maps on my VS Xamarin project. I know there is a way to simplify my code but I don't know how more could I do it. I have a bunch of markers on my map a
Solution 1:
note this is all pseudocode, not syntactically correct json/C#
first, create a json file with your data and include it in your project
[
{ Label = "USA" Address = "2020", Lat = "36.9628066" Long = "-122.0194722" },
...
{ Label = ""Santa HEY MAN", Address = "The city with a boardwalk", Lat = "36.9628066" Long = "-122.0194722} }
]
then, in your code
// read the filevar json = File.ReadAllText(path);
// deserialize using NewtonSoftvar places = DeserializeObject<List<Place>>(json);
// then create pinsforeach (var place in places)
{
var pin = new Pin
{
Label = place.Label,
Address = place.Address,
Type = PinType.Place,
Position = new Position(place.Lat, place.Long)
};
map.Pins.Add(pin);
}
Post a Comment for "How Can I Simplify Pins In Maps"