Hi,

I am trying to add the lat/lon as a layer to the viewer in MapGuide react
layout I am not sure how to define the map and add layers like what we do
in fusion. We use the following code in mapguide fusion but how do you add
the features on the react layout viewer?

var map = parent.Fusion.getWidgetById('Map');

and after it was possible to place a marker on the map

var olMap = map.oMapOL;
var oldmarkers = olMap.getLayersByName ( "Markers" );


Do you know where in my code here need change to add the lat/lon typed
a list to the viewer's map? below is my code



function addLatlngLayer()
{
  var name=window.document.getElementById("selectname").value;

  name="cus_"+tl.toString()+":"+name;
  tl=tl+1;
  var x=window.document.getElementById("selectcolor");
  var mycolor=x.value;
  var color=x.options[x.selectedIndex].text;
  var size=window.document.getElementById("selectsize").value;
  var latlngs=window.document.getElementById("latlng_list").value;
  latlngs=latlngs.replace(/\t/g, ",").replace(/\r/g, ""). split(/\n/)
  console.log(name, mycolor, size);
  if(name in latlng_layers) {
    alert("Layer "+name+" already added!")
  } else {
    var lg=L.layerGroup();
    for(let row of latlngs) {
      let t=row.split(",")
      console.log(t[1],t[2],t[0],size, mycolor);
      lg.addLayer(L.circleMarker([t[1],t[2]], {
            radius: size,
            color: mycolor,
            fillColor: mycolor,
            fillOpacity: 1
      }).bindPopup(t[0]));
    }
    latlng_layers[name]=lg.addTo(map);
    let table = document.getElementById("layer_list_table");
    let newRow = table.insertRow(table.rows.length);
    newRow.insertCell(0).innerHTML = name;
    newRow.insertCell(1).innerHTML = "Color:"+color+",size:"+size.toString();
    newRow.insertCell(2).innerHTML = '<button
onclick="deleteLayer(this)">Delete</button>';
   }
}
_______________________________________________
mapguide-users mailing list
mapguide-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapguide-users

Reply via email to