OpenLayers开发中,坐标系’EPSG:4326’转’EPSG:900913′

  var mapOptions = {
        resolutions: [156543.03390625, 78271.516953125, 39135.7584765625, 19567.87923828125, 9783.939619140625, 4891.9698095703125, 2445.9849047851562, 1222.9924523925781, 611.4962261962891, 305.74811309814453,
152.87405654907226, 76.43702827453613, 38.218514137268066, 19.109257068634033, 9.554628534317017, 4.777314267158508, 2.388657133579254, 1.194328566789627, 0.5971642833948135],
        // resolutions: [0.703125, 0.3515625, 0.17578125, 0.087890625, 0.0439453125, 0.02197265625, 0.010986328125, 0.0054931640625, 0.00274658203125,
//            0.001373291015625, 6.866455078125E-4, 3.4332275390625E-4, 1.71661376953125E-4, 8.58306884765625E-5, 4.291534423828125E-5,
//            2.1457672119140625E-5, 1.0728836059570312E-5, 5.364418029785156E-6, 2.682209014892578E-6],
        projection: new OpenLayers.Projection(‘EPSG:900913’),
        displayProjection: new OpenLayers.Projection(‘EPSG:4326’),
        maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
        allOverlays: true,
        //  units: “meters”,
        controls: []
    };
function drawFature(vwkt,vl){
   var feature = new OpenLayers.Format.WKT().read(vwkt);
   var gml = new OpenLayers.Format.GML();
   var style = {
           strokeColor: “blue”,
           strokeWidth: 1,
           pointerEvents: “visiblePainted”,
           fillColor: “red”,
           fillOpacity: 0.5
       };
   feature.style=style;
   var geo = feature.geometry;
      var bo = geo.getBounds();
      var latlon=bo.getCenterLonLat();
      var p=latlon.transform(map.displayProjection,map.getProjectionObject());
      var lat = p.lat;
      var lon = p.lon;
             console.info(lat+”–“+lon);
      vectorLayer.addFeatures([feature]);
      locatebylonlat(lon,lat,vl);
     map.moveTo([lon, lat],10,  new Object());
   
 }

转载自:https://blog.csdn.net/u013925989/article/details/46878771

You may also like...

退出移动版