已知点的经纬度,如何将它画在地图上(Mapxtreme for java)
地图服务器是mapxtreme for jave 4.8。已知一点的经纬度(24.3,103.2),如何将其画在地图上?请高手解答!急啊 --------------------编程问答-------------------- try {// ASSUMPTIONS:
// The variable mapj is of type MapJ and has loaded a map
// The variable req is of type HttpServletRequest
// The variable res is of type HttpServletResponse
// The variable dp is of type DoublePoint
// Add annotation layer - this layer will consist of one image symbol to "animate"
//注解表格提供帮助类
AnnotationTableDescHelper atdh = new AnnotationTableDescHelper("Animation_Layer");
//注解数据服务帮助类
AnnotationDataProviderHelper adph = new AnnotationDataProviderHelper();
//本地数据服务引用
LocalDataProviderRef ldpr = new LocalDataProviderRef(adph);
//创建注解图层
Layer animate_layer = mapj.getLayers().insert(ldpr, atdh,0, "Animation_Layer");
//定义注点
Rendition r = RenditionImpl.getDefaultRendition();
r.setvalue(Rendition.SYMBOL_MODE,Rendition.SymbolMode.IMAGE);
r.setvalue(Rendition.SYMBOL_URL, "file:///C:/images/car.gif");
//创建这个点-----
//先创建特征工厂
FeatureFactory ff = mapj.getFeatureFactory();
//包含单个属性的数组
Attribute[] aAIntAttribute = {new Attribute(33)};
//创建Integer
PrimaryKey pkey = new PrimaryKey(aAIntAttribute);
Feature f = ff.createPoint(dp, r, aAIntAttribute, pkey);
PrimaryKey pk = animate_layer.addFeature(f);
// Create the ImageRequestComposer
ImageRequestComposer imageRC =ImageRequestComposer.create(mapj, 256, Color.blue,"image/gif");
/*
Create the composite renderer
Render the image
Stream the image back to the client
*/
CompositeRenderer compositeRenderer = new CompositeRenderer(" http://localhost:8080/mapxtreme40/servlet/mapxtreme";, 0);
compositeRenderer.render(imageRC);
ServletOutputStream sos = res.getOutputStream();
compositeRenderer.toStream(sos);
//Set this attribute to false so that the bottom image is not rendered next time
compositeRenderer.setRedrawBottom(false);
} catch(Exception e) {
//Take appropriate error handling steps
}相关部分有示例代码。 --------------------编程问答-------------------- 没有看见创建点的语名啊!比如问题中提到的经纬度(24.3,103.2),具体是在哪儿创建的呢? --------------------编程问答-------------------- 没有看见创建点的语名啊!比如问题中提到的经纬度(24.3,103.2),具体是在哪儿创建的呢? --------------------编程问答-------------------- 创建点的语句应该是Feature f = ff.createPoint(dp, r, aAIntAttribute, pkey); 这个吧?
我也是试图在地图的一点显示图像,但按楼主的办法显示不了,不知道是怎么回事
请指教哦 --------------------编程问答-------------------- 我也是,发生异常
java.lang.RuntimeException: Error rendering: Message=java.lang.IllegalArgumentException: URI is not absolute
补充:企业软件 , 地理信息系统