有没有办法在 GWT 中重用/制作可序列化的 LatLng 和 LatLngBounds 类型?还有其他选择吗?
我很高兴使用 GWT Maps API,它编写了一个在其接口中采用 LatLng 和 LatLngBounds 的服务...只是在运行时发现这些类没有实现 Serialized,可能是因为它们是 Javascript 本机对象。
那么,在服务器端使用 GWT 处理位置数据类型的最佳方法是什么?是否有任何库已经提供可序列化的类以及与 LatLng 和 LatLng 之间的转换?公司?或者每个人都写自己的包装器?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看我编写的任何代码是否可以帮助您:
https://github.com/dartmanx/mapmaker/blob/master/src/main/java/org/jason/mapmaker/client/util/GoogleMapUtil.java
GWT 提供了为未实现 Serialized(或 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