public CameraPosition getCurrentCamera()
 {
   if (b.getMap() != null) {
     return b.getMap().a();
   }
   return null;
 }
 public double[] getViewableRegion()
 {
   if (b.getMap() != null)
   {
     Object localObject = b.getMap().d();
     LatLng localLatLng1 = ((g)localObject).a(new Point(0, 0));
     localObject = ((g)localObject).a(new Point(b.getWidth(), b.getHeight()));
     LatLng localLatLng2 = b.getMap().a().a;
     return new double[] { a, b, a, b, a, b };
   }
   return null;
 }
    public AccidentViewHolder(final View itemView) {
      super(itemView);
      final Context context = itemView.getContext();
      mPadding = context.getResources().getDimensionPixelSize(R.dimen.content_inset_material);

      mMapView = (MapView) itemView.findViewById(R.id.map_view);
      final int gmsState = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
      if (gmsState == ConnectionResult.SUCCESS) {
        mMapView.onCreate(null);
      }

      // Gets to GoogleMap from the MapView and does initialization stuff
      mGoogleMap = mMapView.getMap();
      mGoogleMap.setMyLocationEnabled(false);
      mGoogleMap.setOnMapLoadedCallback(this);

      final UiSettings uiSettings = mGoogleMap.getUiSettings();
      uiSettings.setMyLocationButtonEnabled(false);
      uiSettings.setAllGesturesEnabled(false);
      uiSettings.setZoomControlsEnabled(false);

      // Needs to call MapsInitializer before doing any CameraUpdateFactory calls
      try {
        MapsInitializer.initialize(context);
      } catch (final Exception e) {
        Log.e(LOG_TAG, "Failed to initialize Google Maps. ", e);
      }

      mTimeView = (TextView) itemView.findViewById(R.id.time);
      mMaxSpeedView = (TextView) itemView.findViewById(R.id.max_speed);
    }
  private void setupMap(final LatLng center, final Bundle savedInstanceState) {
    mapView = new MapView(this);
    mapView.onCreate(savedInstanceState);
    MapsInitializer.initialize(this);

    if (mapView.getMap() != null) {
      mapRender = new MapRender(this, mapView.getMap(), true);

      if (center != null) {
        final CameraPosition cameraPosition =
            new CameraPosition.Builder().target(center).zoom(DEFAULT_ZOOM).build();
        mapView.getMap().moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
      }
    }

    final RelativeLayout rlView = (RelativeLayout) findViewById(R.id.db_map_rl);
    rlView.addView(mapView);
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_detail);
   mv = (MapView) findViewById(R.id.mapView);
   mv.onCreate(savedInstanceState);
   map = mv.getMap();
   init();
   initDemoPoint();
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_google_map_view, container, false);
    mMapView = (MapView) v.findViewById(R.id.mapView);
    mMapView.onCreate(savedInstanceState);

    mMapView.onResume(); // needed to get the map to display immediately

    try {
      MapsInitializer.initialize(getActivity().getApplicationContext());
    } catch (Exception e) {
      e.printStackTrace();
    }

    md = new GMapV2Direction(getActivity());

    queue = Volley.newRequestQueue(getActivity());

    googleMap = mMapView.getMap();

    googleMap.setMyLocationEnabled(true);

    if (checkPlayServices()) {

      // Building the GoogleApi client
      buildGoogleApiClient();
    }
    makeJsonObjectRequest();

    return v;

    //        Button btn_find = (Button) v.findViewById(R.id.button);
    //        etLocation = (EditText) v.findViewById(R.id.startLocation);
    //
    //        // Defining button click event listener for the find button
    //        OnClickListener findClickListener = new OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                // Getting user input location
    //                String location = etLocation.getText().toString();
    //
    //                if(location!=null && !location.equals("")){
    //                    new GeocoderTask().execute(location);
    //                }else{
    //                    makeJsonObjectRequest();
    //                }
    //            }
    //        };
    //        btn_find.setOnClickListener(findClickListener);

  }
