| public class MapReverseGeocodingMIDP extends MapDemoMIDP implements CommandListener, IReverseGeocodingListener { private Command mapFindAddressCommand = new Command("Find Address", Command.OK, 1); public void startApp() { init(); canvas.addCommand(mapFindAddressCommand); map.setReverseGeocodingListener(this); canvas.setCommandListener(this); GeoLatLng center = new GeoLatLng(-31.948275, 115.857562); map.setCenter(center, 13, MapType.GOOGLEMAP); Display.getDisplay(this).setCurrent(canvas); } public void commandAction(Command c, Displayable d) { if (c == mapFindAddressCommand) { map.getReverseLocations("-31.948275,115.857562"); } } public void done(String arg0, MapPoint[] result) { if (result != null) { map.panTo(result[0].getPoint()); } } } |
Remember the string format, latitude comes first, and don’t put space in between. The result is also returned as an array. Normaly only the first result is most appropriate, the rest is for bigger area, i.e the city, the state and then the country the address is in.
No comments:
Post a Comment