duanbi3151 2012-04-09 07:06
浏览 190
已采纳

如何在openstreetmap中从地图外部打开标记?

i am using openstreetmap in my project, earlier i used google map in this project but the request limit is lower than what my client needs and he can't afford what google takes to increase the request limit so i had to switch to openstreetmap, i am searching a lot in openstreetmap documentation but not getting the clue that how to open a marker from a link which is outside the map, can you please help me in solving this. This will be a huge help for me.

Thanks in advance

Hey, I solved it myself, this is the code to open popup of marker from outside the map.

       function openMarker(id,lon,lat,html) 
       {
        jQuery(".olPopup").remove();
        marklonLat = new OpenLayers.LonLat(lon,lat)
          .transform(
            new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
            map.getProjectionObject() // to Spherical Mercator Projection
        );

        var size = new OpenLayers.Size(200,200);
        popup = new OpenLayers.Popup(id,marklonLat,size,html,true,'' , {keepInMap: true });

        map.addPopup(popup);
    }

jQuery(".olPopup").remove(); -- This will close all the popup's on the map before you open a new popup

html -- this is the content which will be there in the popup

  • 写回答

1条回答 默认 最新

  • dtxooq1020 2012-04-22 08:19
    关注

    Just try this :

    Pass unique id of the marker, longitude, latitude and html which you want to show in tooltip.

    function openMarker(id,lon,lat,html) 
        {
            jQuery(".olPopup").remove();
            marklonLat = new OpenLayers.LonLat(lon,lat)
              .transform(
                new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
                map.getProjectionObject() // to Spherical Mercator Projection
            );
    
        var size = new OpenLayers.Size(200,200);
        popup = new OpenLayers.Popup(id,marklonLat,size,strhtml,true,'' , {keepInMap: true });
    
        map.addPopup(popup);
    }
    

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建