android - How to zoom to a specific country with OSMDroid? -
assume following situation:
user chooses country list. after clicking on country, map should zoom selected country.
how can achieve zoomtocountry in osmdroid if know country name list?
in php api "googlemaps v3" there solution like
function findaddress(address) { var geocoder = null; geocoder = new google.maps.geocoder(); if (!address) var address=document.getelementbyid("countryselect").value; if ((address != '') && geocoder) { geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.geocoderstatus.ok) { if (status != google.maps.geocoderstatus.zero_results) { if (results && results[0] && results[0].geometry && results[0].geometry.viewport) map.fitbounds(results[0].geometry.viewport); } else { alert("no results found"); } } else { alert("geocode not successful following reason: " + status); } }); } }
is there similar in osmdroid or osmbonuspack?
the php solution call geocoding service country name, country bounding box.
you can similar using nominatim service. osmbonuspack geocodernominatim should usable.
roughly (without error handling, asynctask , on):
geocodernominatim coder = new geocodernominatim(ctx); list<address> results = coder.getfromlocationname(countryname, 1); address address = results.get(0); bundle extras = address.getextras(); boundingboxe6 bb = extras.getparcelable("boundingbox");
then:
mapview.zoomtoboundingbox(bb);
as simple php/googlemaps solution, isn't it?
Comments
Post a Comment