megabot
09-18-2007, 05:12 PM
Hello,
I've been using a particular method (for educational purposes) the last year or so for rendering a map from a Route object.
Last time I checked this code was about three months or so a go, and it worked perfectly fine. I've been using this code within a Web Service that I coded myself. The idea is to get the info (route description, route distance, route image/map) from the Mappoint Web Service and send it to a J2ME application.
Just a couple of days a go I started the Web Service that I had coded myself (after a few months) and now the method that I use for rendering an map from a given Route object seems not to be working.
The code is below:
public Image getMap(Route rte)
{
this.connectMappoint(username, password, 2);
route = new Route();
route.setCalculatedRepresentation(rte.getCalculate dRepresentation());
Segment[] segments = rte.getItinerary().getSegments().getSegment();
Pushpin startpush = new Pushpin();
Waypoint startway = segments[0].getWaypoint();
startpush.setLatLong(startway.getLocation().getLat Long());
startpush.setLabel(startway.getName());
startpush.setIconName("Car");
startpush.setIconDataSource("MapPoint.Icons");
Pushpin endpush = new Pushpin();
Waypoint endway = segments[1].getWaypoint();
endpush.setLatLong(endway.getLocation().getLatLong ());
endpush.setLabel(endway.getName());
endpush.setIconName("33");
endpush.setIconDataSource("MapPoint.Icons");
pushpins = new ArrayOfPushpin();
pushpins.setPushpin(new Pushpin[] {startpush, endpush});
mapspec = new MapSpecification();
MapOptions mapop = new MapOptions();
mapop.setIsOverviewMap(Boolean.FALSE);
mapop.setStyle(MapStyle.DefaultStyle);
mapop.setFontSize(MapFontSize.Smaller);
mapop.setReturnType(MapReturnType.ReturnImage);
mapop.setRouteHighlightColor(RouteHighlightColor.D efaultColor);
mapop.setConstructionDelayHighlightColor(RouteHigh lightColor.DefaultColor);
mapop.setConstructionClosureHighlightColor(RouteHi ghlightColor.DefaultColor);
mapspec.setOptions(mapop);
mapspec.setDataSourceName(startway.getLocation().g etDataSourceName());
mview = rte.getItinerary().getView().getByHeightWidth();
try
{
ImageFormat format = new ImageFormat();
format.setWidth(new Integer(400));
format.setHeight(new Integer(400));
format.setMimeType("image/png");
mapspec.getOptions().setFormat(format);
ArrayOfMapView mapviews = new ArrayOfMapView();
mapviews.setMapView(new MapView[] {mview});
mapspec.setViews(mapviews);
mapspec.setRoute(route);
mapspec.setPushpins(pushpins);
ArrayOfMapImage mapimage = renss.getMap(mapspec);
MapImage mimage = mapimage.getMapImage(0);
mviewreps = mimage.getView();
mview = mviewreps.getByHeightWidth();
image = getToolkit().createImage(mimage.getMimeData().getB its());
return image;
}
catch(Exception e)
{
System.out.println("Hier gebeurt de kanker exception " + e);
return null;
}
}
Up until now everything was working fine, but with the same code that worked three
months a go on the same application I now keep getting an Image object which is 'null'.
Anyone here who might be able to help? I am really stuck on this one at the moment.
Did the Mappoint RenderService change in the meanwhile by any chance?
Help is much appreciated, thanks in advance.
I've been using a particular method (for educational purposes) the last year or so for rendering a map from a Route object.
Last time I checked this code was about three months or so a go, and it worked perfectly fine. I've been using this code within a Web Service that I coded myself. The idea is to get the info (route description, route distance, route image/map) from the Mappoint Web Service and send it to a J2ME application.
Just a couple of days a go I started the Web Service that I had coded myself (after a few months) and now the method that I use for rendering an map from a given Route object seems not to be working.
The code is below:
public Image getMap(Route rte)
{
this.connectMappoint(username, password, 2);
route = new Route();
route.setCalculatedRepresentation(rte.getCalculate dRepresentation());
Segment[] segments = rte.getItinerary().getSegments().getSegment();
Pushpin startpush = new Pushpin();
Waypoint startway = segments[0].getWaypoint();
startpush.setLatLong(startway.getLocation().getLat Long());
startpush.setLabel(startway.getName());
startpush.setIconName("Car");
startpush.setIconDataSource("MapPoint.Icons");
Pushpin endpush = new Pushpin();
Waypoint endway = segments[1].getWaypoint();
endpush.setLatLong(endway.getLocation().getLatLong ());
endpush.setLabel(endway.getName());
endpush.setIconName("33");
endpush.setIconDataSource("MapPoint.Icons");
pushpins = new ArrayOfPushpin();
pushpins.setPushpin(new Pushpin[] {startpush, endpush});
mapspec = new MapSpecification();
MapOptions mapop = new MapOptions();
mapop.setIsOverviewMap(Boolean.FALSE);
mapop.setStyle(MapStyle.DefaultStyle);
mapop.setFontSize(MapFontSize.Smaller);
mapop.setReturnType(MapReturnType.ReturnImage);
mapop.setRouteHighlightColor(RouteHighlightColor.D efaultColor);
mapop.setConstructionDelayHighlightColor(RouteHigh lightColor.DefaultColor);
mapop.setConstructionClosureHighlightColor(RouteHi ghlightColor.DefaultColor);
mapspec.setOptions(mapop);
mapspec.setDataSourceName(startway.getLocation().g etDataSourceName());
mview = rte.getItinerary().getView().getByHeightWidth();
try
{
ImageFormat format = new ImageFormat();
format.setWidth(new Integer(400));
format.setHeight(new Integer(400));
format.setMimeType("image/png");
mapspec.getOptions().setFormat(format);
ArrayOfMapView mapviews = new ArrayOfMapView();
mapviews.setMapView(new MapView[] {mview});
mapspec.setViews(mapviews);
mapspec.setRoute(route);
mapspec.setPushpins(pushpins);
ArrayOfMapImage mapimage = renss.getMap(mapspec);
MapImage mimage = mapimage.getMapImage(0);
mviewreps = mimage.getView();
mview = mviewreps.getByHeightWidth();
image = getToolkit().createImage(mimage.getMimeData().getB its());
return image;
}
catch(Exception e)
{
System.out.println("Hier gebeurt de kanker exception " + e);
return null;
}
}
Up until now everything was working fine, but with the same code that worked three
months a go on the same application I now keep getting an Image object which is 'null'.
Anyone here who might be able to help? I am really stuck on this one at the moment.
Did the Mappoint RenderService change in the meanwhile by any chance?
Help is much appreciated, thanks in advance.