Search in sources :

Example 31 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project Pokemap by omkarmoghe.

the class MapWrapperFragment method setGymsMarkers.

private void setGymsMarkers(final GymsEvent event) {
    if (mGoogleMap != null) {
        int markerSize = getResources().getDimensionPixelSize(R.dimen.gym_marker);
        Collection<FortDataOuterClass.FortData> gyms = event.getGyms();
        if (gyms != null && mPref.getShowGyms()) {
            Set<String> markerKeys = gymsList.keySet();
            for (final FortDataOuterClass.FortData gym : gyms) {
                double distanceFromCenterInMeters = MapHelper.distance(new LatLng(event.getLatitude(), event.getLongitude()), new LatLng(gym.getLatitude(), gym.getLongitude())) * 1000;
                if (!markerKeys.contains(gym.getId()) && distanceFromCenterInMeters <= MapHelper.convertStepsToRadius(mPref.getSteps())) {
                    RemoteImageLoader.loadMapIcon(getActivity(), gymTeamImageUrls.get(gym.getOwnedByTeam().getNumber()), markerSize, markerSize, new RemoteImageLoader.Callback() {

                        @Override
                        public void onFetch(Bitmap bitmap) {
                            BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
                            Marker marker = mGoogleMap.addMarker(new MarkerOptions().position(new LatLng(gym.getLatitude(), gym.getLongitude())).title(getString(R.string.gym)).icon(bitmapDescriptor).zIndex(MapHelper.LAYER_GYMS).anchor(0.5f, 0.5f));
                            // adding gyms to list to be removed on next search
                            gymsList.put(gym.getId(), new GymMarkerExtended(gym, marker));
                        }
                    });
                }
            }
        }
        updateMarkers();
    } else {
        showMapNotInitializedError();
    }
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) GymMarkerExtended(com.omkarmoghe.pokemap.models.map.GymMarkerExtended) FortDataOuterClass(POGOProtos.Map.Fort.FortDataOuterClass) BitmapDescriptor(com.google.android.gms.maps.model.BitmapDescriptor) Marker(com.google.android.gms.maps.model.Marker) Bitmap(android.graphics.Bitmap) LatLng(com.google.android.gms.maps.model.LatLng) RemoteImageLoader(com.omkarmoghe.pokemap.helpers.RemoteImageLoader)

Example 32 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project Pokemap by omkarmoghe.

the class MapWrapperFragment method setPokestopsMarkers.

private void setPokestopsMarkers(final PokestopsEvent event) {
    if (mGoogleMap != null) {
        int markerSize = getResources().getDimensionPixelSize(R.dimen.pokestop_marker);
        Collection<Pokestop> pokestops = event.getPokestops();
        if (pokestops != null && mPref.getShowPokestops()) {
            Set<String> markerKeys = pokestopsList.keySet();
            for (final Pokestop pokestop : pokestops) {
                // radial boxing
                double distanceFromCenterInMeters = MapHelper.distance(new LatLng(event.getLatitude(), event.getLongitude()), new LatLng(pokestop.getLatitude(), pokestop.getLongitude())) * 1000;
                if (!markerKeys.contains(pokestop.getId()) && distanceFromCenterInMeters <= MapHelper.convertStepsToRadius(mPref.getSteps())) {
                    RemoteImageLoader.loadMapIcon(getActivity(), pokestop.hasLurePokemon() ? lurePokeStopImageUrl : pokeStopImageUrl, markerSize, markerSize, new RemoteImageLoader.Callback() {

                        @Override
                        public void onFetch(Bitmap bitmap) {
                            BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
                            Marker marker = mGoogleMap.addMarker(new MarkerOptions().position(new LatLng(pokestop.getLatitude(), pokestop.getLongitude())).title(getString(R.string.pokestop)).icon(bitmapDescriptor).zIndex(MapHelper.LAYER_POKESTOPS).alpha(pokestop.hasLurePokemon() ? 1.0f : 0.5f).anchor(0.5f, 0.5f));
                            //adding pokemons to list to be removed on next search
                            pokestopsList.put(pokestop.getId(), new PokestopMarkerExtended(pokestop, marker));
                        }
                    });
                }
            }
        }
        updateMarkers();
    } else {
        showMapNotInitializedError();
    }
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) PokestopMarkerExtended(com.omkarmoghe.pokemap.models.map.PokestopMarkerExtended) BitmapDescriptor(com.google.android.gms.maps.model.BitmapDescriptor) Marker(com.google.android.gms.maps.model.Marker) Bitmap(android.graphics.Bitmap) Pokestop(com.pokegoapi.api.map.fort.Pokestop) LatLng(com.google.android.gms.maps.model.LatLng) RemoteImageLoader(com.omkarmoghe.pokemap.helpers.RemoteImageLoader)

