//this function must be in Draw() in Overlay
Using java Syntax Highlighting
- Draw(Pixelcalculator pcC,------------------------)
- {
- int[] screenCoords = new int[2];
- int[] screenCoords1 = new int[2];
- Point centrePoint=new Point((int)MyMap.mMapView.getMapCenter().getLatitudeE6(),(int)MyMap.mMapView.getMapCenter().getLongitudeE6());
- Point knownPoint=new Point((int)MyMap.mMapView.getMapCenter().getLatitudeE6()+500,(int)MyMap.mMapView.getMapCenter().getLongitudeE6()+100);
- pxC.getPointXY(centrePoint, screenCoords);
- pxC.getPointXY(knownPoint, screenCoords1);
- if(screenCoords1[1]>220)
- eachPixelLat= 500/(screenCoords1[1]-screenCoords[1]);
- if(screenCoords1[1]<220)
- eachPixelLat= 500/(screenCoords[1]-screenCoords1[1]);
- if(screenCoords1[0]>160)
- eachPixelLong= 100/(screenCoords1[0]-screenCoords[0]);
- if(screenCoords1[0]<160)
- eachPixelLong= 100/(screenCoords[0]-screenCoords1[0]);
- return 0;
- }
- //this function should be in java class where tuoch event in enabled
- public static int unknownLatLongCalc(int X,int Y)
- {
- double eachPixelLatDiff=eachPixelLat;
- double eachPixelLongDiff=eachPixelLong;
- double centreKnownLat=mPoint.getLatitudeE6();
- double centreKnownLog=mPoint.getLongitudeE6();
- int unkwPointScreenCordX=X;
- int unkwPointScreenCordY=Y;
- //North East
- if(mPoint.getLatitudeE6()>0 && mPoint.getLongitudeE6()>0)
- {
- if(unkwPointScreenCordX<160)
- unknownLog=centreKnownLog-((160-unkwPointScreenCordX)*eachPixelLongDiff);
- if(unkwPointScreenCordY<220)
- unknownLat=centreKnownLat+((220-unkwPointScreenCordY)*eachPixelLatDiff);
- if(unkwPointScreenCordX>160)
- unknownLog=centreKnownLog+((unkwPointScreenCordX-160)*eachPixelLongDiff);
- if(unkwPointScreenCordY>220)
- unknownLat=centreKnownLat-((unkwPointScreenCordY-220)*eachPixelLatDiff);
- }
- //North West
- if(mPoint.getLatitudeE6()>0 && mPoint.getLongitudeE6()<0)
- {
- if(unkwPointScreenCordX<160)
- unknownLog=centreKnownLog-((160-unkwPointScreenCordX)*eachPixelLongDiff);
- if(unkwPointScreenCordX>160)
- unknownLog=centreKnownLog+((unkwPointScreenCordX-160)*eachPixelLongDiff);
- if(unkwPointScreenCordY<220)
- unknownLat=centreKnownLat+((220-unkwPointScreenCordY)*eachPixelLatDiff);
- if(unkwPointScreenCordY>220)
- unknownLat=centreKnownLat-((unkwPointScreenCordY-220)*eachPixelLatDiff);
- }
- //South West
- if(mPoint.getLatitudeE6()<0 && mPoint.getLongitudeE6()<0)
- {
- if(unkwPointScreenCordX<160)
- unknownLog=centreKnownLog-((160-unkwPointScreenCordX)*eachPixelLongDiff);
- if(unkwPointScreenCordX>160)
- unknownLog=centreKnownLog+((unkwPointScreenCordX-160)*eachPixelLongDiff);
- if(unkwPointScreenCordY<220)
- unknownLat=centreKnownLat+((220-unkwPointScreenCordY)*eachPixelLatDiff);
- if(unkwPointScreenCordY>220)
- unknownLat=centreKnownLat-((unkwPointScreenCordY-220)*eachPixelLatDiff);
- }
- //South East
- if(mPoint.getLatitudeE6()<0 && mPoint.getLongitudeE6()>0)
- { if(unkwPointScreenCordX<160)
- unknownLog=centreKnownLog-((160-unkwPointScreenCordX)*eachPixelLongDiff);
- if(unkwPointScreenCordX>160)
- unknownLog=centreKnownLog+((unkwPointScreenCordX-160)*eachPixelLongDiff);
- if(unkwPointScreenCordY<220)
- unknownLat=centreKnownLat+((220-unkwPointScreenCordY)*eachPixelLatDiff);
- if(unkwPointScreenCordY>220)
- unknownLat=centreKnownLat-((unkwPointScreenCordY-220)*eachPixelLatDiff);
- }
- return 0;
- }
Parsed in 0.043 seconds, using GeSHi 1.0.8.4




