我正在我的网站上创建OSM地图并添加一些带有openlayer的标记..我的问题是我总是得到相同的标记图标..
<script type="text/javascript">
var map = new OpenLayers.Map("heatMap");
var mapnik = new OpenLayers.Layer.OSM();
map.addLayer(mapnik);
map.setCenter(new OpenLayers.LonLat(-4.0575942987957,54.390175926091) // Center of the map
.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
new OpenLayers.Projection("EPSG:900913") // to Spherical Mercator Projection
), 6 // Zoom level
);
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
var icon1 = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png', size, offset);
var icon2 = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker-gold.png', size, offset);
var icon3 = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker-green.png', size, offset);
var lonLat1 = new OpenLayers.LonLat(-4.0575942987957,54.390175926091).transform(
new OpenLayers.Projection("EPSG:4326"), // transform …Run Code Online (Sandbox Code Playgroud)