Search in sources :

Example 1 with Device

use of itor.topnetwork.com.dxditor.bean.Device in project Dxditor by kimi2009.

the class MapPageActivity method initGPSData.

private void initGPSData() {
    try {
        InputStream is = MapPageActivity.this.getAssets().open("devicetestdata.txt");
        String jsonString = MyUtils.inputStream2String(is);
        JSONObject js = new JSONObject(jsonString);
        String re = js.getString("devices");
        Gson gson = new Gson();
        List<Device> devices = gson.fromJson(re, new TypeToken<List<Device>>() {
        }.getType());
        for (int i = 0; i < devices.size(); i++) {
            LatLng latlng = convert(MapPageActivity.this, devices.get(i).getLocationy() + "", devices.get(i).getLocationx() + "");
            addMarkersToMap(latlng, devices.get(i));
        }
        aMap.setOnMarkerClickListener(this);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : JSONObject(org.json.JSONObject) InputStream(java.io.InputStream) Device(itor.topnetwork.com.dxditor.bean.Device) TypeToken(com.google.gson.reflect.TypeToken) Gson(com.google.gson.Gson) LatLng(com.amap.api.maps.model.LatLng) Point(android.graphics.Point) IOException(java.io.IOException)

Aggregations

Point (android.graphics.Point)1 LatLng (com.amap.api.maps.model.LatLng)1 Gson (com.google.gson.Gson)1 TypeToken (com.google.gson.reflect.TypeToken)1 Device (itor.topnetwork.com.dxditor.bean.Device)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 JSONObject (org.json.JSONObject)1