Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>osmosa-viewer</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
12 changes: 12 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#Tue Apr 24 12:16:17 WIT 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
27 changes: 27 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.osmosa.viewer"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="14"/>

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Binary file added libs/osmdroid-android-3.0.7.jar
Binary file not shown.
Binary file added libs/osmdroid-third-party-3.0.7.jar
Binary file not shown.
Binary file added libs/slf4j-android-1.6.1-RC1.jar
Binary file not shown.
20 changes: 20 additions & 0 deletions proguard-project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
14 changes: 14 additions & 0 deletions project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=Google Inc.:Google APIs:7
Binary file added res/drawable-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-ldpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/marker_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<org.osmdroid.views.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true" />

</LinearLayout>
29 changes: 29 additions & 0 deletions res/layout/popup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:drawable/btn_default"
android:stretchColumns="1,3" >

<TableRow>
<TextView
android:layout_marginRight="10dip"
android:text="Lat:" />
<TextView android:id="@+id/latitude" />
<TextView
android:layout_marginRight="10dip"
android:text="Lon:" />
<TextView android:id="@+id/longitude" />
</TableRow>
<TableRow>
<TextView
android:layout_marginRight="10dip"
android:text="X:" />
<TextView android:id="@+id/x" />
<TextView
android:layout_marginRight="10dip"
android:text="Y:" />
<TextView android:id="@+id/y" />
</TableRow>

</TableLayout>
4 changes: 4 additions & 0 deletions res/menu/main_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/changeserver" android:title="@string/change_server"></item>
</menu>
5 changes: 5 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Osmosa Viewer</string>
<string name="change_server">Change Server</string>
</resources>
9 changes: 9 additions & 0 deletions src/net/osmosa/viewer/Constant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package net.osmosa.viewer;

import org.osmdroid.tileprovider.tilesource.OnlineTileSourceBase;
import org.osmdroid.tileprovider.tilesource.XYTileSource;

public class Constant {
public static final OnlineTileSourceBase OSMOSA_TILE = new XYTileSource("OSMOSA-ID", null, 3, 18, 256, ".png",
"http://www.osmosa.net/osm_tiles3/");
}
121 changes: 121 additions & 0 deletions src/net/osmosa/viewer/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package net.osmosa.viewer;

import static net.osmosa.viewer.Constant.OSMOSA_TILE;

import java.util.ArrayList;

import net.osmosa.viewer.overlay.PointItemizedOverlay;

import org.osmdroid.tileprovider.MapTileProviderBasic;
import org.osmdroid.tileprovider.tilesource.OnlineTileSourceBase;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.ItemizedIconOverlay.OnItemGestureListener;
import org.osmdroid.views.overlay.OverlayItem;
import org.osmdroid.views.overlay.TilesOverlay;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.Toast;

public class MainActivity extends Activity {

private MapView osmMapview;
private PointItemizedOverlay<OverlayItem> mLocationOverlay;

private static final int TILE_SOURCE = Menu.FIRST;
private static final int OSMOSA = TILE_SOURCE + 1;
private static final int OPENSTREETMAP = OSMOSA + 1;
private boolean isOsmosa = true;

@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

RelativeLayout relativeLayout = new RelativeLayout(this);

osmMapview = new MapView(this, 256);
relativeLayout.addView(osmMapview, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));

osmMapview.setBuiltInZoomControls(true);
osmMapview.setMultiTouchControls(true);
osmMapview.getController().setZoom(2);
osmMapview.getController().setCenter(new GeoPoint((int) (-2.56 * 1E6), (int) (116.97 * 1E6)));

changeServer(OSMOSA_TILE);
{
ArrayList<OverlayItem> items = new ArrayList<OverlayItem>();
items.add(new OverlayItem("Cempaka Putih", "Meruvian", new GeoPoint((int) (-6.29 * 1E6), (int) (106.75 * 1E6))));
items.add(new OverlayItem("Blitar", "Home", new GeoPoint((int) (-8.10 * 1E6), (int) (112.16 * 1E6))));
mLocationOverlay = new PointItemizedOverlay<OverlayItem>(items,
this.getResources().getDrawable(R.drawable.marker_default), itemGestureListener, this);
osmMapview.getOverlays().add(mLocationOverlay);
}

setContentView(relativeLayout);
}

private OnItemGestureListener<OverlayItem> itemGestureListener = new OnItemGestureListener<OverlayItem>() {
@Override
public boolean onItemLongPress(int index, OverlayItem item) {
Toast.makeText(MainActivity.this, item.mTitle, Toast.LENGTH_LONG).show();
return true;
}

@Override
public boolean onItemSingleTapUp(int index, OverlayItem item) {
Toast.makeText(MainActivity.this, item.mTitle, Toast.LENGTH_LONG).show();
return false;
}
};

@Override
public boolean onCreateOptionsMenu(Menu menu) {
SubMenu subMenu = menu.addSubMenu(Menu.CATEGORY_CONTAINER, TILE_SOURCE, Menu.NONE, "Choose Tile Source");
{
subMenu.add(Menu.CATEGORY_SECONDARY, OSMOSA, Menu.NONE, "osmosa.net");
subMenu.add(Menu.CATEGORY_SECONDARY, OPENSTREETMAP, Menu.NONE, "openstreetmap.org");
}
return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case OPENSTREETMAP:
if (isOsmosa)
changeServer(TileSourceFactory.MAPNIK);
isOsmosa = false;
return true;
case OSMOSA:
if (!isOsmosa)
changeServer(OSMOSA_TILE);
isOsmosa = true;
return true;
}
return false;
}

public void changeServer(OnlineTileSourceBase tileSource) {
MapTileProviderBasic tileProvider = new MapTileProviderBasic(getApplicationContext());
tileProvider.setTileSource(tileSource);

TilesOverlay tilesOverlay = new TilesOverlay(tileProvider, this.getBaseContext());
tilesOverlay.setLoadingBackgroundColor(Color.TRANSPARENT);

if (osmMapview.getOverlays().isEmpty()) {
osmMapview.getOverlays().add(tilesOverlay);
} else {
osmMapview.getOverlays().set(0, tilesOverlay);
}
osmMapview.invalidate();
}
}
30 changes: 30 additions & 0 deletions src/net/osmosa/viewer/overlay/PointItemizedOverlay.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package net.osmosa.viewer.overlay;

import java.util.List;

import org.osmdroid.DefaultResourceProxyImpl;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.ItemizedIconOverlay;
import org.osmdroid.views.overlay.OverlayItem;
import org.osmdroid.views.overlay.OverlayItem.HotspotPlace;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;

public class PointItemizedOverlay<Item extends OverlayItem> extends ItemizedIconOverlay<Item> {

private Drawable marker;

public PointItemizedOverlay(List<Item> aList, Drawable pMarker, OnItemGestureListener<Item> aOnItemTapListener,
Context ctx) {
super(aList, pMarker, aOnItemTapListener, new DefaultResourceProxyImpl(ctx));
this.marker = pMarker;
}

@Override
public void draw(Canvas c, MapView osmv, boolean shadow) {
super.draw(c, osmv, shadow);
boundToHotspot(marker, HotspotPlace.BOTTOM_CENTER);
}
}