Javascript 如何从geoserver获取坐标
我有这个剧本。 我想从lokasi_penting那里得到坐标, 让它成为地图的中心Javascript 如何从geoserver获取坐标,javascript,postgis,openlayers-3,geoserver,Javascript,Postgis,Openlayers 3,Geoserver,我有这个剧本。 我想从lokasi_penting那里得到坐标, 让它成为地图的中心 $(document).ready(function(){ $("#kirim2").click(function(){ var x = document.getElementById('lokasi_penting2').value; var y = document.getElementById('jarak2').value;
$(document).ready(function(){
$("#kirim2").click(function(){
var x = document.getElementById('lokasi_penting2').value;
var y = document.getElementById('jarak2').value;
bintang_1 = new ol.source.Vector({
loader: function(extent, resolution, projection) {
$.ajax('http://localhost:8383/geoserver/bagas/ows',{
type: 'GET',
data: {
service: 'WFS',
version: '1.0.0',
request: 'GetFeature',
typename: 'bagas:bintang_1',
srsname: 'EPSG:3857',
outputFormat: 'text/javascript',
viewparams : "lokasi_penting:" + x +";jarak:" + y,
bbox: extent.join(',') + ',EPSG:3857'
},
dataType: 'jsonp',
jsonpCallback:'callback:loadFeaturesbin_1',
jsonp:'format_options'
});
},
strategy: ol.loadingstrategy.tile(new ol.tilegrid.XYZ({
maxZoom: 19
})),
});
window.loadFeaturesbin_1 = function(response) {
geoJSON = new ol.format.GeoJSON();
bintang_1.addFeatures(geoJSON.readFeatures(response));
};
var bin_1 = new ol.layer.Vector({
source: bintang_1,
style: bintang_satu,
name : 'bin_1'
});
map.addLayer(bin_1);
lokasi_penting和jarak来自geoserver。因此,我想在加载后将lokasi penting的坐标作为地图的中心。问题是什么?您提供的只是一些代码,但没有问题陈述或与itI相关的问题。我想将lokasi penting的坐标作为地图的中心。因为,地图的中心仍然是默认的,它不能解释问题,也不能解释代码shownYes当前正在发生或没有发生的事情,问题还不是很清楚,但也许你只需要一个
map.setCenter(new OpenLayers.LonLat(x,y),10)代码>?是的,就是这样,但我需要lokasi_penting坐标的坐标。lokasi_penting来自geoserver。