Example 33 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project HumaneApp by Ganesh1010.

the class MapActivity method onLocationChanged.

@Override
public void onLocationChanged(Location locations) {
    System.out.println("location changed");
    if (mCurrLocationMarker != null) {
        mCurrLocationMarker.remove();
    }
    //Place current location marker
    LatLng latLng = new LatLng(locations.getLatitude(), locations.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    cur_latitude = locations.getLatitude();
    cur_longitude = locations.getLongitude();
    latitude = cur_latitude;
    longitude = cur_longitude;
    location = new LatLng(cur_latitude, cur_longitude);
    mCurrLocationMarker = mGoogleMap.addMarker(new MarkerOptions().position(location).title(getAaddress(cur_latitude, cur_longitude)));
    mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 17));
    if (mGoogleApiClient != null) {
        LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
    }
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) LatLng(com.google.android.gms.maps.model.LatLng)

Example 34 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project HumaneApp by Ganesh1010.

the class MapActivity method onMapSearch.

public void onMapSearch(String locations) {
    System.out.println("location searched");
    if (addresses.size() > 0)
        addresses.clear();
    //String locations = locationSearch.getText().toString();
    try {
        addresses = geocoder.getFromLocationName(locations, 1);
        Address address = addresses.get(0);
        if (mCurrLocationMarker != null) {
            mCurrLocationMarker.remove();
        }
        latitude = address.getLatitude();
        longitude = address.getLongitude();
        location = new LatLng(latitude, longitude);
        mCurrLocationMarker = mGoogleMap.addMarker(new MarkerOptions().position(location).title(getAaddress(latitude, longitude)));
        mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 17));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) Address(android.location.Address) LatLng(com.google.android.gms.maps.model.LatLng) IOException(java.io.IOException)

Example 35 with MarkerOptions

use of com.google.android.gms.maps.model.MarkerOptions in project easy by MehdiBenmesa.

the class MapsActivity method onMapReady.

/**
     * Manipulates the map once available.
     * This callback is triggered when the map is ready to be used.
     * This is where we can add markers or lines, add listeners or move the camera. In this case,
     * we just add a marker near Sydney, Australia.
     * If Google Play services is not installed on the device, the user will be prompted to install
     * it inside the SupportMapFragment. This method will only be triggered once the user has
     * installed Google Play services and returned to the app.
     */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    // Add a marker in Sydney and move the camera
    LatLng sydney = new LatLng(-34, 151);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) LatLng(com.google.android.gms.maps.model.LatLng)

Aggregations

MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)39 LatLng (com.google.android.gms.maps.model.LatLng)24 BitmapDescriptor (com.google.android.gms.maps.model.BitmapDescriptor)7 Marker (com.google.android.gms.maps.model.Marker)6 GoogleMap (com.google.android.gms.maps.GoogleMap)5 Bitmap (android.graphics.Bitmap)4 View (android.view.View)4 Document (org.w3c.dom.Document)4 OnClickListener (android.view.View.OnClickListener)3 GoogleDirection (app.akexorcist.gdaplibrary.GoogleDirection)3 OnDirectionResponseListener (app.akexorcist.gdaplibrary.GoogleDirection.OnDirectionResponseListener)3 OnMapReadyCallback (com.google.android.gms.maps.OnMapReadyCallback)3 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)3 RemoteImageLoader (com.omkarmoghe.pokemap.helpers.RemoteImageLoader)3 TextView (android.widget.TextView)2 OnAnimateListener (app.akexorcist.gdaplibrary.GoogleDirection.OnAnimateListener)2 CameraPosition (com.google.android.gms.maps.model.CameraPosition)2 CircleOptions (com.google.android.gms.maps.model.CircleOptions)2 PokemonIdOuterClass (POGOProtos.Enums.PokemonIdOuterClass)1 FortDataOuterClass (POGOProtos.Map.Fort.FortDataOuterClass)1