Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我怎么才能在地图上看到城市中间没有滑动的数字呢?_Javascript_Jquery_Html_Css_Svg - Fatal编程技术网

Javascript 我怎么才能在地图上看到城市中间没有滑动的数字呢?

Javascript 我怎么才能在地图上看到城市中间没有滑动的数字呢?,javascript,jquery,html,css,svg,Javascript,Jquery,Html,Css,Svg,我有一张地图,我想在每个国家显示一个数字。。我在页面上给出x,y的位置。但是把我的代码移到另一页x,y位置在下滑。每个城市上面应该只有一个盒子 $(function () { $("#map svg path").each(function () { var id=$(this).attr("id"); $("#sehir").text(id); $(this).html(id); if ($("#" + id).length > 0) {

我有一张地图,我想在每个国家显示一个数字。。我在页面上给出x,y的位置。但是把我的代码移到另一页x,y位置在下滑。每个城市上面应该只有一个盒子

$(function () {
  $("#map svg path").each(function () {
    var id=$(this).attr("id");
    $("#sehir").text(id);
    $(this).html(id);

    if ($("#" + id).length > 0) {
      var k = $("#" + id).position();
      var x = "", y = "";
      x = k.left - 110, y = k.top + 20;

              $.ajax({

                      url: '<%=ResolveUrl("~/Default.aspx/GetDeger") %>',
                      data: '{prefix: ' + JSON.stringify(id) + '}',
                      dataType: "json",
                      type: "POST",
                      context: this,
                      contentType: "application/json; charset=utf-8",                     
                      success: function (data) {

                          $("#map").append("<a href='https://www.elemanhavuzu.com/'><div class='kutu' style='left:" + x + "px;top:" + y + "px;' data-toggle='tooltip' title="+id+"><b> " + data.d + "</b></div></a> ");


                          if (data.d != null)
                          {
                                var i = +(data.d);

                                if (i == 0) {
                                    $(this).attr("style", "fill:#C12E3F");
                                }
                                else if (i > 0 && i <= 10) {
                                    $(this).attr("style", "fill:#FFD28B");
                                }

                                else if (i > 10 && i <= 20) {
                                    $(this).attr("style", "fill:#4dbc83");
                                }
                                else if (i > 20) {                          
                                    $(this).attr("style", "fill:#40A556");
                                }
                          }
                      },
                      error: function (response) {
                          alert(response.responseText);
                      },
                      failure: function (response) {
                          alert(response.responseText);
                      }
                  });
    }
  });
})
$(函数(){
$(“#映射svg路径”)。每个(函数(){
var id=$(this.attr(“id”);
$(“#sehir”).text(id);
$(this.html(id);
如果($(“#”+id).length>0){
var k=$(“#”+id).position();
var x=“”,y=“”;
x=k.左-110,y=k.顶+20;
$.ajax({
url:“”,
数据:'{prefix:'+JSON.stringify(id)+'}',
数据类型:“json”,
类型:“POST”,
背景:这,,
contentType:“应用程序/json;字符集=utf-8”,
成功:功能(数据){
$(“#地图”)。附加(“”);
if(data.d!=null)
{
变量i=+(data.d);
如果(i==0){
$(this.attr(“样式”,“填充:#C12E3F”);
}
如果(i>0&&i10&&i20){
$(此).attr(“样式”,“填充:#40A556”);
}
}
},
错误:函数(响应){
警报(response.responseText);
},
故障:功能(响应){
警报(response.responseText);
}
});
}
});
})
看起来像现在


这个问题不是很清楚……至少对我自己来说不是。你必须更清楚地解释你的疑问。请提供尽可能多的信息。让我再解释一下。我想在地图上以圆形显示每个城市的招聘职位数量。我根据城市的id标记这些圆圈。当我在代码中设置x和y坐标时,它们会到达我想要的位置。但有些正在下滑。将x,y直接赋给该位置会更正框的位置,但我不想每次都进行编辑。我不能直接把这些数字放在中间吗?我编辑了我的共享。你可以添加一个链接到一个工作示例吗?这个问题不是很清楚…至少我自己不清楚。你必须更清楚地解释你的疑问。请提供尽可能多的信息。让我再解释一下。我想在地图上以圆形显示每个城市的招聘职位数量。我根据城市的id标记这些圆圈。当我在代码中设置x和y坐标时,它们会到达我想要的位置。但有些正在下滑。将x,y直接赋给该位置会更正框的位置,但我不想每次都进行编辑。我不能直接将这些数字放在中间吗?我编辑了我的共享。您可以添加一个指向工作示例的链接吗?