的OpenLayers。标记信息太大了

时间:2015-12-19 11:22:42

标签: openlayers

我有这段代码在地图中显示标记,我使用openlayers(一个开源javascript库来加载,显示和渲染网页上多个来源的地图),但弹出窗口太大

 <div class="windowContentMap">
                    <div>
                       <div id="Map"></div>
                         <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
                        <script>
                            var lat            = '50.8340150';
                            var lon            = '4.3778850';
                            var zoom           = 18;

                            var fromProjection = new OpenLayers.Projection("EPSG:4326");   // Transform from WGS 1984
                            var toProjection   = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
                            var position       = new OpenLayers.LonLat(lon, lat).transform( fromProjection, toProjection);

                            map = new OpenLayers.Map("Map");
                            var mapnik         = new OpenLayers.Layer.OSM();
                            map.addLayer(mapnik);

                            var markers = new OpenLayers.Layer.Markers( "Markers" );
                            map.addLayer(markers);
                            markers.addMarker(new OpenLayers.Marker(position));
                            map.setCenter(position, zoom);
                            // The location of our marker and popup. We usually think in geographic
                            // coordinates ('EPSG:4326'), but the map is projected ('EPSG:3857').
                            var myLocation = new OpenLayers.Geometry.Point(lon, lat).transform('EPSG:4326', 'EPSG:3857');

                            // A popup with some information about our location
                            var popup = new OpenLayers.Popup.FramedCloud("Popup",
                            myLocation.getBounds().getCenterLonLat(), null,
                            //'<a target="_blank" href="http://openlayers.org/">We</a> ' +
                            'E506  (TD1204 EVB)', null,
                            true // <-- true if we want a close (X) button, false otherwise
                        );
                        map.addPopup(popup);
                        </script>

                    </div>
                </div>

enter image description here

0 个答案:

没有答案