Author Topic: Insert image returned by Google Static Map API  (Read 4028 times)

0 Members and 1 Guest are viewing this topic.

FELIX

  • Bull Frog
  • Posts: 241
Insert image returned by Google Static Map API
« on: October 20, 2018, 11:23:47 PM »
From the string below how can I insert a Google Static Map image into AutoCAD?
I just need to get the image return of this API in AutoCAD.

Code: [Select]
(setq str "https://maps.googleapis.com/maps/api/staticmap?center=-22.876012,-42.445214&size=400x400&scale=1&zoom=17&maptype=satellite&key=MYKEY")

MYKEY = my Google KEY. I already have one

Vovka already provided an excellent application that inserts images from Google but can not provide the source code and therefore does not run on Bricscad, ZwCAD and GstarCAD and also executes many options.

OK.

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Insert image returned by Google Static Map API
« Reply #1 on: October 21, 2018, 06:07:07 AM »
you have the problem with downloading or inserting?

FELIX

  • Bull Frog
  • Posts: 241
Re: Insert image returned by Google Static Map API
« Reply #2 on: October 21, 2018, 11:46:13 AM »
I have not started the program yet. Just test a browser only because I do not know how to get the image and also lap it will come to be handled so first I need to download.

Send my Google KEY to your email in case you need to test if you do not have one. Google is giving a US$300.00 bonus to be used in a year.
OK.

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Insert image returned by Google Static Map API
« Reply #3 on: October 21, 2018, 12:43:42 PM »
I have not started the program yet. Just test a browser only because I do not know how to get the image and also lap it will come to be handled so first I need to download.
downloading is easy -> https://www.theswamp.org/index.php?topic=33750.0

FELIX

  • Bull Frog
  • Posts: 241
Re: Insert image returned by Google Static Map API
« Reply #4 on: October 21, 2018, 05:29:39 PM »
Code: [Select]
(IF (SETQ ARQKEY (FINDFILE "GOOGLEKEY.TXT"))
    (ALERT "file GOOGLEKEY.TXT OK.")
    (ALERT "File GOOGLEKEY.TXT not found!")
)
(IF ARQKEY
   (PROGN
   (SETQ ARQ (OPEN ARQKEY "r")) (SETQ MYKEY (READ-LINE ARQ)) (CLOSE ARQ)
   (setq MYSTR (STRCAT "https://maps.googleapis.com/maps/api/staticmap"
       "?center=-22.876012,-42.445214"
       "&size=400x400"
       "&scale=1"
       "&zoom=18"
       "&format=jpg"
       "&maptype=satellite"
       "&key=" MYKEY))
   (SETQ MYIMG (vl-filename-mktemp "MYIMG" (GETVAR "TEMPPREFIX") ".jpg"))
   (SETQ MYARQ (vk_DownloadFile MYSTR MYIMG))
   (IF MYARQ (ALERT MYARQ))
   )
)
(PRINC)

Yes, with your help, Vovka, it was easy.

The next step, the most important is to insert the image.

The conversion of geographic coordinates to UTM does not have to, since I have some guidelines for this.

What I really need are: scale, angle of rotation and the insertion point because a center point is passed and the image is inserted in the lower left corner.

I also know that the size and zoom will also interfere but I can see later maybe.

Can you help me with these Vovka too?
OK.

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Insert image returned by Google Static Map API
« Reply #5 on: October 21, 2018, 06:14:04 PM »
Can you help me with these Vovka too?
i guess you'll have to find geographic coordinates of lower left and upper right corners of this image, then convert them to UTM coordinates and then align it

FELIX

  • Bull Frog
  • Posts: 241
Re: Insert image returned by Google Static Map API
« Reply #6 on: October 21, 2018, 07:26:19 PM »
Ok I'll try.
OK.

FELIX

  • Bull Frog
  • Posts: 241
Re: Insert image returned by Google Static Map API
« Reply #7 on: October 22, 2018, 09:37:44 AM »
I found how to do it but it is in JavaScript and I do not master this.

https://stackoverflow.com/questions/44784839/calculate-bounding-box-of-static-google-maps-image
OK.

FELIX

  • Bull Frog
  • Posts: 241
Re: Insert image returned by Google Static Map API
« Reply #8 on: October 25, 2018, 12:43:01 AM »
I was able to get the coordinates of the lower left and upper right corners of the image.
I did the alignment (scale and rotate)

I need one more tip. How to create the mesh to insert the images?
OK.

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Insert image returned by Google Static Map API
« Reply #9 on: October 25, 2018, 05:10:55 AM »
How to create the mesh to insert the images?
what mesh?
you want to insert the neighboring image?

FELIX

  • Bull Frog
  • Posts: 241
Re: Insert image returned by Google Static Map API
« Reply #10 on: October 25, 2018, 11:57:59 AM »
Mount a mesh like your image in IRT so the maps fit
Divides geographies into equal spacings and converts to UTM?
OK.

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Insert image returned by Google Static Map API
« Reply #11 on: October 25, 2018, 01:25:13 PM »
Mount a mesh like your image in IRT so the maps fit
Divides geographies into equal spacings and converts to UTM?
IRT works in a different way, it downloads static tiles, they are not generated "on demand" as in your code
and shows the mesh only as a preview

FELIX

  • Bull Frog
  • Posts: 241
Re: Insert image returned by Google Static Map API
« Reply #12 on: October 25, 2018, 04:02:29 PM »
Yes, your mesh is just visualization but the coordinates of this mesh as it is defined?
OK.

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: Insert image returned by Google Static Map API
« Reply #13 on: October 26, 2018, 04:51:07 AM »
Yes, your mesh is just visualization but the coordinates of this mesh as it is defined?
if you have the lower left and upper right coordinates of a tile then you can draw a rectangle and then you can make an array of rectangles
you'll get 'a mesh' as a result

FELIX

  • Bull Frog
  • Posts: 241
Re: Insert image returned by Google Static Map API
« Reply #14 on: October 26, 2018, 10:03:31 AM »
Yes, your mesh is just visualization but the coordinates of this mesh as it is defined?
if you have the lower left and upper right coordinates of a tile then you can draw a rectangle and then you can make an array of rectangles
you'll get 'a mesh' as a result

Okay, that's how I did it, I got it, thank you anyway.
OK.