Android Open Source - pink-ponies Map Overlay






From Project

Back to project page pink-ponies.

License

The source code is released under:

Software License Agreement (BSD License) Copyright (c) 2013, Pink Ponies Team All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted prov...

If you think the Android project pink-ponies listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * Copyright (c) 2013 Alexander Konovalov, Andrey Konovalov, Sergey Voronov, Vitaly Malyshev. All
 * rights reserved. Use of this source code is governed by a BSD-style license that can be found in
 * the LICENSE file.//from  www . j  a  v  a2  s.  com
 */

package ru.pinkponies.app;

import java.util.HashMap;
import java.util.Map;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import android.graphics.Color;

/**
 * An overlay which displays arbitrary image markers on the map.
 */
public final class MapOverlay {
  private final GoogleMap map;

  private final Map<String, Marker> markers = new HashMap<String, Marker>();
  private final Map<String, Circle> circles = new HashMap<String, Circle>();

  public MapOverlay(final GoogleMap map) {
    this.map = map;
  }

  public synchronized void addMarker(final String name, final LatLng location, final BitmapDescriptor bitmapDescriptor) {
    if (this.markers.containsKey(name)) {
      this.removeMarker(name);
    }
    Marker marker = this.map.addMarker(new MarkerOptions().position(location).icon(bitmapDescriptor).title(name));
    this.markers.put(name, marker);
  }

  public synchronized void removeMarker(final String name) {
    Marker marker = this.markers.get(name);
    if (marker != null) {
      marker.remove();
      this.markers.remove(name);
    }
  }

  public synchronized void addCircle(final String name, final LatLng location, final double radius, final int color) {
    if (this.circles.containsKey(name)) {
      this.removeCircle(name);
    }
    Circle circle = this.map.addCircle(new CircleOptions().center(location).radius(radius).strokeWidth(2)
        .strokeColor(Color.BLACK).fillColor(color));
    this.circles.put(name, circle);
  }

  public synchronized void removeCircle(final String name) {
    Circle circle = this.circles.get(name);
    if (circle != null) {
      circle.remove();
      this.circles.remove(name);
    }
  }
}




Java Source Code List

android.UnusedStub.java
ru.pinkponies.app.LoginActivity.java
ru.pinkponies.app.MainActivity.java
ru.pinkponies.app.MapOverlay.java
ru.pinkponies.app.net.NetworkListener.java
ru.pinkponies.app.net.NetworkingService.java
ru.pinkponies.app.net.NetworkingThread.java
ru.pinkponies.app.net.package-info.java
ru.pinkponies.app.package-info.java
ru.pinkponies.protocol.AppleUpdatePacket.java
ru.pinkponies.protocol.ClientOptionsPacket.java
ru.pinkponies.protocol.Location.java
ru.pinkponies.protocol.LoginPacket.java
ru.pinkponies.protocol.Packet.java
ru.pinkponies.protocol.PlayerUpdatePacket.java
ru.pinkponies.protocol.Protocol.java
ru.pinkponies.protocol.QuestActionPacket.java
ru.pinkponies.protocol.QuestUpdatePacket.java
ru.pinkponies.protocol.SayPacket.java
ru.pinkponies.protocol.package-info.java
ru.pinkponies.server.Apple.java
ru.pinkponies.server.Entity.java
ru.pinkponies.server.IdManager.java
ru.pinkponies.server.Player.java
ru.pinkponies.server.Quest.java
ru.pinkponies.server.Server.java
ru.pinkponies.server.package-info.java