有没有办法在GWT中重用/生成可序列化的LatLng和LatLngBounds类型?(Is there any way to reuse / make serializable LatLng and

编程入门 行业动态 更新时间:2024-10-23 16:29:33
没有办法在GWT中重用/生成可序列化的LatLng和LatLngBounds类型?(Is there any way to reuse / make serializable LatLng and LatLngBounds types in GWT? Any alternatives?)

我非常兴奋地使用GWT Maps API来编写一个服务,该服务在其界面中使用LatLng和LatLngBounds ......只是为了在运行时发现那些类没有实现Serializable,可能是因为它们是Javascript本机对象。

那么使用GWT在服务器端使用位置数据类型的最佳方法是什么? 是否有任何库已经提供可序列化的类和转换到/来自LatLng&company? 或者每个人都写自己的包装?

I was so excited to use GWT Maps API that wrote a service which takes LatLng and LatLngBounds in its interface... Only to find out at runtime that those classes do not implement Serializable, probably because they are Javascript native objects.

What would be the best approach to work with location data types on the server side with GWT then? Are there any libraries which already provide serializable classes and conversion to/from LatLng & company? Or everybody just writes their own wrappers?

最满意答案

看看我写的这些代码是否有助于你:

https://github.com/dartmanx/mapmaker/blob/master/src/main/java/org/jason/mapmaker/client/util/GoogleMapUtil.java

GWT提供了为不实现Serializable(或IsSerializable)的类创建自定义字段序列化器的功能。 但是,JavaScriptObject确实很奇怪,并且不允许您直接访问Java端的任何数据成员。 因此,编写序列化器将充其量只是一个挑战。

您可能还希望查看google的文档,了解可以返回哪些值:

http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html#passing-javascript

See if any of this code I wrote helps you out:

https://github.com/dartmanx/mapmaker/blob/master/src/main/java/org/jason/mapmaker/client/util/GoogleMapUtil.java

GWT provides the ability to create Custom Field Serializers for classes that don't implement Serializable (or IsSerializable). However, JavaScriptObject is an odd duck indeed and doesn't let you directly access any of its data members on the Java side. So, writing a serializer is going to be a challenge at best.

You may also wish to have a look at google's docs about what sorts of values can be returned:

http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html#passing-javascript

更多推荐

本文发布于:2023-07-16 15:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1130518.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:没有办法   类型   序列化   LatLng   LatLngBounds

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!