windows phone 8 - Add fixed MapLayer once -
in application have map first thing (on launching) add custom maplayer (which populate many mapoverlays/pushpins).
when browse page of app , return map page, (ie maplayer drawn on map) gone.
it takes time add on again each time user navigates map page fixed, drawn/added once.
any suggestions?
edit, added code [i removed details, structure remains same]:
private async void drawstations() { sqliteasyncconnection conn = new sqliteasyncconnection("stasy.sqlite"); list<line1_stations> lines = await conn.queryasync<line1_stations>("select *..."); microsoft.phone.maps.controls.maplayer layer = new microsoft.phone.maps.controls.maplayer(); pushpin p; foreach (line1_stations in lines) { double slat = convert.todouble(a.lat); double slon = convert.todouble(a.lon); p = new pushpin(); p.location = new geocoordinate(slat, slon); p.tap += img_tap; p.content = "..."; p.foreground = new solidcolorbrush(colors.transparent); p.width = 30; p.height = 30; mapoverlay overlay1 = new mapoverlay(); overlay1.content = p; overlay1.geocoordinate = new geocoordinate(slat, slon); overlay1.positionorigin = new point(0.0, 1.0); layer.add(overlay1); } mymap.layers.add(layer); }
you can try create maplayer public property in app.xaml.cs , set when app running first time.
then create instance of app inside page map , add maplayer map layers inside onnavigatedto event.
Comments
Post a Comment