Code Monkey home page Code Monkey logo

Comments (7)

branflake2267 avatar branflake2267 commented on July 17, 2024

Is this in debugging? And if so which browser?

from gwt-maps-v3-api.

waliddah avatar waliddah commented on July 17, 2024

Yeah, in the debuggin and in the normal run, in hosted mode and even in the server mode (deployed on tomcatServer | WebSphereServer), and in all browser (at least IE8 and fireFox 10.0.2)

from gwt-maps-v3-api.

branflake2267 avatar branflake2267 commented on July 17, 2024

Can you check your error console and see if _gwt_ObjectId error or something like that is showing up?

from gwt-maps-v3-api.

waliddah avatar waliddah commented on July 17, 2024

In the browser console? No, there is non error !

And yeah, i forget to tell you that resizing the browser window resolve the problem !!!

from gwt-maps-v3-api.

branflake2267 avatar branflake2267 commented on July 17, 2024

Could I see how your adding them to your composite so I could reproduce it when I get a chance.

from gwt-maps-v3-api.

waliddah avatar waliddah commented on July 17, 2024

Of course !

public abstract class GWTMapV3 extends Composite {

protected VerticalPanel verticalPanel;

public interface GeoCallBack {
    void callFailed();

    void callSucced(Adresse adresse);

    void serviceIndisponible();

    /**
     * 
     */
    void startCalling();

    /**
     * 
     */
    void adresseNotFound();

    /**
     * @param adresses
     */
    void multipleAdressesFounds(List<String> adresses);
}

/**
 * 
 */
public GWTMapV3() {
    super();
}

}

AND

public class GWTMapWidgetV3 extends GWTMapV3 {

private MapWidget mapWidget;

public GWTMapWidgetV3(GeoCallBack geoCallBack) {
    verticalPanel = new VerticalPanel();
    initWidget(verticalPanel);
    initMap(geoCallBack);
}

/**
 * 
 */
private void initMap(final GeoCallBack geoCallBack) {
    LatLng pointGPS = LatLng.newInstance(48.833, 2.333);
    MapOptions opts = MapOptions.newInstance();
    opts.setZoom(8);
    opts.setCenter(pointGPS);
    opts.setMapTypeId(MapTypeId.ROADMAP);
    mapWidget = new MapWidget(opts);
    verticalPanel.add(mapWidget);
    mapWidget.setSize("487px", "372px");
    mapWidget.addClickHandler(new ClickMapHandler() {
        public void onEvent(ClickMapEvent event) {
            geoCallBack.startCalling();
            decodeLongtiudeLatitudeToAdresse(geoCallBack, event.getMouseEvent().getLatLng().getLongitude(), event.getMouseEvent().getLatLng().getLatitude());

        }

    });

}

/**
 * @param adresse
 * @param geoCallBack
 */
public void drawFromAdresse(String adresse, final GeoCallBack geoCallBack) {
    GeocoderRequest request = GeocoderRequest.newInstance();
    request.setAddress(adresse);
    geoCallBack.startCalling();
    Geocoder.newInstance().geocode(request, new GeocoderRequestHandler() {

        @Override
        public void onCallback(JsArray<GeocoderResult> results, GeocoderStatus status) {
            if (GeocoderStatus.UNKNOWN_ERROR.equals(status) || GeocoderStatus.ERROR.equals(status)) {
                geoCallBack.serviceIndisponible();
            } else if (GeocoderStatus.ZERO_RESULTS.equals(status)) {
                geoCallBack.adresseNotFound();
            } else if (results.length() > 1) {
                List<String> adresses = new ArrayList<String>();
                for (int i = 0; i < results.length(); i++) {
                    adresses.add(results.get(i).getFormatted_Address());
                }
                geoCallBack.multipleAdressesFounds(adresses);
            } else {
                traiterLeResutlat(geoCallBack, results);

            }

        }

        /**
         * @param geoCallBack
         * @param results
         */
        private void traiterLeResutlat(final GeoCallBack geoCallBack, JsArray<GeocoderResult> results) {
            Adresse adresse = null;
            try {
                GeocoderResult geocoderRequest = results.get(0);
                refreshMapWithTheGivenPosition(geocoderRequest.getGeometry().getLocation());
                adresse = getAdresse(geocoderRequest, geocoderRequest.getGeometry().getLocation());
            } catch (Throwable throwable) {
                geoCallBack.callFailed();
            }
            geoCallBack.callSucced(adresse);
        }

    });

}

/**
 * @param latLng
 */
private void refreshMapWithTheGivenPosition(LatLng latLng) {
    mapWidget.setCenter(latLng);
}

/**
 * @param d
 * @param e
 * @param mapClickHandler
 */
public void draw(double longitude, double latitude, final GeoCallBack geoCallBack) {
    decodeLongtiudeLatitudeToAdresse(geoCallBack, longitude, latitude);

}

/**
 * @param geoCallBack
 * @param event
 */
private void decodeLongtiudeLatitudeToAdresse(final GeoCallBack geoCallBack, double longitude, double latitude) {
    GeocoderRequest request = GeocoderRequest.newInstance();
    LatLng latLng = LatLng.newInstance(latitude, longitude);
    request.setLocation(latLng);
    geoCallBack.startCalling();
    Geocoder.newInstance().geocode(request, new GeocoderRequestHandler() {

        @Override
        public void onCallback(JsArray<GeocoderResult> results, GeocoderStatus status) {

            GeocoderResult geocoderRequest = results.get(0);
            refreshMapWithTheGivenPosition(geocoderRequest.getGeometry().getLocation());

            Adresse adresse = getAdresse(geocoderRequest, geocoderRequest.getGeometry().getLocation());

            geoCallBack.callSucced(adresse);
        }

    });
}

/**
 * @param geocoderRequest
 * @param latLng
 * @return
 */
private Adresse getAdresse(GeocoderResult geocoderRequest, LatLng latLng) {
    Adresse adresse = AdresseDecoder.getAdresse(geocoderRequest.getAddress_Components());
    adresse.setLatidue(latLng.getLatitude() + "");
    adresse.setLongitude(latLng.getLongitude() + "");

    return adresse;
}

}

