问题
I am trying to add a custom fusion table styling to my Google Map. Similar to here: https://developers.google.com/maps/documentation/javascript/examples/layer-fusiontables-styling
I want to color a country based on a particular value assigned to it let's say 0 = green, 50 = yellow and 100=red.
I have a Fusion table set up here: https://www.google.com/fusiontables/DataSource?docid=1tJkzVXTv-B2-rFeQVO9bX_vICCvJ9Xq1LU6xog5f
and I am able to achieve desired result here but not in my code.
I am using Google Maps API V3 with GWT.
private void setupFusionTablesLayer(final MapWidget mapWidget) {
final String select = "geometry";
final String from = "1tJkzVXTv-B2-rFeQVO9bX_vICCvJ9Xq1LU6xog5f";
final String where = "risk >= 0";
final FusionTablesStyle fusionTablesStyle = FusionTablesStyle
.newInstance();
final FusionTablesPolygonOptions polygonOptions = FusionTablesPolygonOptions
.newInstance();
polygonOptions.setFillColor("#505050"); // grey
polygonOptions.setFillOpacity(0.3);
fusionTablesStyle.setPolygonOptions(polygonOptions);
final FusionTablesQuery query = FusionTablesQuery.newInstance();
query.setSelect(select);
query.setFrom(from);
query.setWhere(where);
final FusionTablesLayerOptions options = FusionTablesLayerOptions
.newInstance();
options.setQuery(query);
final JsArray arr = JavaScriptObject.createArray().cast();
arr.push(fusionTablesStyle);
options.setStyles(arr);
final FusionTablesLayer layer = FusionTablesLayer.newInstance(options);
layer.addClickHandler(new FusionTablesMouseMapHandler() {
@Override
public void onEvent(final FusionTablesMouseMapEvent event) {
event.getInfoWindowHtml();
final LatLng latlng = event.getLatLng();
event.getPixelOffset();
event.getRow();
final String json = event.getRowAsJson();
GWT.log("click on " + latlng.getToString() + " json=" + json);
}
});
layer.setMap(mapWidget);
}
This is what I have so far:
I have no clue why it is all red!!
Please help.
Thanks
EDIT#1 I did the code change and was able to change the whole map color to grey. But still not sure how to get risk column's value and update per country color.
来源:https://stackoverflow.com/questions/29577659/custom-coloring-of-countries-in-google-maps-gwt