示例#7
0
  //// ---onCreate--start----------------------------------------------
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // inflat and return the layout
    View view = inflater.inflate(R.layout.fragment_map, container, false);

    mMapView = (MapView) view.findViewById(R.id.mapView);
    mMapView.onCreate(savedInstanceState);

    mMapView.onResume(); // needed to get the map to display immediately

    try {
      MapsInitializer.initialize(getActivity().getApplicationContext());
    } catch (Exception e) {
      e.printStackTrace();
    }

    googleMap = mMapView.getMap();

    if (!isGooglePlayServicesAvailable()) getActivity().finish();

    createLocationRequest();

    mGoogleApiClient =
        new GoogleApiClient.Builder(getActivity())
            .addApi(LocationServices.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

    swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.map_swipeLayout);
    swipeLayout.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            Intent intent = new Intent(getActivity(), ReloadService.class);
            getActivity().startService(intent);
          }
        });

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(ReloadService.DONE);
    getActivity().registerReceiver(reloadDone, intentFilter);

    // Perform any camera updates here
    return view;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ubicacion);

    // Para agregar al LocationManager un nuevo LocationListener
    // que escuche las actualización de ubicación del GPS.
    LocationManager locManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    MyLocationListener locListener = new MyLocationListener();
    locListener.setUbicacionActivity(this);
    locManager.requestLocationUpdates(
        LocationManager.NETWORK_PROVIDER, 0, 0, (LocationListener) locListener);
    // locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, (LocationListener)
    // locListener);

    // ELEMENTOS DE LA INTERFAZ
    tvUbicacion = (TextView) findViewById(R.id.tvUbi);
    tvDireccion = (TextView) findViewById(R.id.tvDireccion);
    logo = (ImageView) findViewById(R.id.logo);
    vistaMapa = (MapView) findViewById(R.id.miMapa);
    Button btnActualizar = (Button) findViewById(R.id.btnActualizar);

    vistaMapa.onCreate(savedInstanceState);
    // inicializar google map
    googleMapa = vistaMapa.getMap();
    // tipo de mapa que queramos mostrar
    googleMapa.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    // poner a disponible la ubicacion para poder utilizar
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
            != PackageManager.PERMISSION_GRANTED
        && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION)
            != PackageManager.PERMISSION_GRANTED) {
      // TODO: Consider calling
      //    ActivityCompat#requestPermissions
      // here to request the missing permissions, and then overriding
      //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
      //                                          int[] grantResults)
      // to handle the case where the user grants the permission. See the documentation
      // for ActivityCompat#requestPermissions for more details.
      return;
    }
    googleMapa.setMyLocationEnabled(true);
    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_map, container, false);
    mMapView = (MapView) v.findViewById(R.id.map);
    mMapView.onCreate(savedInstanceState);
    mMapView.onResume();

    try {
      MapsInitializer.initialize(getActivity().getApplicationContext());
    } catch (Exception e) {
      e.printStackTrace();
    }

    GoogleMap googleMap = mMapView.getMap();
    googleMap.setOnInfoWindowClickListener(this);

    indicative = new LatLng(48.511902, 32.269087);
    hydrosila = new LatLng(48.524263, 32.265076);
    zirka = new LatLng(48.515700, 32.265896);
    MarkerOptions mrkIndicative =
        new MarkerOptions()
            .position(indicative)
            .title("Indicative")
            .snippet(getString(R.string.indicative_snippet));
    MarkerOptions mrkHydrosila =
        new MarkerOptions()
            .position(hydrosila)
            .title("Hydrosila")
            .snippet(getString(R.string.hydrosila_snippet));
    MarkerOptions mrkZirka =
        new MarkerOptions()
            .position(zirka)
            .title("Zirka")
            .snippet(getString(R.string.zirka_snippet));

    googleMap.addMarker(mrkHydrosila);
    googleMap.addMarker(mrkIndicative);
    googleMap.addMarker(mrkZirka);

    CameraPosition cameraPosition =
        new CameraPosition.Builder().target(indicative).zoom(15).build();
    googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

    return v;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_detail_list, container, false);

    // Gets the MapView from the XML layout and creates it
    mapView = (MapView) v.findViewById(R.id.map_view);
    mapView.onCreate(savedInstanceState);

    // Gets to GoogleMap from the MapView and does initialization stuff
    mMap = mapView.getMap();
    mMap.getUiSettings().setMyLocationButtonEnabled(false);
    mMap.setMyLocationEnabled(true);

    setUpMap();

    return v;
  }
