Saya menggunakan Javascript, jQuery, Java, GeoServer, OpenLayers dan PostGIS.
Menggunakan kelas java ResultSet
saya mengembalikan String ini:
POLYGON((516000 2135000,515039.264020162 2125245.48389919,512193.976625564 2115865.82838175,507573.480615127 2107221.48834902,501355.339059327 2099644.66094067,493778.51165098 2093426.51938487,485134.171618255 2088806.02337444,475754.516100806 2085960.73597984,466000 2085000,456245.483899194 2085960.73597984,446865.828381746 2088806.02337444,438221.48834902 2093426.51938487,430644.660940673 2099644.66094067,424426.519384873 2107221.48834902,419806.023374436 2115865.82838175,416960.735979839 2125245.48389919,416000 2135000,416960.735979838 2144754.51610081,419806.023374436 2154134.17161825,424426.519384873 2162778.51165098,430644.660940673 2170355.33905933,438221.48834902 2176573.48061513,446865.828381745 2181193.97662556,456245.483899193 2184039.26402016,466000 2185000,475754.516100806 2184039.26402016,485134.171618254 2181193.97662556,493778.51165098 2176573.48061513,501355.339059327 2170355.33905933,507573.480615127 2162778.51165098,512193.976625564 2154134.17161825,515039.264020161 2144754.51610081,516000 2135000))
Cukup lama bukan? Jadi menggunakan fungsi ajax JQuery saya menangkap String ini dan sekarang saya ingin mengubahnya menjadi OpenLayers.Geometry.Polygon
, ini adalah baris di mana saya menggunakan fungsi ajax:
$.ajax({
url:"Catcher",
data:query,
type:"POST",
dataType:"text",
success:function(data){
var fea=new OpenLayers.Feature.Vector(data); //this doesn't work
vectorLayer.addFeatures([fea]); // here I add the feature to the vector layer I created as a global variable
map.zoomToExtent(bounds);
}
});
Bagaimana saya bisa melakukan konversi?
apakah console.log (data.d) memberi Anda string poligon WKT? (POLYGON ((
—
516000
menggunakan kueri WFS mungkin akan bekerja lebih baik
—
Ian Turton