如何在javascript的情况下定义函数?

时间:2019-06-19 06:53:18

标签: javascript php

我有两个类似的功能,但是我需要根据情况打电话给我。不同地图URL的大小写a和不同地图URL的大小写b

第一个功能在下面

function drawMapFromWms(latt, longt, complaintid) {
  $.ajax({
    type: "GET",
    url: "tools/nrega_v2.1/map.php",
    data: 'complaintid=' + complaintid,
    success: function(data) {
      var data_array = JSON.parse(data);


      $('.modal-info').html("");

      var hrymap = '<div id="hrymap"></div>';
      $(".modal-info").append(hrymap);

      $('#hrymap').html("");

      $('#hrymap').html("<div id='map' style='width:850px;height:650px;'></div>");
      var map = L.map('map');

      setTimeout(function() {
        map.invalidateSize(true)
      }, 300);
      map.setView([29.0, 76.776695], 8);
      map.fitBounds([
        [latt, longt]

      ]);

      L.tileLayer.wms("https://example.com/bhuvan/gwc/service/wms/", {
        layers: 'india3',

        format: 'image/png',
        transparent: true,
        attribution: "Example"

      }).addTo(map);

      L.tileLayer.wms("https://example.com/bhuvan/gwc/service/wms/", {
        layers: 'hrcm_roads',

        format: 'image/png',
        transparent: true,
        attribution: "Indian Remote Sensing Satellites"
      }).addTo(map);

      var marker = L.marker([latt, longt]).addTo(map).bindPopup('Complaint ID:' + data_array.complaint_id + '</br>Road ID:' + data_array.road_id + '</br>Complainant Name:' + data_array.name + '</br>Complaint Type:' + data_array.feedback_type)
        .openPopup();
      map.invalidateSize();

      $("#detail_content").css({
        'display': 'block'
      });
    }
  });

}

第二个功能

function drawMapFromWms(latt, longt, complaintid) {

  var map;

  require([
    "esri/map",
    "esri/geometry/Point",
    "esri/symbols/SimpleMarkerSymbol",
    "esri/graphic",
    "esri/layers/GraphicsLayer", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/layers/ArcGISTiledMapServiceLayer",
    "dojo/domReady!"
  ], function(
    Map, Point, SimpleMarkerSymbol, Graphic, GraphicsLayer, ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer
  ) {
    map = new Map("map", {
      basemap: "streets",
      center: [76.0856, 29.0588],
      zoom: 10
    });
    map.on("load", function() {
      var gl = new GraphicsLayer();
      var p = new Point(76.0856, 29.0588);
      var s = new SimpleMarkerSymbol().setSize(60);
      var g = new Graphic(p, s);
      gl.add(g);
      map.addLayer(gl);
      map.addLayer(new ArcGISDynamicMapServiceLayer('https:example.com?Token=HmogUWq8X66dAOhfBvc3c_6hWKsfJo_d9W-pgPAkGlI11KHSkX364i5BJzvMvafyWW9X1Lnc_qfdZVn5P2ZkFw..'));
    });
  });
}

正在通过按钮onclick="drawMapFromWms(<?php echo $latt ?>,<?php echo $longt; ?>,<?php echo $complaintid; ?>)"调用功能

如何通过此通话使用case? 是否可以在JavaScript和 单击按钮时是否可以通话?

0 个答案:

没有答案