MapView - Layer with street and town names

Post

Posted
Rating:
#1 (In Topic #619)
Regular
01McAc is in the usergroup ‘Regular’
I am experimenting with the component MapView. Purpose is to get a fast GPS exif browser for jpg and raw files. I am struggling with different layers in Google Maps. How can I enable or disable different layers of in Google Maps like street/town names, topographic view, etc.

What I see right now for the coordinates 52.52033763987445, 13.376083912073048 is the following
Image

(Click to enlarge)


InLat=52.52033763987445 and InLon=13.376083912073048

Code (gambas)

  1. Public Sub ShowMap(InLat As Variant, InLon As Variant)
  2.   Dim iZoom As Integer
  3.   Dim fLatitude, fLongitude As Float
  4.   Dim sCacheName, sTileName, sTilePattern As String
  5.   Dim cArguments As New Collection
  6.   Dim sPoint As String
  7.   Inc iCounter
  8.  
  9.   iZoom = 13  
  10.   sTileName = "OpenStreetMap"
  11.   sTilePattern = "http://\{s}.tile.openstreetmap.org/\{z}/\{x}/\{y}.png"
  12.  
  13.   cArguments = Null
  14.   sCacheName = Null  
  15.   fLatitude = CFloat(InLat)  ' °Lat
  16.   fLongitude = CFloat(InLon) ' °Lon  
  17.   sPoint = CStr(fLatitude) & ", " & CStr(fLongitude)
  18.   Debug RB_Openstreetmap.Value
  19.   Debug RB_GoogleMaps.Value
  20.  
  21.   If RB_Openstreetmap.Value = True Then
  22.     sTileName = "OpenStreetMap"
  23.     MapView1.Map.AddTile(sTileName, sTilePattern, cArguments, sCacheName)
  24.     MapView1.Map[sTileName].Copyright = " © OpenStreetMap"
  25.  
  26.   If RB_GoogleMaps.Value = True Then
  27.     sTileName = "GoogleMaps"
  28.     MapView1.Map.AddTile("GoogleMaps", "https://khms\{s}.google.it/kh/v=\{version}&src=app&x=\{x}&y=\{y}&z=\{z}&s=Galile", ["version": "869"]).SubDomains = ["0", "1", "2"]
  29.     MapView1.Map[sTileName].Copyright = " © GoogleMaps"
  30.  
  31.   If RB_virtualearth.Value = True Then
  32.     sTileName = "VirtualEarth"
  33.     MapView1.Map.AddTile(sTileName, "http://ecn.dynamic.t\{s}.tiles.virtualearth.net/comp/ch/\{q}?mkt=fr-fr&it=G,VE,BX,L,LA&shading=hill&n=z&cb=1").SubDomains = ["0", "1", "2"]
  34.     MapView1.Map[sTileName].Copyright = " © VirtualEarth"
  35.  
  36.   MapView1.Map.DefaultCache = "/tmp"
  37.   MapView1.Map[sTileName].Visible = True ' optional;
  38.   MapView1.Map.AddShape("P" & iCounter)
  39.   'MapView1.Map!P1.AddPoint(sPoint, MapPoint(fLatitude, fLongitude))  
  40.   MapView1.Map["P" & iCounter].AddPoint(sPoint, MapPoint(fLatitude, fLongitude))  
  41.   MapView1.Map.Center = MapPoint(fLatitude, fLongitude)
  42.  
  43.   MapView1.Map.Zoom = iZoom
  44.   MapView1.AllowEffect = True
  45. End ' ShowMap()

Any ideas?
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
You might like to look at 'PhotoEXIF' that I wrote. It is on the Gambas Farm. This manipulates the URL to get what I wanted. You want more! I notice that the URLs change depending on what feature you request. I have not worked out what all the codes in the URL do, but you can see the changes. Try these of the island of Guernsey where I live.

Normal view
Satellite view
Terrain view
Traffic view

