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();
}
}
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();
}
}
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);
}
}
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();
}
}
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));
}
Aggregations