openlayers google v3只显示一个marker故障

openlayers google v3只显示一个marker故障

找了半天也没找到,后来看了OpenStreetMap网站源码,才最终解决的,

看来用OpenLayers的不算太多哈。

markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon));

 markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(10,10),icon.clone()));

   

改为以下写法正确

    markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(110,10).transform(new OpenLayers.Projection(“EPSG:4326”), map.getProjectionObject()),icon.clone()));
    markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(120,20).transform(new OpenLayers.Projection(“EPSG:4326”), map.getProjectionObject()),icon.clone()));
    markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(130,30).transform(new OpenLayers.Projection(“EPSG:4326”), map.getProjectionObject()),icon.clone()));

转载自:https://blog.csdn.net/sq8706/article/details/7788111

You may also like...