The URLs are: -
Google Maps
Google Maps
Google Maps
Google Maps
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
stevedee is in the usergroup ‘Regular’
Yes you need to change the "pattern" argument to display the required layer.

So for a Road Map:-

Code

MapView1.Map.AddTile("GoogleMap", "http://mt0.google.com/vt/lyrs=m&hl=en&x=\{x}&y=\{y}&z=\{z}")

Satellite:-

Code

MapView1.Map.AddTile("GoogleMap", "http://mt0.google.com/vt/lyrs=s&hl=en&x=\{x}&y=\{y}&z=\{z}")

Terrain:-

Code

MapView1.Map.AddTile("GoogleMap", "http://mt0.google.com/vt/lyrs=t&hl=en&x=\{x}&y=\{y}&z=\{z}")

Its the "p&hl" bit that changes.
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
01McAc is in the usergroup ‘Regular’
cogier : I'll have close look into the PhotoExif program tomorrow. After a first quick run through it looks 'wow' but throws an error when clicked and changed to another directory. It is very interesting how the exif information gets extracted. My app is much simpler and just focused on GPS and the mapview.
How is life in Guernsey? Must be a lovely spot especially in time of Covid-19.

stevedee : Road map and satellite both work but terrain shows just a black rough surface in mapview.
Its the "p&hl" bit that changes.
What do you mean exactly?

Thanks you both of you. I'll try (and error) in the next couple of days.
Another question is about raw files. Filemanager Dolphin and others provide a preview of a raw file *.DNG. FileView ind Gambas doesn't. Can I train FileView somehow to show a preview of DNG-files?
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
stevedee is in the usergroup ‘Regular’

01McAc said

…@stevedee: Road map and satellite both work but terrain shows just a black rough surface in mapview.
That layer is described as Terrain Only so I guess that's what you are getting. Try this one:-

Code

MapView1.Map.AddTile("GoogleMap", "http://mt0.google.com/vt/lyrs=p&hl=en&x=\{x}&y=\{y}&z=\{z}").Copyright = "© GoogleMaps"

Its the "p&hl" bit that changes.
What do you mean exactly?

The only bit that changes in this sequence of "patterns" for different Layers is: "m&hl"…"p&hl" … "s&hl" … "t&hl" … "y&hl" … "r&hl

…Can I train FileView somehow to show a preview of DNG-files?

You will need a utility to either convert RAW into another format or to extract the small jpeg image that is embedded in RAW files.
Note that DNG is just one RAW format. Most camera manufacturers have their own format.
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Regular
stevedee is in the usergroup ‘Regular’

01McAc said

…@stevedee: Road map and satellite both work but terrain shows just a black rough surface in mapview…

Yes the Terrain Only Pattern doesn't do anything.

But I found that "h" produces a strange map layer…

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#7
Guru
BruceSteers is in the usergroup ‘Guru’

stevedee said

01McAc said

…@stevedee: Road map and satellite both work but terrain shows just a black rough surface in mapview.
That layer is described as Terrain Only so I guess that's what you are getting. Try this one:-

Code

MapView1.Map.AddTile("GoogleMap", "http://mt0.google.com/vt/lyrs=p&hl=en&x=\{x}&y=\{y}&z=\{z}").Copyright = "© GoogleMaps"

Its the "p&hl" bit that changes.
What do you mean exactly?

The only bit that changes in this sequence of "patterns" for different Layers is: "m&hl"…"p&hl" … "s&hl" … "t&hl" … "y&hl" … "r&hl

…Can I train FileView somehow to show a preview of DNG-files?

You will need a utility to either convert RAW into another format or to extract the small jpeg image that is embedded in RAW files.
Note that DNG is just one RAW format. Most camera manufacturers have their own format.

Does Image class not convert raw to jpg ?
My icon maker app loads all manner of image types and saves as many different types even .ico but all it uses is Image.Load() Image.Save()

