javiers

Active Member
Licensed User
Longtime User
Unfortunately you need a Key API. I am using all free bees, adding a key would mean making many changes in the code. Find a map that does not require Api Key
Hi, thanks for your response. I hadn't realized an API was necessary for this image provider.

I understand this may not be among your priorities, but I see that Leaflet offers the option to view WMS (Web Map Service) layers.
For Spain (which is my area of work), the most up-to-date satellite imagery can be obtained using a WMS, in addition to other layers of interest for emergency services. I understand this is very specific, but, would it be possible to access WMS layers in a "simple" way for users who don't know much... perhaps by configuring the most important options in a file or something like that?

URL: .URL of the WMS web service we want to consume.
layers: Specifies the name of the WMS layer we want to request from the server.
format: Defines the format of the image to be downloaded (for example, image/png or image/jpeg).
transparent: Indicates whether the layer should have transparency (true) or not (false).
attribution: Add information about the source of the data, which will be displayed on the map.

Example...

Ejemplo:
// Definir las capas WMS
var pnoaLayer = L.tileLayer.wms('https://www.ign.es/wms-inspire/pnoa-ma?', {
    layers: 'OI.OrthoimageCoverage',
    format: 'image/jpeg',
    transparent: false,
    attribution: 'PNOA - © Instituto Geográfico Nacional de España'
});

var curvasNivelLayer = L.tileLayer.wms('https://servicios.idee.es/wms-inspire/mdt?', {
    layers: 'EL.ContourLine',
    format: 'image/png',
    transparent: true,
    attribution: '© Instituto Geográfico Nacional de España'
});

var ignBaseLayer = L.tileLayer.wms('https://www.ign.es/wms-inspire/ign-base?', {
    layers: 'IGNBaseOrto',
    format: 'image/png',
    transparent: true,
    opacity: 0.75,
    attribution: '© Instituto Geográfico Nacional de España'
});

var catastroLayer = L.tileLayer.wms('https://ovc.catastro.meh.es/cartografia/INSPIRE/spadgcwms.aspx?', {
    layers: 'BU.Building',
    format: 'image/png',
    transparent: true,
    attribution: 'Catastro © Ministerio de Hacienda'
});

There's an example on this page. I don't know if this development is possible, and in any case, I understand the difficulty and why it's not planned, but I think access to these layers would be useful for more people.
Well, thank you again, and sorry if I'm going on about too much.
 

javiers

Active Member
Licensed User
Longtime User
Thanks for the new version (1.13).

1.13
Added method UpdatePolygonFillColor, AddMarker3, AddMarker2Label, AddMarker3Label to OpenMaps class
Added method bestRouteTSP to OpenMapsExt class
Fix bugs Label / icon marker


Waiting for the next one!!

  • 1.14
    • Added AlternativeMap method to be able to insert other maps that require API KEY
    • Polygon/Polyline editor improve
 

Star-Dust

Expert
Licensed User
Longtime User
Update rel. 1.13
  • Added method UpdatePolygonFillColor, AddMarker3, AddMarker2Label, AddMarker3Label to OpenMaps class
  • Added method bestRouteTSP to OpenMapsExt class
  • Fix bugs Label / icon marker
 

javiers

Active Member
Licensed User
Longtime User
Hi, I'm trying to use this last feature AlternativeMap , but I'm not able to.
I use these map providers: https://leaflet-extras.github.io/leaflet-providers/preview/

It works with Esri.WorldImagery.
B4X:
GMap.AlternativeMap("https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",20 ,"Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community")

It doesn't work with Stadia.AlidadeSatellite:

B4X:
    Dim atribucion As String = $"&copy; CNES, Distribution Airbus DS, © Airbus DS, © PlanetObserver (Contains Copernicus Data) | &copy; <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a> &copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors"$
    If GMap.IsReady Then GMap.AlternativeMap("https://tiles.stadiamaps.com/tiles/alidade_satellite/{z}/{x}/{y}{r}.jpg",20 ,atribucion)

You can get an API key at https://stadiamaps.com/, but I don't know if it's possible to use it here...



