Author Topic: Code for Geographic Mapping?  (Read 1319 times)

anayi89

  • Guest
Code for Geographic Mapping?
« on: February 25, 2015, 08:15:22 pm »
Hello!

I have been searching for code that lets users pin their location on a mapping service and have been unable to find code that I can use in DragonFire. May someone please help?

Gus

  • Newbie
  • *
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Code for Geographic Mapping?
« Reply #1 on: February 28, 2015, 01:54:57 pm »
Hi anayi89
Your question is interesting
I think its possible, I wrote this line to try solve this.
of course is incomplete!


forum reviews:
https://developers.google.com/maps/documentation/staticmaps/#Latlons
http://dragonfiresdk.net/forum/index.php?topic=145.msg559#msg559

this print screen from DFSDK simulator
have a good luck  :)

#include <stdio.h>
#include <string.h>
#include "DragonFireSDK.h"

int MyFont;
int LatitudeText;
int LongitudeText;
char TextBuffer[200];
char LatitudeBuff[200];
char LongitudeBuff[200];
char completeUrl[200];
int refresh=0;
int MyText;
float lat;
float lng;
char name[50];
int img;
char SCORES_FILE_NAME[100] = "map2.png";
float altitude;

int OnResponse(int evento, char *response, int len){
   int i;
   int FilePng;
   if(evento>0){
      FilePng=FileCreate((char *)SCORES_FILE_NAME);
      for (i=0;i<len;i++)
      {
         FileWrite(FilePng, (char *)&response, len);
      }
      FileClose(FilePng);
      ImageSetImage(img,"Documents/map2.png");//you need void this line replace with a perfect code
   }
return evento;
}

void AppMain()
{
   PortraitMode();
   
   // Begin monitoring location
   LocationMonitorLocation(1);
   LocationMonitorHeading(1);
   //imagen map
   img=ImageAdd("empty.png");
   ViewAdd(img,0,0);//red image
   //text
   MyFont = FontAdd("Helvetica", "Regular", 24, 0xFB0000);
   LatitudeText = TextAdd(10, 30, "Latitude:", MyFont);
   LongitudeText =   TextAdd(10, 70, "Longitude:", MyFont);
}

//===============================================
void OnTimer()
{
   refresh--;
   if(refresh<=0){
      refresh=60;
      altitude = LocationGetAltitude();
      //print to screen
      LocationGet(lat, lng);
   
      sprintf(TextBuffer, "Latitude: %f", lat);
      TextSetText(LatitudeText, TextBuffer);
      sprintf(LatitudeBuff,"%f" ,lat);

      sprintf(TextBuffer, "Longitude: %f", lng);
      TextSetText(LongitudeText, TextBuffer);
      sprintf(LongitudeBuff,"%f",  lng);
   
      //*****************map request************
      //"zhttps://maps.googleapis.com/maps/api/staticmap?center=      34.7669885      ,      -117.8604357    &zoom=14&size=400x400&markers=color:blue%7Clabel:G%7C   34.7669885      ,           -117.8604357"
      //                        string 1                                                                      string 2    comma 1     string 3                           string 4                                                                             string 5     comma 2     string 6
      strcpy(completeUrl,"http://maps.googleapis.com/maps/api/staticmap?center=");//string 1
      strcat(completeUrl,LatitudeBuff);//string 2
      strcat(completeUrl,","); //comma 1
      strcat(completeUrl,LongitudeBuff);//string 3
      strcat(completeUrl,"&zoom=14&size=768x1024&markers=color:blue%7Clabel:G%7C");//string 4
      strcat(completeUrl,LatitudeBuff);//string 5
      strcat(completeUrl,",");//comma 2
      strcat(completeUrl,LongitudeBuff);//string 6
      //Example completeUrl: NetSend("https://maps.googleapis.com/maps/api/staticmap?center=34.7669885,-117.8604357&zoom=12&size=400x400&markers=color:blue%7Clabel:G%7C34.7669885,-117.8604357", OnResponse);
   
      NetSend(completeUrl, OnResponse);

   }
}
//===============================================
void AppExit()
{

}


« Last Edit: February 28, 2015, 02:03:30 pm by Gus »