I'm not entirely sure what you are doing but i get the feeling Image class is your friend here being able to load many formats and even extract parts of an image.

All the best
Online now: No Back to the top

Post

Posted
Rating:
#8
Regular
01McAc is in the usergroup ‘Regular’
Does Image class not convert raw to jpg ?
Unfortunately not. When I load the DNG file

Code (gambas)

  1. hImageIW = Image.Load(FileChooser1.SelectedPath)

there are a few messages from the interpreter in the debug window:
TIFFReadDirectory: Warning, Unknown field with tag 51125 (0xc7b5) encountered.
foo: Sorry, can not handle image with PhotometricInterpretation=32803.
 and the code stopped working with an error message saying

Code

Unable to load image in FMain:123

Image types like jpg, png, ico, etc are not a problem.
Online now: No Back to the top

Post

Posted
Rating:
#9
Regular
01McAc is in the usergroup ‘Regular’

stevedee said

But I found that "h" produces a strange map layer…
Yes indeed. MapSD is quite a cool little program. A nice demonstration what Gambas is capable of - with just a few lines of code.
How do you know the URLs? I haven't found any documention re Google Maps. Common knowlege?
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Guru
cogier is in the usergroup ‘Guru’
@cogier: I'll have close look into the PhotoExif program tomorrow. After a first quick run through it looks 'wow' but throws an error when clicked and changed to another directory. It is very interesting how the exif information gets extracted. My app is much simpler and just focused on GPS and the mapview.

I would be interested in finding the error and sorting it. Can you let me know what Distro you are running, what you did to create the error, what and where it is.

How is life in Guernsey? Must be a lovely spot especially in time of Covid-19.
I don't want to live anywhere else. We had a few cases of Covid-19 pop up in January, but it's all under control, no new cases for 19 days, and if all stays that way we will free from lock down restraints on Monday (22/03).
Online now: No Back to the top

Post

Posted
Rating:
#11
Avatar
Regular
stevedee is in the usergroup ‘Regular’

01McAc said

…How do you know the URLs? I haven't found any documention re Google Maps. Common knowlege?

I did a lot of searching. Seem to get lucky on sites where users are quoting this stuff for other programming languages.
Online now: No Back to the top

Post

Posted
Rating:
#12
Regular
01McAc is in the usergroup ‘Regular’
I would be interested in finding the error and sorting it. Can you let me know what Distro you are running, what you did to create the error, what and where it is.

Here it is.
Image

(Click to enlarge)


I attached the jpg image which caused the errror. I suppose someone has lost his armchair.
Online now: No Back to the top

Post

Posted
Rating:
#13
Avatar
Guru
cogier is in the usergroup ‘Guru’
Thanks for the reply and the picture, but I could not recreate the error. Expensive camera!!

<IMG src="https://www.cogier.com/gambas/NoError.png"> </IMG>
Online now: No Back to the top

Post

Posted
Rating:
#14
Regular
01McAc is in the usergroup ‘Regular’

cogier said

Thanks for the reply and the picture, but I could not recreate the error.
I think it's not actually a bug rather than a national interpretation of numbers. When the 'error' occurs I've got the following numbers

Code (gambas)

  1. fLat = Val(sLatArray[0]) + (Val(sLatArray[1]) / 60) + (Val(sLatArray[2]) / 3600)

sLatArray[2] = 37.58
Val(sLatArray[2]) = NULL

So why NULL? In Germany Val("37,58") is equal to 37,58 (which is correct)
I might switch to English but I don't find the settings in the IDE.

cogier said

Expensive camera

Once in a lifetime. I presume I am the one of five people in the world using this camera, post process with open source with Linux ;)
Online now: No Back to the top

Post

Posted
Rating:
#15
Avatar
Guru
cogier is in the usergroup ‘Guru’
So why NULL? In Germany Val("37,58") is equal to 37,58 (which is correct)

