Hi Miguel, I would like for you to review the attached patch. It converts the Route object to a JavaScript overlay.
D maps/maps/src/com/google/gwt/maps/client/impl/RouteImpl.java M maps/maps/src/com/google/gwt/maps/client/geocode/Route.java -- Eric Z. Ayers - GWT Team - Atlanta, GA USA http://code.google.com/webtoolkit/ --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
D maps/maps/src/com/google/gwt/maps/client/impl/RouteImpl.java M maps/maps/src/com/google/gwt/maps/client/geocode/Route.java Index: maps/maps/src/com/google/gwt/maps/client/impl/RouteImpl.java =================================================================== --- maps/maps/src/com/google/gwt/maps/client/impl/RouteImpl.java (revision 766) +++ maps/maps/src/com/google/gwt/maps/client/impl/RouteImpl.java (working copy) @@ -1,50 +0,0 @@ -/* - * Copyright 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.google.gwt.maps.client.impl; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.maps.client.geocode.Distance; -import com.google.gwt.maps.client.geocode.Duration; -import com.google.gwt.maps.client.geocode.Placemark; -import com.google.gwt.maps.client.geocode.Step; -import com.google.gwt.maps.client.geom.LatLng; -import com.google.gwt.maps.jsio.client.JSFlyweightWrapper; - -/** - * Wraps the GRoute object from the Maps API using JSIO. - */ -public interface RouteImpl extends JSFlyweightWrapper { - - RouteImpl impl = GWT.create(RouteImpl.class); - - Distance getDistance(JavaScriptObject jsoPeer); - - Duration getDuration(JavaScriptObject jsoPeer); - - Placemark getEndGeocode(JavaScriptObject jsoPeer); - - LatLng getEndLatLng(JavaScriptObject jsoPeer); - - int getNumSteps(JavaScriptObject jsoPeer); - - Placemark getStartGeocode(JavaScriptObject jsoPeer); - - Step getStep(JavaScriptObject jsoPeer, int index); - - String getSummaryHtml(JavaScriptObject jsoPeer); - -} Index: maps/maps/src/com/google/gwt/maps/client/geocode/Route.java =================================================================== --- maps/maps/src/com/google/gwt/maps/client/geocode/Route.java (revision 766) +++ maps/maps/src/com/google/gwt/maps/client/geocode/Route.java (working copy) @@ -17,7 +17,6 @@ import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.maps.client.geom.LatLng; -import com.google.gwt.maps.client.impl.RouteImpl; /** * Created by the [EMAIL PROTECTED] Directions} class to store information about a single @@ -26,40 +25,29 @@ */ // TODO(zundel): Should we provide a List to access the steps in the route? This // would be consistent with our implementation in [EMAIL PROTECTED] DirectionsResult}. -public final class Route { +public class Route extends JavaScriptObject { - static Route createPeer(JavaScriptObject jsoPeer) { - return new Route(jsoPeer); + protected Route() { + // Required for JavaScript overlays } - private final JavaScriptObject jsoPeer; - /** - * Construct a Route by wrapping an existing GRoute JavaScript object. - * - * @param jsoPeer the JavaScriptObject to wrap. - */ - private Route(JavaScriptObject jsoPeer) { - this.jsoPeer = jsoPeer; - } - - /** * Returns the total distance of this route. * * @return the total distance of this route. */ - public Distance getDistance() { - return RouteImpl.impl.getDistance(jsoPeer); - } + public final native Distance getDistance() /*-{ + return this.getDistance(); + }-*/; /** * Returns the total estimated time of this route. * * @return the total estimated time of this route. */ - public Duration getDuration() { - return RouteImpl.impl.getDuration(jsoPeer); - } + public final native Duration getDuration() /*-{ + return this.getDuration(); + }-*/; /** * Returns the ending point of this route. @@ -68,9 +56,9 @@ * * @see Route#getEndLatLng() */ - public Placemark getEndGeocode() { - return RouteImpl.impl.getEndGeocode(jsoPeer); - } + public final native Placemark getEndGeocode() /*-{ + return this.getEndGeocode(); + }-*/; /** * Returns a [EMAIL PROTECTED] LatLng} object for the last point along the polyline for @@ -82,18 +70,19 @@ * * @return the last point along the polyline for this route. */ - public LatLng getEndLatLng() { - return RouteImpl.impl.getEndLatLng(jsoPeer); - } + public final native LatLng getEndLatLng() /*-{ + // TODO(zundel): This method will not work until LatLng is converted to a JSO + return this.getEndLatLng(); + }-*/; /** * Returns the number of steps in this route. * * @return the number of steps in this route. */ - public int getNumSteps() { - return RouteImpl.impl.getNumSteps(jsoPeer); - } + public final native int getNumSteps() /*-{ + return this.getNumSteps(); + }-*/; /** * Returns the starting point of this route. @@ -102,9 +91,9 @@ * * @see Route#getEndLatLng() */ - public Placemark getStartGeocode() { - return RouteImpl.impl.getStartGeocode(jsoPeer); - } + public final native Placemark getStartGeocode() /*-{ + return this.getStartGeocode(); + }-*/; /** * Returns the Step object for the ith step in this route. @@ -113,9 +102,9 @@ * @param index The index of the step to return in the route * @return the Step object for the ith step in this route */ - public Step getStep(int index) { - return RouteImpl.impl.getStep(jsoPeer, index); - } + public final native Step getStep(int index) /*-{ + return this.getStep(index); + }-*/; /** * Returns an HTML snippet containing a summary of the distance and time for @@ -124,7 +113,7 @@ * @return an HTML snippet containing a summary of the distance and time for * this route. */ - public String getSummaryHtml() { - return RouteImpl.impl.getSummaryHtml(jsoPeer); - } + public final native String getSummaryHtml() /*-{ + return this.getSummaryHtml(); + }-*/; }
