Guidebee Map API default uses Google Map Service, but there’s way you can choose which service you want to use. For example, if you applied CloudMade map key and you want to use CloudMade map service for your application. Or if you are in China , you want to use MapAbc map service instead of Google Map API.
Remember when use map in China , there’s an “offset” for most maps (google map china, Bing map China , MapAbc Map) used in China . You need offset rectify data to adjust the location received from GPS device and then shown on these maps. CloudMade Map China map doesn’t have such “offset”.
The following example show how you choose map services in your application. It uses three different map services to get direction between Nanjing to Tianjing in China .
| public class MapRoutingMIDP extends MapDemoMIDP implements CommandListener, IRoutingListener { private Command mapGetDirectionCommand = new Command("Get Direction", Command.OK, 1); public void startApp() { init(); map.setCurrentMapService(DigitalMapService. MAPABC_MAP_SERVICE); //map.setCurrentMapService(DigitalMapService.GOOGLE_MAP_SERVICE); //map.setCurrentMapService(DigitalMapService.CLOUDMADE_MAP_SERVICE); canvas.addCommand(mapGetDirectionCommand); map.setRoutingListener(this); canvas.setCommandListener(this); GeoLatLng center = new GeoLatLng(32.0616667, 118.7777778); map.setCenter(center, 15, MapType.MICROSOFTCHINA); Display.getDisplay(this).setCurrent(canvas); } public void commandAction(Command c, Displayable d) { if (c == mapGetDirectionCommand) { GeoLatLng latLng1=new GeoLatLng(32.0418381,118.7788905); GeoLatLng latLng2=new GeoLatLng(39.11643,117.180908); map.getDirections(new GeoLatLng[]{latLng1,latLng2}); } } public void done(String query, MapDirection result) { if (result != null) { map.setMapDirection(result); map.setZoom(13); map.panTo(new GeoLatLng(32.0418381,118.7788905)); } } } |
The above diagram display the route returned by Google Map Service, MapAbc Map Service and CloudMade MapService. You can notice there’s “offset” for CloudMade sevice returned route.
This is because the Bing China Map itself is a map with offset, the returned result by CloudMade Map service is the actual coordinates. The google map china map service also returned the latitude, longitude with offset, that’s why they are “matched” perfectly.
No comments:
Post a Comment