I didn't think of that. Can you try adding the 'New' code below, and let me know if that works for you in your German setup. If it does it should work for other languages as well.

Code (gambas)

  1.   sLatArray = Split(sLat, " ")
  2.   sLongArray = Split(sLong, " ")
  3.  
  4.   If IsNull(Val("2.2")) Then                        ''New
  5.     sLatArray = Replace(sLatArray, ".", ",")        ''New
  6.     sLongArray = Replace(sLongArray, ".", ",")      ''New
  7.  
  8.   fLat = Val(sLatArray[0]) + (Val(sLatArray[1]) / 60) + (Val(sLatArray[2]) / 3600)
  9.   fLong = Val(sLongArray[0]) + (Val(sLongArray[1]) / 60) + (Val(sLongArray[2]) / 3600)

Once in a lifetime. I presume I am the one of five people in the world using this camera, post process with open source with Linux ;)

Good for you. Puts my Canon 6D MkII in its place! I also use Linux for all my photography.
Online now: No Back to the top

Post

Posted
Rating:
#16
Regular
01McAc is in the usergroup ‘Regular’
Weird, the condition IsNull(Val("2.2")) is never true
When I type Val("2.2") into the console the result is "02.02.2021 00:00:00"

Then I replaced your condition with the code

Code (gambas)

  1. InStr(sLatArray[2], ".")

This condition becomes true but

Code (gambas)

  1. sLatArray = Replace(sLatArray, ".", ",")
expects a string: an error occurs. I guess you need to go through the array in a loop and then replace the values one by one.


The following code works but I suppose it is not very elegant:

Code (gambas)

  1. If InStr(sLatArray[2], ".") Then                        ''New
  2.     sLatArray[0] = Replace(sLatArray[0], ".", ",")        ''New
  3.     sLatArray[1] = Replace(sLatArray[1], ".", ",")        ''New
  4.     sLatArray[2] = Replace(sLatArray[2], ".", ",")        ''New
  5.     sLongArray[0] = Replace(sLongArray[0], ".", ",")      ''New
  6.     sLongArray[1] = Replace(sLongArray[1], ".", ",")      ''New
  7.     sLongArray[2] = Replace(sLongArray[2], ".", ",")      ''New

All in all this is actually the application I was looking for. I just need to enhance it to raw files.
Online now: No Back to the top

Post

Posted
Rating:
#17
Regular
01McAc is in the usergroup ‘Regular’

01McAc said

The following code works

Continued some tests. My code is not reliable, sorry. It doesn't work for all jpg's. I don't know, why.

I did notice you are using exiftool to extract the exif tags. I use the following parameter to get the correct "GPS Position"-tag in degrees (e.g. 54.989667). No calculation is necessary:

Code (gambas)

  1. aCommand = ["exiftool", "-c", "%+6f", "-x", "Arp", FileChooser1.SelectedPath, "|", "sort"]
  2. Exec aCommand To myGPS
  3.  
Online now: No Back to the top

Post

Posted
Rating:
#18
Avatar
Guru
cogier is in the usergroup ‘Guru’
I have set up my laptop with German as the main language and have tried various code changes to stop this problem, but there is always a knock on effect. I think I will leave it as it is for now.
Online now: No Back to the top

Post

Posted
Rating:
#19
Regular
01McAc is in the usergroup ‘Regular’
No worries. Don't get lost in German language on your computer.
I am currently working on my own Exif2Map app;) Just for fun. Sure, eveybody needs his own app! In the meantime I figured out which long way round it needs to preview raw file in the imageview class (e.g. *DNG). But what I haven't manage so far is to preview raw files in FileView class although Nautilus and Dolphin are able to show the embedded jpg immediately.
I copied one or another idea from your project PhotoEXIF. In particular I embraced the AutoResize and Expand functionality which I was (and still am) not familiar with. I'll provide an early beta version in Project Showcase subforum in the next few days.
Online now: No Back to the top
1 guest and 0 members have just viewed this.