开发者

Google GWT MapWidget addOverlay Polygon shows border but not fill

开发者 https://www.devze.com 2023-03-31 05:34 出处:网络
LatLng[] polyLatLng = new LatLng[5]; polyLatLng[0] = LatLng.newInstance(90, 180); polyLatLng[1] = LatLng.newInstance(90, 180);
    LatLng[] polyLatLng = new LatLng[5];
    polyLatLng[0] = LatLng.newInstance(90, 180);
    polyLatLng[1] = LatLng.newInstance(90, 180);
    polyLatLng[2] = LatLng.newInstance(-90, 180);
    polyLatLng[3] = LatLng.newInstance(-90, -180);
    polyLatLng[4] = polyLatLng[0];

    Polygon disabledOverlay = new Polygon(polyLatLng, "#F33F00", 1, 1.0, "#F33F00", 0.5);
    mapWidget.addOverlay(disabledOverlay);

In the above code, I make a com.google.gwt.maps.client.overlay.Polygon and add it as an overlay to a com.google.gw开发者_开发技巧t.maps.client.MapWidget.

The polygon's border appears, but the fill doesn't appear. Am I doing something wrong?


The code is correct, but your coordinates are weird. Are you trying to encircle the entire earth? I didn't see anything when I used your coordinates, but when I used a smaller polygon the border and fill appeared fine.

My code:

private void buildUI() {
    LatLng[] poly = new LatLng[4];
    poly[0] = LatLng.newInstance(50, -60);
    poly[1] = LatLng.newInstance(20, -60);
    poly[2] = LatLng.newInstance(20, -80);
    poly[3] = LatLng.newInstance(50, -80);

    Polygon polygon = new Polygon(poly, "#000000", 1, 1.0, "#000000", 0.5);
    LatLng apl = LatLng.newInstance(39.1656,-76.8986);

    MapWidget map = new MapWidget(apl, 11);
    map.setSize("100%", "100%");
    map.addControl(new LargeMapControl());
    map.addOverlay(new Marker(apl));
    map.addOverlay(polygon);

    mapPanel.add(map);

}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号