2017-08-19 4 views
0

#markersにはjson出力があります。このダイナミックデータセットはチェックボックスをクリックすると表示され、markerimg=datasetid%10の助けを借りてimgname iconUrlを作成しています。このimgの名前をデータベースに保存します。このiconUrl変数をphp変数に送信できません。カラムidのベースに作成されたdbにjs変数を保存します

function markerdata(Data) 
     { 
     # markers =Data;# 

      //alert(markers); 
      //console.log(markers); 
     var json = JSON.parse(markers); 

        var xyz=json["aa"]; 

     for (var i = 0; i < xyz.length; i++) { 


      var mainindex=xyz[i].length; 
      for (var j=0;j<mainindex;j++) 
      { 
      newlat=(xyz[i][j].latitude); 
      newlong=(xyz[i][j].longitude); 
       newlocation=(xyz[i][j].location); 

      id=(xyz[i][j].id); 
      datasetid=(xyz[i][j].dataset_id); 
     ---------------------------------------- 
      markerimg=datasetid%10; 
     ---------------------------------------- 
       var location = new L.LatLng(newlat, newlong); 
      if (newlocation.length > 0) { 
       var address = "<div style='font-size: 14px;'>"+ newlocation +"</div>"; 
      } 
      else { 
       var address = ""; 
      } 
      var leafIcon = L.icon({ 
            iconUrl: "markerimg/marker"+ markerimg +".png", 
            ------------------------------------------------------ 

           }); 
      var marker = new L.Marker(location, { 
       title: address, 
       icon: leafIcon 
      }); 

      //console.log(xyz[i][j].location); 
      //document.getElementById("address").value = address; 
       var form = '<form id="inputform" enctype="multipart/form-data" class="well">'+ 
      '<label><strong>location:</strong></label>'+ 
       '<input type="text" class="span3" id="address" name="address" value="'+xyz[i][j].location+'"/>'+ 
       '<input style="display: none;" type="text" id="datasetid" name="datasetid" value="'+datasetid +'" />'+ 
       '<input style="display: none;" type="text" id="id" name=id" value="'+id +'" />'+ 
       '<input style="display: none;" type="text" id="latitude" name="latitude" value="'+newlat +'" />'+ 
       '<input style="display: none;" type="text" id="longitude" name="longitude" value="'+newlong +'" /><br>'+ 
       '<div class="row-fluid">'+ 
        '<div class="span6" style="text-align:center;"><button type="button" class="btn btn-primary" onclick="insertUser()">Submit</button></div>'+ 
       '</div>'+ 
       '</form>'; 

     marker.bindPopup(form).openPopup(); 
      map.addLayer(marker); 

    } 
    } 
} 

答えて

0

グローバル変数が

var finalicon ="markerimg/marker"+ markerimg +".png"; 

var leafIcon = L.icon({ 
    iconUrl: finalicon, 

})以下のようなコードの変更を行うにしてください。

のUSE finaliconのvaribleと、それは確かに

に動作しますよ、PHPに渡し
関連する問題