export function createPopupContent (popupInfo, properties) {
  // console.log(popupInfo, properties);
  var r = /\{([^\]]*)\}/g;
  var titleText = '';
  var content = '';

  if (popupInfo.title !== undefined) {
    titleText = popupInfo.title;
  }

  titleText = titleText.replace(r, function (s) {
    var m = r.exec(s);
    return properties[m[1]];
  });

  content = '<div class="leaflet-popup-content-title"><h4>' + titleText + '</h4></div><div class="leaflet-popup-content-description" style="max-height:200px;overflow:auto;">';

  for (var i = 0; i < popupInfo.fieldInfos.length; i++) {
    if (popupInfo.fieldInfos[i].visible === true) {
      content += '<div style="font-weight:bold;color:#999;margin-top:5px;word-break:break-all;">' + popupInfo.fieldInfos[i].label + '</div><p style="margin-top:0;margin-bottom:5px;word-break:break-all;">' + properties[popupInfo.fieldInfos[i].fieldName] + '</p>';
    }
  }

  content += '</div>';

  if (popupInfo.mediaInfos.length > 0) {
    // It does not support mediaInfos for popup contents.
  }

  return content;
}

export var Popup = {
  createPopupContent: createPopupContent
};

export default Popup;

@@ -528,16 +528,62 @@
 o;%22%3E';%0A%0A
+  if (popupInfo.fieldInfos !== undefined) %7B%0A  
   for (v
@@ -636,16 +636,18 @@
 ) %7B%0A    
+  
 if (popu
@@ -682,24 +682,26 @@
 === true) %7B%0A
+  
       conten
@@ -959,27 +959,287 @@
     
-%7D%0A  %7D%0A%0A  content +=
+  %7D%0A    %7D%0A    content += '%3C/div%3E';%0A  %7D else if (popupInfo.description !== undefined) %7B%0A    // KMLLayer popup%0A    var descriptionText = popupInfo.description.replace(r, function (s) %7B%0A      var m = r.exec(s);%0A      return properties%5Bm%5B1%5D%5D;%0A    %7D);%0A    content += descriptionText +
  '%3C/
@@ -1243,21 +1243,26 @@
 '%3C/div%3E'
-;
+%0A  %7D
 %0A%0A  
+//
 if (popu
@@ -1352,16 +1352,18 @@
 ents.%0A  
+//
 %7D%0A%0A  ret

support kml popup