Jump to content

Leaflet OpenStreetMaps Example


GerhardV

Recommended Posts

An example showing how to incorporate Leaflet and OpenStreetMaps into UniGUI.

The following lines must be added to the ServerModule | CustomFiles:

See the Mapbox Tab in the application for more details.

P.S. I am no expert with Leaflet - please see the following for more details:

Getting started with Leaflet

OpenStreetMap

Mapbox - the accessToken used for this is a public one...you can register to receive your own.

opera_2018-09-11_17-36-09.png

opera_2018-09-11_17-36-38.png

Leaflet Maps Example.zip

  • Like 2
  • Upvote 1
Link to comment
Share on other sites

  • 2 months later...

I answer myself:

 

1) 

   UniSession.AddJS('var marker = L.marker([37.184203, -5.847710]).addTo(leafletMap).bindPopup("text");');

 

2) in afteruodatehtml in clientevents of the htmlframe:

 

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

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

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

var googleStreets = L.tileLayer('http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',{
    maxZoom: 20,
    subdomains:['mt0','mt1','mt2','mt3']
});

 

      leafletMap = L.map('uni_map_leaflet', {
                layers: [googleHybrid] // only add one!
            })
            .setView([37.18161024, -5.84075043], 10);


        var baseLayers = {
            "Hybrid": googleHybrid,
            "Street": googleStreets,
            "Satellite": googleSat,
            "Terrain": googleTerrain,
            "Catastro": catastro
        };

        L.control.layers(baseLayers).addTo(leafletMap);

 

 

  • Like 2
Link to comment
Share on other sites

  • 4 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...