0

I've been playing with the Javascript Google Maps API and am able to get it to display the Moon and Mars maps that Google have.

I am wondering if I can do the same natively for Android. Looking at the Google Maps for Android API V2 I see no mention of this functionality. In searching the web I didn't either.

So my question. Can I have Google Mars and Moon maps natively in Android? Or do I have to wrap HTML5/Javascript into a web view?

Andrew S
  • 2,847
  • 3
  • 33
  • 50

2 Answers2

0

I am not sure if this is what you are looking for, but in the samples downloaded with Google Play Service lib you get the maps demo application and check Tile Overlays Activity, it shows how to add moon tiles.

here is a link on where to find the sample code : Sample Code

Moh Sakkijha
  • 2,705
  • 1
  • 14
  • 19
  • Thankyou for this link I will take a look and get back. – Andrew S Jan 10 '13 at 18:28
  • Yep, thanks the answer was shown in the code for the TileOverlayDemoActivity. I will warn would be Google Maps Android V2 demo users to follow instructions carefully. These two posts may be of interest too. http://stackoverflow.com/questions/13703273/google-map-api-v2-is-not-working/14284558#14284558 and http://stackoverflow.com/questions/13733911/google-maps-android-api-v2-sample-code-crashes – Andrew S Jan 11 '13 at 18:58
  • @AndrewS glad it is what you was looking for :) – Moh Sakkijha Jan 11 '13 at 19:39
0

I used the recomendation provided by @Moh,it is working fine. Thank you.

Also wrote the code for Mars map, for android. Using this example https://github.com/googlemaps/android-samples/blob/master/ApiDemos/java/app/src/main/java/com/example/mapdemo/TileOverlayDemoActivity.java

Here the method for mars

@Override
public void onMapReady(GoogleMap map) {
    map.setMapType(GoogleMap.MAP_TYPE_NONE);

    TileProvider tileProvider = new UrlTileProvider(256, 256) {


        @Override
        public synchronized URL getTileUrl(int x, int y, int zoom) {
            // The mars tile coordinate system .
            System.out.println(" marte 101");
            double bound = Math.pow(2, zoom);


            String quads = "t";
            System.out.println(" marte 102");
            for (int z = 0; z < zoom; z++) {
                bound = bound / 2;
                if (y < bound) {
                    if (x < bound) {
                        quads=quads+"q";
                    } else {
                        quads=quads+"r";
                        x -= bound;
                    }
                } else {
                    if (x < bound) {
                        quads=quads+"t";

                        y -= bound;
                    } else {
                        quads=quads+"s";

                        x -= bound;
                        y -= bound;
                    }
                }
            }

            System.out.println(" marte 103");

            String s = "http://mw1.google.com/mw-planetary/mars/elevation/"+quads+".jpg";
            System.out.println(" marte 104:"+s);
            URL url = null;
            try {
                url = new URL(s);
            } catch (MalformedURLException e) {
                throw new AssertionError(e);
            }
            return url;
        }
    };
    System.out.println(" marte 2");
    mMoonTiles = map.addTileOverlay(new TileOverlayOptions().tileProvider(tileProvider));
    System.out.println(" marte 3");
    mTransparencyBar.setOnSeekBarChangeListener(this);
    System.out.println(" marte 4.1");
}

I obtained the original method, (in javascript) from this https://github.com/beekay-/gmaps-samples-v3/blob/master/planetary-maptypes/planetary-maptypes.html

I used elevation. But there is also the mars map with option visible or infrared.

Hope it helps for someone looking for a Mars map in Java Android.