views:

778

answers:

4

any example on using google map v3 with gwt1.6.4 through jsni ?

+1  A: 
native void initializeMap() /*-{
    var latlng = new $wnd.google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      zoom: 8,
      center: latlng,
      mapTypeId: $wnd.google.maps.MapTypeId.ROADMAP
    };
    var map = new $wnd.google.maps.Map($doc.getElementById("map_canvas"), myOptions);
}-*/;
A: 

Hi,

can you provide more details please?

Ileo
A: 

How would you return a value back to the java code? e.g. I can get the duration of a trip with the below code, but how can I then get it back to my java code?

protected native String getDuration() /*-{
    var directionsService = new $wnd.google.maps.DirectionsService();
    var start = "penn station, new york, ny";
    var end = "grand central station, new york, ny";
    var request = {
    origin: start,
    destination: end,
    travelMode: $wnd.google.maps.DirectionsTravelMode.WALKING
    };

    var duration = "not set";
    directionsService.route(request, function(response, status) {
    if (status == $wnd.google.maps.DirectionsStatus.OK) {
    duration = response.routes[0].legs[0].duration.text;
    }
    });
}-*/;
Stephen