1. 程式人生 > >openlayers google v3只顯示一個marker故障

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()));