Finally, would it be possible to access this WMS layer?

B4X:
// Define the WMS layers
var pnoaLayer = L.tileLayer.wms('https://www.ign.es/wms-inspire/pnoa-ma?', {
layers: 'OI.OrthoimageCoverage',
format: 'image/jpeg',
transparent: false,
attribution: 'PNOA - © Instituto Geográfico Nacional de España'
});

I appreciate the help!
 

Star-Dust

Expert
Licensed User
Longtime User
Hi, I'm trying to use this last feature AlternativeMap , but I'm not able to.
In theory, some Stadia Maps should work without an API key, but as of 2023/2024 they have made the key mandatory for almost all of their services, even the free plan.
B4X:
GMap.AlternativeMap("https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}.png?api_key=abcd1234-xxxx-yyyy-zzzz-1234567890",20,$"&copy; <a href="https://stadiamaps.com/">Stadia Maps</a> &copy; <a href="https://openmaptiles.org/">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>"$)
 

javiers

Active Member
Licensed User
Longtime User
Thank you! Works!

B4X:
GMap.AlternativeMap("https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}.png?api_key=abcd1234-xxxx-yyyy-zzzz-1234567890",20,$"&copy; <a href="https://stadiamaps.com/">Stadia Maps</a> &copy; <a href="https://openmaptiles.org/">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>"$)


B4X:
    If GMap.IsReady Then GMap.AlternativeMap("https://tiles.stadiamaps.com/tiles/alidade_satellite/{z}/{x}/{y}{r}.jpg?api_key=abcd1234-xxxx-yyyy-zzzz-1234567890",20 ,$"&copy; <a href="https://stadiamaps.com/">Stadia Maps</a> &copy; <a href="https://openmaptiles.org/">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>"$)



Regarding that WMS layer, would that be possible?
 

Star-Dust

Expert
Licensed User
Longtime User

javiers

Active Member
Licensed User
Longtime User
I did not understand exactly what you ask
Sorry, I was referring to Service WMS

There are some maps (for Spain) for WMS services. Specifically, satellite images, which I believe are configured in Leaflet with an L.tileLayer.wms function.

B4X:
// Definir las capas WMS
var pnoaLayer = L.tileLayer.wms('https://www.ign.es/wms-inspire/pnoa-ma?', {
    layers: 'OI.OrthoimageCoverage',
    format: 'image/jpeg',
    transparent: false,
    attribution: 'PNOA - © Instituto Geográfico Nacional de España'
});


I don't know if it could be implemented or if it's impossible.
Thanks again (for your work and your patience).
 

Star-Dust

Expert
Licensed User
Longtime User
In this version it is not possible. See in the following
 

yfleury

Active Member
Licensed User
Longtime User
I prefer the look of Google Maps and don't like the look of OpenStreetMap, which doesn't provide enough detail.

With Leaflet, we can use GoogleMutant in a webView, and the look is very similar to Google Maps, almost identical. It's fine for simple things like a few markers, polylines, etc., but for a large project, it's too complicated and cumbersome to manage.

I don't know if it's feasible to add something like GoogleMutant to jSD_OpenMaps. Or to have other map types that look more like Google Maps, like MAP_TYPE_CARTO. But I need to see the rectangles representing the houses for more precision. Needless to say, satellite images are clearer with Google Maps. But we all know that.

Thanks @Star-Dust for your works
 

Attachments

  • Capture d’écran 2025-05-25 092922.png
    137.6 KB · Views: 60
  • Capture d’écran 2025-05-25 094934.png
    360.2 KB · Views: 72

Star-Dust

Expert
Licensed User
Longtime User
to use this type of map you need to make several changes to the library and certainly create a second specific library. This takes time and is not in my plans
 

yfleury

Active Member
Licensed User
Longtime User
I completely understand your point of view.
In the Leaflet JavaScript file (googlemutant), it uses Google tiles. This may not be usable with jSD_OpenMaps. But I've never used the API key, and it works fine with Leaflet. Here's some of the code to use Google tiles, but I don't know how to adapt it with AlternativeMap.

JavaScript:
    // Définir les différentes couches Google Maps
    var googleStreets = L.tileLayer('https://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}', {
        maxZoom: 20,
        subdomains: ['mt0', 'mt1', 'mt2', 'mt3'],
        attribution: '&copy; Google Maps'
    });

    var googleSatellite = L.tileLayer('https://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', {
        maxZoom: 20,
        subdomains: ['mt0', 'mt1', 'mt2', 'mt3'],
        attribution: '&copy; Google Maps'
    });

    var googleHybrid = L.tileLayer('https://{s}.google.com/vt/lyrs=y&x={x}&y={y}&z={z}', {
        maxZoom: 20,
        subdomains: ['mt0', 'mt1', 'mt2', 'mt3'],
        attribution: '&copy; Google Maps'
    });

    var googleTerrain = L.tileLayer('https://{s}.google.com/vt/lyrs=p&x={x}&y={y}&z={z}', {
        maxZoom: 20,
        subdomains: ['mt0', 'mt1', 'mt2', 'mt3'],
        attribution: '&copy; Google Maps'
    });

    // Couche OpenStreetMap pour comparaison
    var openStreetMap = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
        maxZoom: 19,
        attribution: '&copy; OpenStreetMap contributors'
    });
Thanks for all your job in this forum
 

Star-Dust

Expert
Licensed User
Longtime User
GogleMutant is used with Gridlayer and not with TileLayer. That's why in my library it is not possible to use Googlemutant.
GridLayer is more complex, it requires development, compared to TileLayer that is ready for use. It has a high customization and the performance depend on the implementation. (TileLayers is always fast)
GoogleMutant is a plugin, which extends Leaflet, which allows you to integrate Google Maps in conformity to Google's terms of service


The field of geolocation and maps is vast, as you have read someone else asked WMS (customizable dynamic maps).

I created sd_openmaps because it served me for my work to restart some applications that have no particular needs. It is an alternative to Googlemaps that implements the same methods to avoid rewriting the code already working. I don't go to create a solution to cover every need, it takes time.
But what I create for my customers if I can share it
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
PS.

Different of the maps you have already indicated are included in the various choices of maps already available.

However alternativemap is used like this

B4X:
GMap.AlternativeMap("https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}.png?api_key=abcd1234-xxxx-yyyy-zzzz-1234567890",20,$"&copy; <a href="https://stadiamaps.com/">Stadia Maps</a> &copy; <a href="https://openmaptiles.org/">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>"$)
 

Star-Dust

Expert
Licensed User
Longtime User
1.15
  • added AddMarker3bis - Adds the marker, hitting it in height in the coordinate indicated
  • The possibility of the escape seques in the panel text (GMap.MessageToPanel)
  • Fixed the bug that prevented having more openmaps classes started at the same time
 

KY Leng

Active Member
Licensed User
Longtime User
I can use your map library without any problem for my project when I compile with Java version 19. The tiles display correctly, I can draw the polyline and change the map source without problem. However, when I make the app to be standalone (EXE), I cannot load the map, see only white screen and error like this "(JSException) netscape.javascript.JSException: ReferenceError: Can't find variable: L". Can any memember help me?
 

Star-Dust

Expert
Licensed User
Longtime User
Add this
B4X:
#PackagerProperty: IncludedModules = jdk.crypto.ec
 

Ralph Parkhurst

Member
Licensed User
Longtime User
The implementation of jSD_OpenMaps v1.15 continues to work flawlessly in my B4J app - thank you again Star-Dust!

I am required by my customers to briefly document how my app uses the internet. This is what I have come up with for the Map Tiles section:

Map Tiles
  • Service: OpenStreetMap (via jSD_OpenMaps v1.15)
  • Protocol: HTTPS
  • Privacy: No user data is sent to OpenStreetMap
  • Port: 443
  • Direction: Outbound
  • Purpose: Retrieves map tiles for visual display within the application
  • Notes: DNS access must be allowed for public map tile providers (e.g., tile.openstreetmap.org or equivalent)
Have I missed anything, or does this adequately describe how jSD_OpenMaps uses the internet?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…