Ejemplo n.º 1
0
  protected void handleAddRoute(HashMap routeMap) {
    Object routeArray = routeMap.get("points");
    if (routeArray instanceof Object[]) {
      Object[] routes = (Object[]) routeArray;
      MapPoint[] pointsType = new MapPoint[routes.length];
      for (int i = 0; i < routes.length; i++) {

        if (routes[i] instanceof HashMap) {
          HashMap tempRoute = (HashMap) routes[i];
          MapPoint mp =
              new MapPoint(
                  TiConvert.toDouble(tempRoute, "latitude"),
                  TiConvert.toDouble(tempRoute, "longitude"));
          pointsType[i] = mp;
        }
      }

      MapRoute mr =
          new MapRoute(
              pointsType,
              TiConvert.toColor(routeMap, "color"),
              TiConvert.toInt(routeMap, "width"),
              TiConvert.toString(routeMap, "name"));

      if (mapView == null) {
        this.routes.add(mr);
      } else {
        mapView.addRoute(mr);
      }
    }
  }