[OpenLayers-Users] geocoding problem
vrbikdan
vrbikdan at gmail.com
Sat Mar 24 06:19:07 EDT 2012
Hi all,
I'm trying to add geogoding to my map. I found example here:
http://openlayers.org/dev/examples/openls.html
http://openlayers.org/dev/examples/openls.html but when I try to add code
to my map is result: Cannot read property 'documentElement' of null and this
is result even if I copy whole code from example. But in example page
everythink works, so where should be a problem. My code is here:
function vypisAdresu() {
var queryString = document.vyhledaniAdresy.adresa.value;
OpenLayers.Request.POST({
url:
"http://www.openrouteservice.org/php/OpenLSLUS_Geocode.php",
scope: this,
failure: this.requestFailure,
success: this.requestSuccess,
headers: {"Content-Type":
"application/x-www-form-urlencoded"},
data: "FreeFormAdress=" + encodeURIComponent(queryString) +
"&MaxResponse=1"
});
}
function requestSuccess(response) {
var format = new OpenLayers.Format.XLS();
var output = format.read(response.responseXML);
if (output.responseLists[0]) {
var geometry = output.responseLists[0].features[0].geometry;
var foundPosition = new OpenLayers.LonLat(geometry.x,
geometry.y).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
);
map.setCenter(foundPosition, 16);
} else {
alert("Sorry, no address found");
}
}
function requestFailure(response) {
alert("An error occurred while communicating with the OpenLS
service. Please try again.");
}
And I have configured proxy.cgi in the same folder and in code like this:
OpenLayers.ProxyHost = "proxy.cgi?url=";
I used to nominatim for geocoding, but problem was, that it works only in
Chrome and FF, and IE and Opera has problem with request so I found this
example.
Thanks for help
Dan
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/geocoding-problem-tp4651323p4651323.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list