Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Map Kit provides the temperature map layer. The layer obtains weather data from the Global Forecast System (GFS) of National Oceanic and Atmospheric Administration (NOAA), and utilizes normalization algorithms of the linear function to convert the weather data to values within the range of (0, 254). The value (255, 255) indicates no data. Then, temperature data of different regions is converted into different color bands and displayed on the temperature map layer. The temperature map layer uses different colors to clearly show temperature values and temperature changes of different regions.
In addition, the temperature map layer is updated according to data released by the GFS of NOAA in real time, and can display the distribution of current temperatures and forecasted temperatures in the next 36 hours.
To add a temperature map layer, perform the following steps:
The ID of the temperature map layer is in the w_tmp_YYMMDDHH format, where YYMMDDHH indicates the year, month, day, and hour in UTC.
private CustomLayer layer;
CustomLayerOption option = new CustomLayerOption();
String[] ids = {"w_tmp_22030918"};
option.setLayerIds(ids);
option.setCoverType(CustomLayerOption.CoverType.ON_OVERLAY);
// Compile the temperature map layer into three tiers, and reuse tier 3 for other tiers.
Integer[] reuse = {0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3};
option.setTierReuses(reuse);
RasterStyleOption rasterStyleOption = new RasterStyleOption();
rasterStyleOption.setChannel(1);
rasterStyleOption.setOpacity(0.5f);
String[] colors = {"0,#8800FF", "42,#0000FF", "85,#007FFF", "127,#00FF00", "170,#FFFF00", "190,#FFA500", "210,#FF0000"};
rasterStyleOption.setColorRamp(colors);
rasterStyleOption.setzIndex(1);
option.setRasterStyle(rasterStyleOption);
CustomLayerCallBack callBack = new CustomLayerCallBack() {
@Override
public void onSuccess(CustomLayer customLayer) {
layer = customLayer;
}
@Override
public void onFailure(String s) {
}
};
hMapEx.addPublicLayer(1, option, callBack);var layer: CustomLayer? = null
val option = CustomLayerOption()
val ids = arrayOf("w_tmp_22030918")
option.setLayerIds(ids)
option.setCoverType(CustomLayerOption.CoverType.ON_OVERLAY)
// Compile the temperature map layer into three tiers, and reuse tier 3 for other tiers.
val reuse = arrayOf(0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3)
option.setTierReuses(reuse)
val rasterStyleOption = RasterStyleOption()
rasterStyleOption.setChannel(1)
rasterStyleOption.setOpacity(0.5f)
val colors = arrayOf(
"0,#8800FF",
"42,#0000FF",
"85,#007FFF",
"127,#00FF00",
"170,#FFFF00",
"190,#FFA500",
"210,#FF0000"
)
rasterStyleOption.setColorRamp(colors)
rasterStyleOption.setzIndex(1)
option.setRasterStyle(rasterStyleOption)
val callBack: CustomLayerCallBack = object : CustomLayerCallBack{
override fun onSuccess(customLayer: CustomLayer?) {
layer = customLayer
}
override fun onFailure(s: String?) {}
}
hMapEx?.addPublicLayer(1, option, callBack)The figure below shows the map effect.
