【问题标题】:raphael plot points in europe map欧洲地图上的拉斐尔情节点
【发布时间】:2012-10-19 17:47:14
【问题描述】:
  1. 嗨,

    我有一张欧洲拉斐尔地图。现在我想在 地图中的某些城市。我尝试通过转换纬度 n 经度 在其中绘制点。但不幸的是,它正在某个地方绘制 else.is it like we should have world map to plot points?这是我的 代码。

    script type="text/javascript" charset="utf-8">

           $(document).ready(function() {
            var rsr = Raphael('map', '631', '686');
            var attr = {
                       fill: "#C0C0C0",
                       stroke: "#666",
                       "stroke-width": 1,
                       "stroke-linejoin": "round"
                   };
               var world = {};
               world.Portugal = rsr.path("56,0.133-1.32,0.527c-0.661,1.321-0.264,2.906-  0.925,4.228c-0.528,1.057-3.698,5.415-3.434,6.868c0.132,0.526,1.056-0.529,1.584-0.529c0.792-0.132,1.585,0.133,2.377,0c0.396,0,0.792-0.396,1.188-0.264
    

    c2.113,0.527,8.981,5.019,9.906,4.887c0.396,0,4.49-1.981,4.754-2.113C57.876,621.536,58.537,621.536,59.197,621.536L3569.197,621. z").attr(attr); world.Spain = rsr.path(" M194.57,552.728c0.924,0.396,1.981,0.63.434,4.754c-,0,0.792,0 c0.661,0.133,1.453,0.133,1.849,0.528c0.66, 0.528,0.264,1.717,0.924,2.113v0.132C190.74,552.066,190.476,553.916,194.57,552.728 L194.57,552.728z").attr(attr);

       var current = null;
                for(var country in world) {
                 (function (st, country) {
                   country = country.toLowerCase();
                     st[0].style.cursor = "pointer";
                     st[0].onmouseover = function () { 
                         st.animate({fill:"#808080", stroke: "#ccc"}, 500);
                     };
                     st[0].onmouseout = function () {
                         st.animate({fill: "#C0C0C0", stroke: "#666"}, 500);
                         st.toFront();
                         R.safari();
                     };
                     st[0].onclick = function () {
                     st.toFront();
                           st.animate({
                             fill: '#808080',
                             transform: 's1.5 '
                         }, 1000);
                     };
                 })(world[country], country);
               }
             });   
      var cities = {};//here i define the cities with lat n long but both draws in thesame point all time
            cities.rome = plot(55.70466,13.19101,1);
          cities.copenhagen = plot(55.676097,12.568337,1);
            var city_attr = {
                    fill:"#FF7F50",
                     stroke:"#666",
                    opacity: .3
                };
            function plot(lat,lon,size) {
                size = size * .5 + 4;
                return   rsr.circle(lon2x(lon),lat2y(lat),size).attr(city_attr);
              }
    
            function lon2x(lon) {
                var xfactor = 1.5255;
                var xoffset = 263.58;
                var x = (lon * xfactor) + xoffset;
                return x;           }           function lat2y(lat) {
                 var yfactor = -1.5255;
                    var yoffset = 130.5;
                    var y = (lat * yfactor) + yoffset;
                    return y;           }
         }); 
          var myMarker = rsr.ellipse(513.859,35.333, 7, 7).attr({
              stroke: "none", 
              opacity: .7, 
              fill: "#f00"
            });
    

【问题讨论】:

  • 请注意格式,代码乱码。我也怀疑 [raphael] 标记是否相关,因为您所谈论的坐标映射无论如何都不是 Raphael.js 特有的。

标签: raphael


【解决方案1】:

地图编码的坐标似乎相当随意。如果是这样,就没有[简单]的方法来自动确定映射。我建议在其自己的坐标系中获取矢量图像的边界框,并在常规地图上的纬度/经度坐标中获取相应的边界框,并从中导出映射,至少作为第一近似值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-22
    • 2013-09-07
    • 2023-03-28
    • 1970-01-01
    相关资源
    最近更新 更多