示例#11
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_map, container, false);
    mMapView = (MapView) v.findViewById(R.id.mapView);
    mMapView.onCreate(savedInstanceState);
    mMapView.onResume();

    try {
      MapsInitializer.initialize(getActivity().getApplicationContext());
    } catch (Exception e) {
      e.printStackTrace();
    }

    googleMap = mMapView.getMap();
    googleMap.getUiSettings().setMapToolbarEnabled(true);
    double paviaX = ConnectionHandler.getCityCoordX();
    double paviaY = ConnectionHandler.getCityCoordY();
    LatLng latLng = new LatLng(paviaX, paviaY);
    googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
    googleMap.setOnInfoWindowClickListener(
        new GoogleMap.OnInfoWindowClickListener() {
          @Override
          public void onInfoWindowClick(Marker marker) {
            final String title = marker.getTitle();
            if (!title.isEmpty()) {
              VenueInfo info = DataService.getVenueInfo(title);
              if (info != null) {
                DataService.SelectedVenue = info;
                DataService.setContactInfo(DataService.SelectedVenue.contact);
                // open the detail
                Intent intent = new Intent(getActivity(), VenueDetailActivity.class);
                intent.putExtra("Title", title);
                getActivity().startActivity(intent);
              }
            }
          }
        });
    // new AddMarkerFromBackground().executeOnExecutor(Executors.newSingleThreadExecutor());
    return v;
  }
示例#12
0
  private void initMapSetting(MapView mapView) {
    map = mapView.getMap();
    CameraPosition cameraPosition =
        new CameraPosition.Builder().target(seolleung).tilt(45).zoom(16).bearing(45).build();
    map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

    // TODO : 지도정보 가져와서 뿌려줘야함
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_pointer))
            .position(test1));
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_pointer))
            .position(test2));
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_pointer))
            .position(test3));
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_pointer))
            .position(test4));
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_pointer))
            .position(test5));
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_pointer))
            .position(test6));
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_pointer))
            .position(test7));
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_pointer))
            .position(test8));
  }
示例#13
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.activity_map_fragment, container, false);
    mapView = (MapView) v.findViewById(R.id.mapView);
    mapView.onCreate(savedInstanceState);
    mapView.onResume();

    marker = null;

    try {
      MapsInitializer.initialize(getActivity().getApplicationContext());
    } catch (Exception e) {
      e.printStackTrace();
    }

    googleMap = mapView.getMap();
    googleMap.setMyLocationEnabled(true);
    LocationManager manager =
        (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
    Location location = manager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    locate(location);

    radius = 20;
    googleMap.setOnMapLongClickListener(
        new GoogleMap.OnMapLongClickListener() {
          @Override
          public void onMapLongClick(LatLng latLng) {
            setMarkerLocation(latLng);
          }
        });

    if (alarm != null) {
      radius = alarm.getRadius();
      setMarkerLocation(new LatLng(alarm.getLocationX(), alarm.getLocationY()), 17.0f);
    }

    return v;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_forecast_map, container, false);

    mapView = (MapView) v.findViewById(R.id.map_view);
    mapView.onCreate(savedInstanceState);

    mMap = mapView.getMap();
    MapsInitializer.initialize(this.getActivity());

    mMap.getUiSettings().setZoomControlsEnabled(true);

    // Add a marker in Tbilisi and move the camera
    // Tbilisi lat & lng
    LatLng latLngToZoom = new LatLng(41.7151377, 44.827096);
    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLngToZoom));
    mMap.animateCamera(CameraUpdateFactory.zoomTo(6.0f));

    return v;
  }
示例#15
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // inflate and return the layout
    View v = inflater.inflate(R.layout.fragment_maps, container, false);

    db = new DatabaseHelper(getActivity());
    victimName = getArguments().getString("VICTIMNAME");

    mMapView = (MapView) v.findViewById(R.id.mapView);
    mMapView.onCreate(savedInstanceState);

    mMapView.onResume(); // needed to get the map to display immediately

    try {
      MapsInitializer.initialize(getActivity().getApplicationContext());
    } catch (Exception e) {
      e.printStackTrace();
    }

    googleMap = mMapView.getMap();
    GPScords = db.getGPSCor(victimName);

    if (GPScords.size() == 0) {
      Toast.makeText(getActivity(), "Downloading gps coordinates...", Toast.LENGTH_LONG).show();
    } else {
      // google maps camera view start
      googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(GPScords.get(0), 20));

      // Draw path from gps point
      Polyline line =
          googleMap.addPolyline(
              new PolylineOptions().addAll(GPScords).width(5).color(Color.BLUE).geodesic(true));
    }

    return v;
  }
