Note that as I tap on the left side of the screen Denmark moves to the right but then seems to move back again after a few clicks where as it should move all the way to the left of the bitmap.
On the other hand if I click to the right too far then it returns an error (gif had to be cut so you cannot see that bit). But here's the error
Error: Symbol Not Found Error
Details: Failed invoking <symbol>
Stack:
- find() at C:\Users\Me\eclipse-workspace\Myprojects\MapWidgetApp\source\MapWidgetView2.mc:76 0x100020ee
- onUpdate() at C:\Users\Me\eclipse-workspace\Myprojects\MapWidgetApp\source\MapWidgetView2.mc:92 0x100021b3
Here is the delegate.
function onTap(clickEvent) { var g_deg0 = Application.getApp().getProperty("longitude"); var g_deg1 = (Application.getApp().getProperty("latitude") + 4.0); var coord = clickEvent.getCoordinates(); var x = coord[0]; var y = coord[1]; if(x > 0 && x < 60 && y > 40 && y < 200) { System.println("left"); var long = (g_deg0 + 0.5); Application.getApp().setProperty("longitude", long); View.onHide; WatchUi.popView(SLIDE_IMMEDIATE); WatchUi.pushView(new MapWidgetView2(), new MapWidgetDelegate2(), SLIDE_IMMEDIATE); WatchUi.requestUpdate(); System.println("works"); } else if(x > 180 && x < 240 && y > 40 && y < 200) { System.println("right"); var long = (g_deg0 - 0.5); Application.getApp().setProperty("longitude", long); View.onHide; WatchUi.popView(SLIDE_IMMEDIATE); WatchUi.pushView(new MapWidgetView2(), new MapWidgetDelegate2(), SLIDE_IMMEDIATE); WatchUi.requestUpdate(); System.println("works"); } else if(x > 60 && x < 180 && y > 0 && y < 60) { System.println("up"); var lati = (g_deg1 + 0.5); Application.getApp().setProperty("latitude", lati); View.onHide; WatchUi.popView(SLIDE_IMMEDIATE); WatchUi.pushView(new MapWidgetView2(), new MapWidgetDelegate2(), SLIDE_IMMEDIATE); WatchUi.requestUpdate(); System.println("works"); } else if(x > 60 && x < 180 && y > 180 && y < 240) { System.println("down"); var lati = (g_deg1 - 0.5); Application.getApp().setProperty("latitude", lati); View.onHide; WatchUi.popView(SLIDE_IMMEDIATE); WatchUi.pushView(new MapWidgetView2(), new MapWidgetDelegate2(), SLIDE_IMMEDIATE); WatchUi.requestUpdate(); System.println("works"); } else { System.println("cl"); } }
Here is the view
using Toybox.WatchUi; using Toybox.Application; using Toybox.Position; using Toybox.Graphics; class MapWidgetView2 extends WatchUi.View { var lat = Application.getApp().getProperty("latitude"); var lon = Application.getApp().getProperty("longitude"); var up; var down; var right; var left; var cross; function initialize() { View.initialize(); up = new WatchUi.Bitmap({:rezId=>Rez.Drawables.up,:locX=>100,:locY=>118}); down = new WatchUi.Bitmap({:rezId=>Rez.Drawables.down,:locX=>200,:locY=>118}); left = new WatchUi.Bitmap({:rezId=>Rez.Drawables.left,:locX=>190,:locY=>10}); right = new WatchUi.Bitmap({:rezId=>Rez.Drawables.right,:locX=>10,:locY=>10}); cross = new WatchUi.Bitmap({:rezId=>Rez.Drawables.cross,:locX=>10,:locY=>10}); } const ut=84.194, un=-36.648, dt=31.662, dn=34.650, imgs=250, rx=3000/imgs, ry=3000/imgs, tt=ut-dt, nn=dn-un; var x,y, ar=new[9], pos, mx,my; function find(t,n) { var ayy = ((ut-t)*ry/tt), axx = (rx-(dn-n)*rx/nn), yy = ayy.toNumber(), xx = axx.toNumber(); my = (ayy-yy)*imgs; mx = (axx-xx)*imgs; var npos = yy*rx+xx; if (pos != npos) { var r = [ :m0, :m1, :m2, :m3, :m4, :m5, :m6, :m7, :m8, :m9,:m10,:m11, :m12,:m13,:m14,:m15,:m16,:m17,:m18,:m19,:m20,:m21,:m22, :m23, :m24,:m25,:m26,:m27,:m28,:m29,:m30,:m31, :m32,:m33, :m34, :m35, :m36,:m37,:m38,:m39,:m40,:m41,:m42,:m43,:m44,:m45,:m46,:m47, :m48,:m49,:m50,:m51,:m52,:m53,:m54,:m55, :m56,:m57,:m58,:m59, :m60,:m61,:m62,:m63,:m64,:m65,:m66,:m67,:m68,:m69,:m70,:m71, :m72, :m73,:m74,:m75,:m76,:m77, :m78,:m79,:m80,:m81,:m82,:m83, :m84, :m85,:m86,:m87,:m88, :m89,:m90,:m91,:m92,:m93,:m94,:m95, :m96,:m97,:m98,:m99,:m100,:m101,:m102,:m103,:m104,:m105,:m106,:m107, :m108, :m109,:m110, :m111,:m112,:m113,:m114,:m115,:m116,:m117,:m118,:m119, :m120,:m121, :m122,:m123,:m124,:m125,:m126,:m127, :m128,:m129,:m130,:m131, :m132,:m133,:m134,:m135,:m136,:m137,:m138,:m139,:m140,:m141,:m142,:m143]; pos = npos; for(var i=0, iy=yy-1; iy<=yy+1; iy++) { for(var ix=xx-1; ix<=xx+1; i++, ix++) { if(iy>=0 && iy<ry && ix>=0 && ix<rx) { ar[i] = Rez.Drawables[r[iy*rx+ix]];} else {ar[i]=null;} }} } } function onUpdate(dc) { lat.toString; lon.toString; var locString = lat+","+ lon; var myLocation = Position.parse(locString, Position.GEO_DEG); var l = myLocation; if (l!=null) { l = l.toDegrees(); find(l[0], l[1]); l = null; for(var i=0, yy=y-imgs-my; yy<y+imgs; yy+=imgs) { for(var xx=x-imgs-mx; xx<x+imgs; xx+=imgs, i++) { if(ar[i]!=null){ dc.drawBitmap(xx, yy, WatchUi.loadResource(ar[i]));}}} } dc.setColor(0xFF0000,-1); dc.fillRectangle(x-2, y-2, 4,4); } function onLayout(dc) { x = dc.getWidth()/2; y = dc.getHeight()/2; } }
Would appreciate some help in figuring out the problem. Thanks.