public class GeolocalisationMap extends Composite {

private FlowPanel flowPanel = new FlowPanel();
private GWTMapWidgetV3 mapWidget;
private Label errerLabel = new Label();

public GeolocalisationMap(GeoCallBack geoCallBack) {
    mapWidget = new GWTMapWidgetV3(geoCallBack);
    flowPanel.add(errerLabel);
    flowPanel.add(mapWidget);
    flowPanel.setStyleName("maps");
    initWidget(flowPanel);
}

public void showParisLocation(GeoCallBack geoCallBack) {
    mapWidget.draw(2.333, 48.833, geoCallBack);
}

public void showError(String message) {
    errerLabel.setText(message);
    errerLabel.setVisible(true);

}

public void clearError() {
    errerLabel.setText("");
    errerLabel.setVisible(false);

}

/*
 * (non-Javadoc)
 * 
 * @see com.google.gwt.user.client.ui.Composite#onAttach()
 */
@Override
protected void onAttach() {
    super.onAttach();

}

/**
 * @param text
 */
public void sarchAdresse(String adresse, final GeoCallBack geoCallBack) {
    mapWidget.drawFromAdresse(adresse, geoCallBack);
}

/**
 * @param adrLatitude
 * @param adrLongitude
 * @param geoCallBack
 */
public void showAdresseInMap(String adrLatitude, String adrLongitude, GeoCallBack geoCallBack) {
    mapWidget.draw(Double.valueOf(adrLongitude), Double.valueOf(adrLatitude), geoCallBack);
}

}

mmmmm, i can't reproduce it with simple class in an onModuleLoad method. I will try to make a simple test class in wich the problem is clearly viewed ! i will make it in this evening after work :)

from gwt-maps-v3-api.

waliddah avatar waliddah commented on July 17, 2024

hi,
i tried to reproduce it with simple classes but i can't, its work juste fine in thoses cases. If i found how to reproduice it i will share with you the example, i use a tabPanel with lazy loading, perhapse the problem is in the way that we use to call the map in it !

Any way, if somone else has the same problem, here it is the solution;

Thanks

from gwt-maps-v3-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.