示例#16
0
  private void setView(Bundle savedInstanceState) {
    mv.onCreate(savedInstanceState);

    mc = new MapController(mv.getMap());
  }
  @Override
  public MapView createViewInstance(ThemedReactContext context) {
    reactContext = context;
    mView = new MapView(context);
    mView.onCreate(null);
    mView.onResume();
    map = mView.getMap();

    if (map == null) {
      sendMapError("Map is null", "map_null");
    } else {
      map.getUiSettings().setMyLocationButtonEnabled(true);
      map.setMyLocationEnabled(true);

      // We need to be sure to disable location-tracking when app enters background, in-case some
      // other module
      // has acquired a wake-lock and is controlling location-updates, otherwise, location-manager
      // will be left
      // updating location constantly, killing the battery, even though some other location-mgmt
      // module may
      // desire to shut-down location-services.
      LifecycleEventListener listener =
          new LifecycleEventListener() {
            @Override
            public void onHostResume() {
              map.setMyLocationEnabled(true);
            }

            @Override
            public void onHostPause() {
              map.setMyLocationEnabled(false);
            }

            @Override
            public void onHostDestroy() {}
          };

      context.addLifecycleEventListener(listener);

      try {
        MapsInitializer.initialize(context.getApplicationContext());
        map.setOnCameraChangeListener(getCameraChangeListener());
        map.setOnMarkerClickListener(getMarkerClickListener());
        // add location button click listener
        map.setOnMyLocationButtonClickListener(
            new GoogleMap.OnMyLocationButtonClickListener() {
              @Override
              public boolean onMyLocationButtonClick() {
                CameraPosition position = map.getCameraPosition();
                mlastZoom = (int) position.zoom;
                return false;
              }
            });
      } catch (Exception e) {
        e.printStackTrace();
        sendMapError("Map initialize error", "map_init_error");
      }
    }

    return mView;
  }
示例#18
0
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_map, container, false);

    mMapView = (MapView) view.findViewById(R.id.mapView);
    mMapView.onCreate(savedInstanceState);
    mMapView.onResume();

    try {
      MapsInitializer.initialize(this.getActivity());
    } catch (GooglePlayServicesNotAvailableException e) {
      e.printStackTrace();
    }

    mGoogleMap = mMapView.getMap();
    mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(center, 13));

    mGoogleMap.setMyLocationEnabled(true);

    /** LocationManager referenciájának lekérése */
    LocationManager locationManager =
        (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);

    Criteria criteria = new Criteria();

    /** Elérhetõ legjobb kapcsolat lekérése */
    String provider = locationManager.getBestProvider(criteria, true);

    /** Aktuális pozició lekérése */
    Location location = locationManager.getLastKnownLocation(provider);

    if (location != null) {
      onLocationChanged(location);
    }
    locationManager.requestLocationUpdates(provider, 5000, 0, this);
    getPeaksCooridinates();
    getPeaksTitles();

    lastSearchButton = (Button) view.findViewById(R.id.lastSearch);
    lastSearchButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Boolean resultLineIsEmpty = SearchFragment.resultLine.isEmpty();

            if (mapIsMarked == true) {
              mGoogleMap.clear();
            }

            if (resultLineIsEmpty == false) {
              markLastLine();
              mapIsMarked = true;
              markState = 1;
            }
          }
        });

    allPeaksButton = (Button) view.findViewById(R.id.allPeaks);
    allPeaksButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {

            if (mapIsMarked == true) {
              mGoogleMap.clear();
            }
            markAll();
            mapIsMarked = true;
            markState = 2;
          }
        });

    clearButton = (Button) view.findViewById(R.id.clear);
    clearButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            mGoogleMap.clear();
            markState = 0;
          }
        });

    return view;
  }