I am using OpenStreeMap with Google as layer, and for geocoding , nominatim service. Below, is my code.
$.ajax({
url: "http://nominatim.openstreetmap.org/search?q=" + address + &format=json&polygon=0&addressdetails=1",
type: 'POST',
//data: { 'htmlViewType': htmlViewType },
complete: function () { },
success: function (result) {
var obj = JSON.parse(result);
if (obj.length > 0) {
document.getElementById('LblError').innerHTML = obj[0].display_name;
var markerslonLat = new OpenLayers.LonLat(obj[0].lon, obj[0].lat).transform(WGS84, map.getProjectionObject(), 0);
map.setCenter(markerslonLat, 10);
//var icon = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png', size, offset);
var icon = new OpenLayers.Icon(' http://maps.google.com/mapfiles/ms/micons/blue.png', size, offset);
markers.addMarker(new OpenLayers.Marker(markerslonLat, icon));
map.addLayer(markers);
}
else {
document.getElementById('LblError').innerHTML = 'no such address.';
}
},
error: function (error) {
document.getElementById('LblError').innerHTML = error;
}
});
Now, when i pass address = "Bharuch" in above URL , it returns 2 result in array, and when address = "Surat", it returns 5.
so, my question is : which result value should i take from that array result as original Result ?
Right , now i am taking result from 0 index, but in few case it don't show my actual address. Thanks.