Android Open Source - interamap Map Fragment






From Project

Back to project page interamap.

License

The source code is released under:

MIT License

If you think the Android project interamap 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

package com.richso.interamap.view;
// w  ww.  ja  va  2s  .  c  o  m
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.UiSettings;
import com.google.android.gms.maps.model.LatLng;
import com.richso.interamap.utils.L;

/**
 * Created with IntelliJ IDEA.
 * User: nikolai
 * Date: 9/20/13
 * Time: 5:09 PM
 * To change this template use File | Settings | File Templates.
 */
public class MapFragment extends SupportMapFragment {

    {
        L.setTag(this.getClass().getName());
    }

    public MapFragment() {
        return;
    }

    @Override
    public View onCreateView(LayoutInflater arg0, ViewGroup arg1, Bundle arg2) {
        L.i( "In overridden onCreateView.");
        View v = super.onCreateView(arg0, arg1, arg2);
        L.i("Initialising map.");
        initMap();
        return v;
    }

    @Override
    public void onViewCreated (View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        resetButtons();
    }

    private void initMap()
    {
        UiSettings settings = getMap().getUiSettings();
        settings.setAllGesturesEnabled(true);
        settings.setZoomControlsEnabled(false);
        settings.setMyLocationButtonEnabled(true);
//        LatLng latLong = new LatLng(22.320542, 114.185715);
//        getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(latLong, 11));
    }

    /**
     * Move my position button at the bottom of map
     */
    private void resetButtons()
    {
        // Get a reference to the zoom buttons and the position button.
        ViewGroup v1 = (ViewGroup)this.getView();
        ViewGroup v2 = (ViewGroup)v1.getChildAt(0);
        ViewGroup v3 = (ViewGroup)v2.getChildAt(0);
        ViewGroup v4 = (ViewGroup)v3.getChildAt(1);

        // The My Position button
        View position =  (View)v4.getChildAt(0);
        int positionWidth = position.getLayoutParams().width;
        int positionHeight = position.getLayoutParams().height;

        // Lay out the My Position button.
        RelativeLayout.LayoutParams positionParams = new RelativeLayout.LayoutParams(positionWidth,positionHeight);
        int margin = positionWidth/5;
        positionParams.setMargins(0, 0, 0, margin);
        positionParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
        positionParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
        position.setLayoutParams(positionParams);

//        // The Zoom buttons
//        View zoom = (View)v4.getChildAt(2);
//        int zoomWidth = zoom.getLayoutParams().width;
//        int zoomHeight = zoom.getLayoutParams().height;
//
//        // Lay out the Zoom buttons.
//        RelativeLayout.LayoutParams zoomParams = new RelativeLayout.LayoutParams(zoomWidth, zoomHeight);
//        zoomParams.setMargins(0, 0, 0, margin);
//        zoomParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
//        zoomParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
//        zoom.setLayoutParams(zoomParams);
    }

}




Java Source Code List

com.richso.interamap.AuthorizationScreen.java
com.richso.interamap.BaseActivity.java
com.richso.interamap.CategoryScreen.java
com.richso.interamap.HomeScreen.java
com.richso.interamap.MapScreen.java
com.richso.interamap.MoreInfoScreen.java
com.richso.interamap.RegistrationScreen.java
com.richso.interamap.SplashScreen.java
com.richso.interamap.adapter.CategoryAdapter.java
com.richso.interamap.adapter.ImageAdapter.java
com.richso.interamap.adapter.MarkerInfoAdapter.java
com.richso.interamap.dialogue.WarningDialog.java
com.richso.interamap.item.Category.java
com.richso.interamap.item.ItemCategory.java
com.richso.interamap.utils.Constant.java
com.richso.interamap.utils.Device.java
com.richso.interamap.utils.L.java
com.richso.interamap.view.MapFragment.java