I have the same issue, Im stucked for 3 days, should I downgrade google
maps version?
On Friday, November 16, 2012 11:53:16 AM UTC, Giorgos Kritsotakis wrote:
>
> I have been able to draw the label, still I can't get the positioning
> right. This is the code in case someone wants to do something similar:
>
>
> public class MapLabel {
> private Element div;
> private LatLng latLng;
> private SimplePanel textPanel;
> private String text;
> private OverlayView overlay = OverlayView.create();
>
> public MapLabel(LatLng latLng, String text, GoogleMap map) {
>
> this.latLng = latLng;
> this.text = text;
>
> HTML textWidget = new HTML(text);
>
> textPanel = new SimplePanel();
> textPanel.setStyleName("textOverlayPanel");
> textPanel.add(textWidget);
>
> initOverlay(overlay);
>
> overlay.setMap(map);
> }
>
> private final native void initOverlay(JavaScriptObject jso) /*-{
> var instance = this;
>
> jso.draw = function() {
> $entry([email protected]::myDraw()());
> };
>
> jso.onAdd = function() {
> $entry([email protected]::myOnAdd()());
> };
>
> jso.onRemove = function() {
>
> $entry([email protected]::myOnRemove()());
> };
> }-*/;
>
> public void myDraw() {
> Point ne =
> overlay.getProjection().fromLatLngToDivPixel(overlay.getMap().getBounds().getNorthEast());
> Point sw =
> overlay.getProjection().fromLatLngToDivPixel(overlay.getMap().getBounds().getSouthWest());
>
> Point p = overlay.getProjection().fromLatLngToDivPixel(latLng);
>
> div.getParentElement().getStyle().setTop(p.getY(), Unit.PX);
> div.getParentElement().getStyle().setLeft(p.getX(), Unit.PX);
>
> div.getStyle().setWidth(100, Unit.PX);
> div.getStyle().setHeight(25, Unit.PX);
> }
>
> public void myOnAdd() {
> div = DOM.createDiv();
> div.appendChild(textPanel.getElement());
> overlay.getPanes().getFloatPane().appendChild(div);
> }
>
> public void myOnRemove() {
> div.removeFromParent();
> textPanel.removeFromParent();
>
> div = null;
> textPanel = null;
> }
> }
>
>
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.