GWT google maps V3 API を使用しており、マップ上にカスタム シェイプを表示する必要があります。単純な要素には、Polygon、Circle、および InfoWidnow クラスを使用しましたが、ボタンやカスタム パネルなどの他のウィジェットを表示したいと考えています。OverlayView クラスを使用してそれを行う方法はありますか? 私は簡単な解決策を試しました.MapWidgetとカスタムウィジェットを含むAbsolutePanelを上に配置しましたが、gwt google mapsクラスをできるだけ使用したいと思います。私はドキュメントを読み、答えを探しましたが、それを理解できなかったので、コード例は素晴らしいでしょう. ありがとう!
2161 次
2 に答える
0
Just make use of standard GWT API alongside with your maps V3 API. They will interconnect well enough.
于 2012-04-10T10:22:21.453 に答える
0
ここで必要なものを見つけました (javascript v3 api): https://developers.google.com/maps/documentation/javascript/overlays#CustomOverlays
メソッド名とクラスは非常に似ているため、GWT クラスの使用方法 (OverlayView など) を理解するのはそれほど難しくありません。
これは、マップ上にレンダリングされたカスタム ウィジェット (SVG 要素とアニメーションを含む) の例です。
private class TargettingOverlay extends OverlayView {
protected Element div ;
protected PanelWrapper panelWrapper;
private TargettingEffect targetEffect;
TargettingOverlay(){
targetEffect = new TargettingEffect();
targetEffect.setLinedDimension(10500);
targetEffect.setLinesOffset(-5000);
}
void positionTarget(LatLng loc, boolean withoutLines){
if (targetEffect == null )
return;
if (loc == null) {
targetEffect.setElementsVisible(false);
return;
}
targetEffect.setElementsVisible(true);
Point p = null;
Point sw = null;
Point ne = null;
LatLng locSW = (LatLng)this.getMap().getBounds().getSouthWest();
LatLng locNE = (LatLng)this.getMap().getBounds().getNorthEast();
//
p = (Point)getProjection().fromLatLngToDivPixel(loc);
sw = (Point)getProjection().fromLatLngToDivPixel(locSW);
ne = (Point)getProjection().fromLatLngToDivPixel(locNE);
targetEffect.setWithoutLinles(withoutLines);
targetEffect.target((int)ne.getY(), (int)p.getY(), (int)sw.getX(), (int)p.getX());
}
@Override
public void draw() {
Point ne = (Point)getProjection().fromLatLngToDivPixel((LatLng)
this.getMap().getBounds().getNorthEast());
Point sw = (Point)getProjection().fromLatLngToDivPixel((LatLng)
this.getMap().getBounds().getSouthWest());
div.getStyle().setTop(ne.getY(), Unit.PX);
div.getStyle().setLeft(sw.getX(), Unit.PX);
}
@Override
public void onAdd() {
div = DOM.createDiv();
getPanes().getOverlayLayer().appendChild(div);
panelWrapper = new PanelWrapper(div);
panelWrapper.attach();
targetEffect.setContainer(panelWrapper);
}
@Override
public void onRemove() {
div.removeFromParent();
panelWrapper.removeFromParent();
div = null;
panelWrapper = null;
}
}
于 2012-07-25T17:24:30.303 に答える