Draw shape of land on view by taking latitude and longitude in iOS? -


i want draw shape of small land on view taking latitude , longitude @ corner of land.

i have wrote following code. took hard core values.

- (void)drawrect:(cgrect)rect {  cgsize screensize = [uiscreen mainscreen].applicationframe.size; scale = min(screensize.width, screensize.height) / (2.0 * earth_radius); offset = min(screensize.width, screensize.height) / 2.0;  cgpoint latlong1 = {18.626103, 73.805023}; cgpoint latlong2 = {18.626444, 73.804884}; cgpoint latlong3 = {18.626226, 73.804969}; cgpoint latlong4 = {18.626103, 73.805023};   nsmutablearray *points=[nsmutablearray arraywithobjects:[nsvalue valuewithcgpoint:[self convertlatlongcoord:latlong1]],[nsvalue valuewithcgpoint:[self convertlatlongcoord:latlong2]], [nsvalue valuewithcgpoint:[self convertlatlongcoord:latlong3]],[nsvalue valuewithcgpoint:[self convertlatlongcoord:latlong4]],nil];  cgcontextref ctx = uigraphicsgetcurrentcontext();     for(int i=0;i<points.count;i++)    {        // cgpoint newcoord = [self convertlatlongcoord:latlong];         nsvalue *val = [points objectatindex:i];        cgpoint newcoord = [val cgpointvalue];         if(i == 0)       {           // move first point           cgcontextmovetopoint(ctx, newcoord.x, newcoord.y);       }       else       {           cgcontextaddlinetopoint(ctx, newcoord.x, newcoord.y);            cgcontextsetlinewidth(uigraphicsgetcurrentcontext(), 1);            cgcontextsetstrokecolorwithcolor(ctx, [[uicolor redcolor] cgcolor]);       }            }      cgcontextstrokepath(ctx); } 

below method converts lat long x,y co-ordinates.

- (cgpoint)convertlatlongcoord:(cgpoint)latlong    {       cgfloat x = earth_radius * cos(latlong.x) * cos(latlong.y) * scale + offset;       cgfloat y = earth_radius * cos(latlong.x) * sin(latlong.y) * scale + offset;       return cgpointmake(x, y);    } 

my problem when took small land(e.g house land) area lat long shape not visible on view after draw. how can show maximise shape of land on view. in advance.


Comments