package com.example.monica.environment;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupMenu;
import android.widget.TextView;
import com.amap.api.maps2d.AMap;
import com.amap.api.maps2d.CameraUpdateFactory;
import com.amap.api.maps2d.MapView;
import com.amap.api.maps2d.model.BitmapDescriptorFactory;
import com.amap.api.maps2d.model.LatLng;
import com.amap.api.maps2d.model.Marker;
import com.amap.api.maps2d.model.MarkerOptions;
import com.amap.api.maps2d.model.MyLocationStyle;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
private TextView my_username,my_userAccount,so2,no2,o3,co,pm10,pm25;
private Button my_login;
private LinearLayout main,main2,main3,home,home2,local,local2,my,my2,my_main_info,main3_userInfo;
private MapView mapView;
private ImageView my_main_advice,my_main_head,my_main_set;
private SharedPreferences sharedPreferences;
private AMap aMap = null;
private List<LatLng> LatLngList = new ArrayList<LatLng>();
private int[][] MonitorData = new int [][]{
//温度、湿度、PM2.5、PM10、SO2、NO2、O3、CO
{1,1,1,1,1,1,1,1},{2,2,2,2,2,2,2,2},{3,3,3,3,3,3,3,3},{4,4,4,4,4,4,4,4},{5,5,5,5,5,5,5,5},
{6,6,6,6,6,6,6,6},{7,7,7,7,7,7,7,7},{8,8,8,8,8,8,8,8},{9,9,9,9,9,9,9,9},{10,10,10,10,10,10,10,10},
{11,11,11,11,11,11,11,11},{12,12,12,12,12,12,12,12},{13,13,13,13,13,13,13,13},{14,14,14,14,14,14,14,14},
{15,15,15,15,15,15,15,15},{16,16,16,16,16,16,16,16}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//加载界面组件
initView();
mapView.onCreate(savedInstanceState);// 此方法必须重写
//加载地图
initMap();
initListener();
}
//加载界面组件
public void initView(){
my_login = (Button)findViewById(R.id.my_login) ;
main = (LinearLayout)findViewById(R.id.main);
main2 = (LinearLayout)findViewById(R.id.main2);
main3 = (LinearLayout)findViewById(R.id.main3);
my_userAccount = (TextView)findViewById(R.id.my_userAccount);
my_main_advice = (ImageView)findViewById(R.id.my_main_advice);
my_main_set = (ImageView)findViewById(R.id.my_main_set);
//首页数据
so2 = (TextView)findViewById(R.id.so2);
no2 = (TextView)findViewById(R.id.no2);
o3 = (TextView)findViewById(R.id.o3);
co = (TextView)findViewById(R.id.co);
pm10 = (TextView)findViewById(R.id.pm10);
pm25 = (TextView)findViewById(R.id.pm25);
//获取底部菜单
home = (LinearLayout)findViewById(R.id.navigation_home);
home2 = (LinearLayout)findViewById(R.id.navigation_home2);
local = (LinearLayout)findViewById(R.id.navigation_localtion);
local2 = (LinearLayout)findViewById(R.id.navigation_localtion2);
my = (LinearLayout)findViewById(R.id.navigation_my);
my2 = (LinearLayout)findViewById(R.id.navigation_my2);
my_main_info = (LinearLayout) findViewById(R.id.my_main_info);
my_main_info = (LinearLayout)findViewById(R.id.my_main_info);
my_main_head = (ImageView)findViewById(R.id.my_main_head);
my_username = (TextView)findViewById(R.id.my_username);
main3_userInfo = (LinearLayout)findViewById(R.id.main3_userInfo);
//获取地图
mapView = (MapView)findViewById(R.id.mapView);
}
//加载监听器
public void initListener(){
home.setOnClickListener(this);
home2.setOnClickListener(this);
local.setOnClickListener(this);
local2.setOnClickListener(this);
my.setOnClickListener(this);
my2.setOnClickListener(this);
my_login.setOnClickListener(this);
my_main_advice.setOnClickListener(this);
my_main_info.setOnClickListener(this);
my_main_set.setOnClickListener(this);
}
//地图操作
public void initMap(){
if(aMap == null) {
aMap = mapView.getMap();
}
//显示定位蓝点
MyLocationStyle myLocationStyle;
//初始化定位蓝点样式类
myLocationStyle = new MyLocationStyle();
//连续定位、且将视角移动到地图中心点,定位点依照设备方向旋转,并且会跟随设备移动。(1秒1次定位)如果不设置myLocationType,默认也会执行此种模式。
myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER);
//设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒
myLocationStyle.interval(2000);
//设置地图的放缩级别
aMap.moveCamera(CameraUpdateFactory.zoomTo(15));
//设置定位蓝点的style
aMap.setMyLocationStyle(myLocationStyle);
//设置默认定位按钮是否显示,非必需设置。
aMap.getUiSettings().setMyLocationButtonEnabled(true);
// 设置为true表示启动显示定位蓝点,false表示隐藏定位蓝点并不进行定位,默认是false。
aMap.setMyLocationEnabled(true);
//设置是否显示定位小蓝点,用于满足只想使用定位,不想使用定位小蓝点的场景,设置false以后图面上不再有定位蓝点的概念,但是会持续回调位置信息
//MyLocationStyle showMyLocation(boolean visible);
//设置定位蓝点的icon图标方法,需要用到BitmapDescriptor类对象作为参数。
//MyLocationStyle myLocationIcon(BitmapDescriptor myLocationIcon);
LatLngList.add(new LatLng(34.797016,113.667602));
LatLngList.add(new LatLng(34.797016,113.667602));
LatLngList.add(new LatLng(34.796543,113.656784));
LatLngList.add(new LatLng(34.791751,113.649604));
LatLngList.add(new LatLng(34.788085,113.656227));
LatLngList.add(new LatLng(34.78625,113.666938));
LatLngList.add(new LatLng(34.785335,113.652290));
LatLngList.add(new LatLng(34.78289,113.66085));
LatLngList.add(new LatLng(34.791095,113.64512));
LatLngList.add(new LatLng(34.785503,113.671745));
LatLngList.add(new LatLng(34.77819,113.663681));
LatLngList.add(new LatLng(34.771778,113.653663));
LatLngList.add(new LatLng(34.775489,113.655242));
LatLngList.add(new LatLng(34.7720144,113.664649));
LatLngList.add(new LatLng(34.775138,113.672317));
LatLngList.add(new LatLng(34.781883,113.665481));
//添加设备
for(int i = 0;i<MonitorData.length;i++){
MarkerOptions options = new MarkerOptions();
options.title("设备"+i).position(LatLngList.get(i))
.snippet("温度:"+MonitorData[i][0]+"℃\n湿度:"+MonitorData[i][1]+"%\nPM2.5:"+MonitorData[i][2]+"\nPM10:"+MonitorData[i][3]+
"\nSO2:"+MonitorData[i][4]+"\nO3:"+MonitorData[i][5]+"\nNO2:"+MonitorData[i][6]+"\nCO:"+MonitorData[i][7]).icon(BitmapDescriptorFactory.fromResource(R.drawable.local));
Marker marker1 = aMap.addMarker(options);
}
}
private android.app.AlertDialog.Builder setPositiveButton(android.a
没有合适的资源?快使用搜索试试~ 我知道了~
main.rar_main环境_wifi app_污染_监测 APP_设备监测
共110个文件
xml:46个
png:31个
java:16个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 100 浏览量
2022-07-14
18:37:30
上传
评论
收藏 6.58MB RAR 举报
温馨提示
环境监测APP的角色主要有一种: 角色权限如下: 普通用户:定位及查看、登陆与注册、查看天气、环境污染物的浓度和风力风向以及舒适度、设置绑定设备、提建议、查看新消息提醒、是否开启消息通知和WIFI下自动更新等功能。
资源推荐
资源详情
资源评论
收起资源包目录
main.rar_main环境_wifi app_污染_监测 APP_设备监测 (110个子文件)
main.iml 336B
MainActivity.java 13KB
RegisterPage.java 10KB
CircleBar.java 8KB
LoginPage.java 8KB
MyInfo.java 4KB
GuidePage.java 4KB
WelcomePage.java 3KB
ChangeHead.java 3KB
SetDevice.java 3KB
DataBast.java 2KB
SuggestionPage.java 2KB
ChangeName.java 2KB
ChangePassword.java 2KB
GuideAdapter.java 1KB
RoundProgressBar.java 687B
JellyInterpolator.java 465B
head7.jpeg 125KB
head6.jpeg 91KB
head8.jpeg 54KB
weather_background.jpg 149KB
head9.jpg 80KB
guide_1.jpg 63KB
head10.jpg 52KB
head5.jpg 34KB
guide_2.jpg 32KB
welcome_4.jpg 30KB
welcome_3.jpg 19KB
guide_4.jpg 18KB
guide_3.jpg 17KB
head2.jpg 8KB
head3.jpg 7KB
head4.jpg 5KB
wether.png 5.65MB
welcome_1.png 50KB
welcome_2.png 27KB
ic_launcher_round.png 15KB
ic_launcher_round.png 10KB
ic_launcher.png 9KB
ic_launcher_round.png 7KB
ic_launcher.png 6KB
ic_launcher_round.png 5KB
ic_launcher.png 4KB
localtion_2.png 3KB
localtion.png 3KB
ic_launcher.png 3KB
ic_launcher_round.png 3KB
my_2.png 3KB
my.png 3KB
start.png 3KB
home_2.png 2KB
home.png 2KB
username.png 2KB
empty_holo.png 2KB
local.png 2KB
password.png 2KB
ic_launcher.png 2KB
full_holo.png 2KB
head.png 1KB
main_title_menu.png 961B
next.png 773B
sun.png 480B
back.png 248B
phone.png 246B
workspace.xml 18KB
activity_main3.xml 10KB
activity_main.xml 7KB
activity_my_info.xml 7KB
weather_2.xml 6KB
ic_launcher_background.xml 6KB
device_info.xml 5KB
register_input_layout.xml 5KB
suggestion.xml 4KB
weather_3.xml 3KB
AndroidManifest.xml 3KB
activity_change_password.xml 3KB
activity_change_name.xml 3KB
login_input_layout.xml 3KB
activity_change_head.xml 2KB
activity_login_page.xml 2KB
main_weather_list.xml 2KB
activity_regist_page.xml 2KB
activity_set_device.xml 2KB
weather_1.xml 2KB
weather_5.xml 2KB
weather_4.xml 2KB
ic_launcher_foreground.xml 2KB
strings.xml 2KB
activity_guid_page.xml 2KB
Project.xml 2KB
title_register_layout.xml 1KB
title_login_layout.xml 1KB
misc.xml 1KB
activity_main2.xml 1KB
activity_main1.xml 1KB
styles.xml 889B
layout_progress.xml 810B
atts.xml 761B
activity_welcome_page.xml 435B
head_cell.xml 415B
共 110 条
- 1
- 2
资源评论
四散
- 粉丝: 54
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功