MapView - Layer with street and town names

Ask about the individual Gambas components here.
01McAc
Posts: 75
Joined: Sunday 24th January 2021 8:25pm

MapView - Layer with street and town names

Post by 01McAc »

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
Maps.jpg
Maps.jpg (817.43 KiB) Viewed 6684 times
InLat=52.52033763987445 and InLon=13.376083912073048
Public Sub ShowMap(InLat As Variant, InLon As Variant)
  Dim iZoom As Integer
  Dim fLatitude, fLongitude As Float
  Dim sCacheName, sTileName, sTilePattern As String
  Dim cArguments As New Collection
  Dim sPoint As String
  Inc iCounter

  iZoom = 13  
  sTileName = "OpenStreetMap"
  sTilePattern = "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"

  cArguments = Null
  sCacheName = Null  
  fLatitude = CFloat(InLat)  ' °Lat
  fLongitude = CFloat(InLon) ' °Lon   
  sPoint = CStr(fLatitude) & ", " & CStr(fLongitude)
  Debug RB_Openstreetmap.Value
  Debug RB_GoogleMaps.Value 
  
  If RB_Openstreetmap.Value = True Then 
    sTileName = "OpenStreetMap"
    MapView1.Map.AddTile(sTileName, sTilePattern, cArguments, sCacheName)
    MapView1.Map[sTileName].Copyright = " © OpenStreetMap"
  Endif
  
  If RB_GoogleMaps.Value = True Then 
    sTileName = "GoogleMaps"
    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"]
    MapView1.Map[sTileName].Copyright = " © GoogleMaps"
  Endif
  
  If RB_virtualearth.Value = True Then
    sTileName = "VirtualEarth"
    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"]
    MapView1.Map[sTileName].Copyright = " © VirtualEarth"
  Endif
  
  MapView1.Map.DefaultCache = "/tmp"
  MapView1.Map[sTileName].Visible = True ' optional;
  MapView1.Map.AddShape("P" & iCounter)
  'MapView1.Map!P1.AddPoint(sPoint, MapPoint(fLatitude, fLongitude))  
  MapView1.Map["P" & iCounter].AddPoint(sPoint, MapPoint(fLatitude, fLongitude))  
  MapView1.Map.Center = MapPoint(fLatitude, fLongitude)

  MapView1.Map.Zoom = iZoom 
  MapView1.AllowEffect = True
End ' ShowMap()
Any ideas?
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: MapView - Layer with street and town names

Post by cogier »

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: -
https://www.google.com/maps/@49.4616719,-2.5680989,13.37z
https://www.google.com/maps/@49.4616719,-2.5680989,8717m/data=!3m1!1e3
https://www.google.com/maps/@49.4616719,-2.5680989,13.37z/data=!5m1!1e4
https://www.google.com/maps/@49.4616719,-2.5680989,13.37z/data=!5m2!1e1!1e4
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: MapView - Layer with street and town names

Post by stevedee »

Yes you need to change the "pattern" argument to display the required layer.

So for a Road Map:-

Code: Select all

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

Code: Select all

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

Code: Select all

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.
01McAc
Posts: 75
Joined: Sunday 24th January 2021 8:25pm

Re: MapView - Layer with street and town names

Post by 01McAc »

@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?
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: MapView - Layer with street and town names

Post by stevedee »

01McAc wrote: Sunday 14th March 2021 7:01pm ...@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: Select all

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.
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: MapView - Layer with street and town names

Post by stevedee »

01McAc wrote: Sunday 14th March 2021 7:01pm ...@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...
MapSD.tar.gz
(7.33 KiB) Downloaded 293 times
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: MapView - Layer with street and town names

Post by BruceSteers »

stevedee wrote: Sunday 14th March 2021 9:15pm
01McAc wrote: Sunday 14th March 2021 7:01pm ...@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: Select all

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
If at first you don't succeed , try doing something differently.
BruceS
01McAc
Posts: 75
Joined: Sunday 24th January 2021 8:25pm

Re: MapView - Layer with street and town names

Post by 01McAc »

Does Image class not convert raw to jpg ?
Unfortunately not. When I load the DNG file
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: Select all

Unable to load image in FMain:123
Image types like jpg, png, ico, etc are not a problem.
01McAc
Posts: 75
Joined: Sunday 24th January 2021 8:25pm

Re: MapView - Layer with street and town names

Post by 01McAc »

stevedee wrote: Sunday 14th March 2021 9:15pm 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?
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: MapView - Layer with street and town names

Post by cogier »

@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).
Post Reply