开发者

Is there any way to reuse / make serializable LatLng and LatLngBounds types in GWT? Any alternatives?

开发者 https://www.devze.com 2023-04-09 21:51 出处:网络
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

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 the开发者_StackOverflow社区re any libraries which already provide serializable classes and conversion to/from LatLng & company? Or everybody just writes their own wrappers?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号