我正在編程一個地圖頁面,我需要捕獲地圖上點擊/點擊的位置並存儲座標。我正在使用OpenLayers js。在桌面瀏覽器(IE/FF/Chrome)上,這工作正常。在移動設備上,水龍頭會在默認Android瀏覽器(無論是在真實設備還是仿真器上)正確捕獲。OpenLayers緯度在Webkit移動瀏覽器中不準確捕獲
但是,在移動webkit瀏覽器(iPhone Safari & Android Chrome Beta)中,我們遇到了水龍頭在實際水龍頭的更高几個像素(朝北)捕捉的問題。錯誤是不固定的(所以,我不能只加100到事件的XY重新校準頂部)。
這裏是我使用的函數clickhandler代碼:
OpenLayers.Control.ClickHandler = OpenLayers.Class(OpenLayers.Control, {
defaultHandlerOptions: {
'single': true,
'double': false,
'pixelTolerance': 0,
'stopSingle': false,
'stopDouble': false
},
initialize: function(options) {
this.handlerOptions = OpenLayers.Util.extend(
{}, this.defaultHandlerOptions
);
OpenLayers.Control.prototype.initialize.apply(
this, arguments
);
this.handler = new OpenLayers.Handler.Click(
this, {
'click': this.trigger
}, this.handlerOptions
);
},
trigger: function(e) {
that.inputLonLat_EPSG4326 = null;
var lonlat = that.inputMap.getLonLatFromViewPortPx(e.xy);
that.logMessage("XY " + e.xy);
that.logMessage("LonLoat " + lonlat);
that.inputMarkers.clearMarkers();
that.inputMarkers.addMarker(new OpenLayers.Marker(lonlat,that.icons["green"].clone()));
lonlat.transform(that.inputMap.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
that.inputLonLat_EPSG4326 = lonlat;
// For the moderation sections
$('#alertLatitude').val(that.inputLonLat_EPSG4326.lat);
$('#alertLongitude').val(that.inputLonLat_EPSG4326.lon);
//lonLat2.transform(that.inputMap.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
that.logMessage("Stored lat " + that.inputLonLat_EPSG4326.lat);
that.logMessage("Stored lon " + that.inputLonLat_EPSG4326.lon);
that.callFunction(that.inputMapListener, e);
}
});
我應該是做不同的事情?有人在使用OpenLayers時看到移動webkit瀏覽器的不準確問題嗎?