Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorDmitry Kunin <dkunin@mapswith.me>2013-06-11 14:24:20 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:56:34 +0300
commit0502e8f6ae7731807dd267f30be793077ad5e56e (patch)
tree8dae5bf2115766be0fc41f2d39674cef116bd705 /api
parent71dcf6bce16f0e318f2122c2cfbbefcec0b9507b (diff)
[android] Added zoom level param for one point.
Diffstat (limited to 'api')
-rw-r--r--api/android/lib/src/com/mapswithme/maps/api/MapsWithMeApi.java91
1 files changed, 74 insertions, 17 deletions
diff --git a/api/android/lib/src/com/mapswithme/maps/api/MapsWithMeApi.java b/api/android/lib/src/com/mapswithme/maps/api/MapsWithMeApi.java
index d3ac6d596d..f456b211cc 100644
--- a/api/android/lib/src/com/mapswithme/maps/api/MapsWithMeApi.java
+++ b/api/android/lib/src/com/mapswithme/maps/api/MapsWithMeApi.java
@@ -15,26 +15,84 @@ import java.util.Locale;
public final class MapsWithMeApi
{
- public static void showPointsOnMap(Activity caller, MWMPoint... points)
- {
- showPointsOnMap(caller, null, null, points);
- }
+ public static final double ZOOM_MIN = 1;
+ public static final double ZOOM_MAX = 19;
- public static void showPointOnMap(Activity caller, double lat, double lon, String name, String id)
+ /**
+ * Shows single point on the map.
+ *
+ * @param caller
+ * @param lat
+ * @param lon
+ * @param name
+ */
+ public static void showPointOnMap(Activity caller, double lat, double lon, String name)
{
showPointsOnMap(caller, (String)null, (PendingIntent)null, new MWMPoint(lat, lon, name));
}
+
+
+ /**
+ * Shows single point on the map using specified
+ * zoom level in range from {@link MapsWithMeApi#ZOOM_MIN} to {@link MapsWithMeApi#ZOOM_MAX}.
+ *
+ * @param caller
+ * @param lat
+ * @param lon
+ * @param name
+ * @param zoomLevel
+ */
+ public static void showPointOnMap(Activity caller, double lat, double lon, String name, double zoomLevel)
+ {
+ showPointsOnMap(caller, (String)null, zoomLevel, (PendingIntent)null, new MWMPoint(lat, lon, name));
+ }
+ /**
+ * Shows set of points on the map.
+ *
+ * @param caller
+ * @param title
+ * @param points
+ */
public static void showPointsOnMap(Activity caller, String title, MWMPoint... points)
{
showPointsOnMap(caller, title, null, points);
}
- public static void showPointsOnMap(Activity caller, String title, PendingIntent pendingIntent, MWMPoint... points)
+ /**
+ * Shows set of points on the maps
+ * and allows MapsWithMeApplication to send {@link PendingIntent} provided by client application.
+ *
+ * @param caller
+ * @param title
+ * @param pendingIntent
+ * @param points
+ */
+ public static void showPointsOnMap(Activity caller, String title, PendingIntent pendingIntent, MWMPoint ... points)
+ {
+ showPointsOnMap(caller, title, -1, pendingIntent, points);
+ }
+
+ /**
+ * Detects if any version (Lite, Pro) of MapsWithMe, which supports
+ * API calls are installed on the device.
+ *
+ * @param context
+ * @return
+ */
+ public static boolean isMapsWithMeInstalled(Context context)
+ {
+ final Intent intent = new Intent(Const.ACTION_MWM_REQUEST);
+ return context.getPackageManager().resolveActivity(intent, 0) != null;
+ }
+
+ // Internal only code
+
+ private static void showPointsOnMap(Activity caller, String title, double zoomLevel, PendingIntent pendingIntent, MWMPoint... points)
{
final Intent mwmIntent = new Intent(Const.ACTION_MWM_REQUEST);
- mwmIntent.putExtra(Const.EXTRA_URL, createMwmUrl(caller, title, points).toString());
+ mwmIntent.putExtra(Const.EXTRA_URL, createMwmUrl(caller, title, zoomLevel, points).toString());
mwmIntent.putExtra(Const.EXTRA_TITLE, title);
final boolean hasIntent = pendingIntent != null;
@@ -47,7 +105,6 @@ public final class MapsWithMeApi
if (isMapsWithMeInstalled(caller))
{
// Match activity for intent
- // TODO specify DEFAULT for Pro version.
final ActivityInfo aInfo = caller.getPackageManager().resolveActivity(mwmIntent, 0).activityInfo;
mwmIntent.setClassName(aInfo.packageName, aInfo.name);
caller.startActivity(mwmIntent);
@@ -56,15 +113,8 @@ public final class MapsWithMeApi
else
Toast.makeText(caller, "MapsWithMe is not installed.", Toast.LENGTH_LONG).show();
}
-
- public static boolean isMapsWithMeInstalled(Context context)
- {
- final Intent intent = new Intent(Const.ACTION_MWM_REQUEST);
- return context.getPackageManager().resolveActivity(intent, 0) != null;
- }
-
- static StringBuilder createMwmUrl(Context context, String title, MWMPoint ... points)
+ static StringBuilder createMwmUrl(Context context, String title, double zoomLevel, MWMPoint ... points)
{
StringBuilder urlBuilder = new StringBuilder("mapswithme://map?");
// version
@@ -77,7 +127,9 @@ public final class MapsWithMeApi
.append("&");
// title
appendIfNotNull(urlBuilder, "appname", title);
-
+ // zoom
+ appendIfNotNull(urlBuilder, "z", isValidZoomLevel(zoomLevel) ? String.valueOf(zoomLevel) : null);
+
// points
for (MWMPoint point : points)
{
@@ -117,4 +169,9 @@ public final class MapsWithMeApi
return builder;
}
+
+ private static boolean isValidZoomLevel(double zoom)
+ {
+ return zoom >= ZOOM_MIN && zoom <= ZOOM_MAX;
+ }
}