Developer forum

Forum » Development » Use ItemType_Location in maps

Use ItemType_Location in maps

Tomas Gomez
Reply

Hi,

I'm trying to create a map containing the locations saved in the ItemType_Location table from the Rapido database. Using the backend I haven't this choice, only to add the points one by one and I don't wish that (see image 1)

I created a data list with the content of the ItemType_Location table, but I didn't find how to take the data from this data list into the map in the configuration of the Map item.

Another option would be creating a custom web api service to get the data from the database and make an Ajax request to get this data (see image 2)

Is there an easier option?

Regards,
Tomas

 

image_1.png image_2.png

Replies

 
Tomas Gomez
Reply
This post has been marked as an answer

I solved the issue creating a web service about stores location, getting the data, making an Ajax call, and inserting the data into a div.

Attached is the image with the result, and this is the code of the ajax call:

function () {

          var options = {};
          options.url = "/api/location";
          options.type = "GET";
          options.dataType = "json";
          options.async = false;
          options.success = function (data) {

              data.forEach(function (element) {
                  //$("#result").append("<h3>" + element + "</h3>");
                  console.log(element);
                  var location = $.parseJSON(element["location"]);
                  console.log(location);
                  //insertar valores en el mapa
                  var rows = "<div class='grid__col-md-3 js-current' data-lat='"+location['Lat']+"'data-lng='"+location['Lng']+"'  data-icon data-title='"+element['name']+"'>" + 
                          "<div class='dynamicweb-map__location-item'>"+
                          "<div class='dynamicweb-map__location-name js-location-search-item'>"+element['name']+"</div>"+
                          "<div class='dynamicweb-map__location-info'>"+
                              "<div class='js-location-search-item'>"+element['address']+"</div>"+
                              "<div class='js-location-search-item'>"+element['city']+"</div>"+
                              "<div class='js-location-search-item'>"+element['country']+"</div>"+
                          "</div>"+
                          "</div>";  
                  $('#Maps-1685-list').append(rows);  

 

              });
        }

 

image.png
Votes for this answer: 1

 

You must be logged in to post in the forum