지도작업에 많이 사용되는 DatabasePostgreSQL을 설치해 봅니다설치 하면서 PostGIS도 같이 설치를 할 수 있습니다.  PostgreSQL을 다운로드 받을 수 있는 위치는

https://www.enterprisedb.com/downloads/postgres-postgresql-downloads

 

이고 

 

postreSQL PostGIS install

 

운영체제 별로 선택해서 다운로드를 받으면 됩니다여기서는 윈도우즈 버전을 설치 하며 다운받은 파일을 실행 합니다.

 

postreSQL PostGIS install

 

MS Visual C++ 라이브러리를 필요로 해서 없는 컴퓨터에는 자동으로 먼저 설치를 진행 합니다.

 

postreSQL PostGIS install

 

여기서 부터는 거의 Next 버튼을 클릭 하면 됩니다.

 

postreSQL PostGIS install

 

설치 위치를 변경하거나 그냥 Next 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

데이터를 생성할 위치를 선택 하거나 Next 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

여기는 적어야 겠네요비밀 번호를 입력 하고 Next 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

Port 번호를 수정 하거나 그냥 Next 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

지역 설정도 한국이 있지만 그냥 default로 하면 됩니다. Next 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

설치를 위한 환경 설정이 완료 되었습니다이제 설치를 위해 Next 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

설치가 진행 됩니다.

 

postreSQL PostGIS install

 

여기 까지 해서 PostgreSQL 설치가 완료된 것 입니다더이상 추가적인 설치를 하지 않으려면 체크를 해제 하고 Finish 버튼을 클릭 합니다여기서는 PostGIS를 추가 할 것이므로 그냥 Finish 버튼을 클릭해 줍니다.

 

postreSQL PostGIS install

 

Stack Builder 설치에 대한 간략한 안내문 입니다. 콤보박스를 선태해서 PostgreSQL을 선택 하고Next 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

Special Extensions 를 확장하여 PostGIS를 체크 하고 Next 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

다운로드 위치를 설정 하고 Next 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

다운로드가 진행 됩니다.

 

postreSQL PostGIS install

 

설치를 하지 않으려면 체크를 하는데 설치하려고 하는 것이니 그냥 Next 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

라이센스를 확인하고

 

postreSQL PostGIS install

 

설치를 확인 하고 Next 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

설치 위치를 설정 하고 Next 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

이제 설치가 진행 됩니다.

 

postreSQL PostGIS install

 

중간에 3번 물어보는 질문은 예 버튼을 클릭 합니다.

 

postreSQL PostGIS install

 

선택한 PostGIS 설치가 완료 되었습니다.

 

postreSQL PostGIS install

 

최종 Stack Builder 작업이 완료 되었습니다.  PostgreSQL이 잘 설치 되었는지 확이해 봅니다.

 

postreSQL PostGIS install

 

잘 설치가 완료 되었습니다.

 

- copy coding -


Eclipse에서 Oracle 데이터베이스 연결을 테스트 하기 위해 Data Source Explorer를 이용하는 방법에 대해 알아 봅니다프로젝트에서 환경 설정 값을 이용하여 테스트 하는 방법도 있지만 DB 접속을 위한 프로그램을 완성 하고 나서 디버깅을 해야만 데이터베이스에 접속이 되는지 아닌지 확인할 수 있지만 Data Source Explorer를 사용하면 설정 값만 사용하여 접속이 잘 되었는지 확인이 가능하고 테스트한 설정 값을 Project에 그대로 적용하기만 하면 별도로 접속 테스트 없이 DB 작업이 가능합니다.

 

먼저 이클립스 네비게이터 영역에 Data Source Explorer를 포함해 봅니다.

Window > Show View > Data Source Explorer

메뉴를 선택 합니다.



Eclipse Data Source Explorer Oracle


만약 Show View 메뉴에서 Data Source Explorer가 보이지 않는다면 하단의 Other...를 선택하여 팝업 메뉴 창을 오픈 합니다.


Eclipse Data Source Explorer Oracle


이곳에서 Data Source Explorer를 찾아 클릭 하면 됩니다.


Eclipse Data Source Explorer Oracle


그러면 좌측 네비게이터 창에 탭으로 추가된 것을 볼 수 있습니다이제 Database를 추가하기 위해 Database Connections에 마우스를 대고 우측 버튼 클릭을 합니다.


Eclipse Data Source Explorer Oracle


팝업 메뉴에서 New...를 선택해 줍니다.


Eclipse Data Source Explorer Oracle


Oracle을 사용하려고 하기 때문에 Oracle을 선택 하고 Name은 임의대로 입력 해도 됩니다이름을 입력 했다면 Next 버튼을 클릭 합니다.


Eclipse Data Source Explorer Oracle


아직 연결을 위한 드라이버가 하나도 생성되어 있지 않아 콤보박스에 선택을 할 수 없고 Drivers 입력란 우측에 있는 원안의 별표를 클릭 합니다.


Eclipse Data Source Explorer Oracle


Name/Type 탭에서 사용하려는 오라클 버전을 선택 합니다저는 사용하려는 버전이 11g이므로11을 선택 했습니다다음으로 JAR List 탭을 선택 합니다.


Eclipse Data Source Explorer Oracle


기본값이 설정되어 있지만 자신이 설치한 오라클에 적합한 jar 파일을 선택해야 합니다. 저는 11g XE 버전을 사용 중 이고 Add JAR/Zip... 버튼을 클릭해서 설치한 oracle 폴더로 이동 해보면

 

C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib

 

이 폴더에 드라이버 파일이 있습니다


Eclipse Data Source Explorer Oracle


여기서는 ojdbc6.jar를 선택 합니다.  그리고 기존에 있던 ojdbc14.jar는 Remove JAR/Zip 버튼을 클릭하여 리스트에서 삭제처리 합니다.


Eclipse Data Source Explorer Oracle


이제 OK 버튼이 활성화 되어 클릭 할 수 있습니다. 클릭 하면 profile 입력 창이 보입니다.


Eclipse Data Source Explorer Oracle


database에 접속을 위한 정보를 입력하고 Test Connection 버튼을 클릭하여 접속 테스트를 진행 합니다.


Eclipse Data Source Explorer Oracle


설정 값에 이상이 없고 연결도 잘 되었습니다. Finish 버튼을 클릭하여 연결 테스트를 종료 합니다만일 설정된 정보를 확인하려면 Next 버튼을 클릭하면 됩니다.


Eclipse Data Source Explorer Oracle


현재 설정된 상세 정보를 볼 수 있고 수정이 필요하면 Back 버튼으로 수정을 하고 테스트를 종료 하려면 Finish 버튼을 클릭 합니다.


Eclipse Data Source Explorer Oracle


데이터베이스 접속 테스트가 성공 하였으니 접속 정보를 위와 같이 프로젝트 설정에 사용하면 DB 접속은 오류 없이 진행 됩니다.


- copy coding -


핸드폰에 안드로이드로 구글 지도를 표시하려고 하는데 빈 화면만 나오는 경우가 있습니다개발을 하면서 소스를 다른 컴퓨터에 복사해서 사용하는 경우 또는 google api에 패키지를 등록할 때 깜빡 하고 저장 버튼을 누르지 않은 경우 발생할 수 있습니다.


android google map blank


이런 경우 오류 메시지를 살펴보면


android google map blank


D/OpenGLRenderer: Swap behavior 0

E/Google Maps Android API: Authorization failure.  Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.

E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)

    Ensure that the "Google Maps Android API v2" is enabled.

    Ensure that the following Android Key exists:

          API Key: AIXxXxXxXXxXxXxXXXXXXxXXXXxXXXXXXXXN_L8

          Android Application (<cert_fingerprint>;<package_name>): 56:C8:12:AA:AA:AA:AA:AA: AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:AA:A4:B8;copycoding.tistory.gpsmap

D/EGL_emulation: eglCreateContext: 0xa2605f00: maj 2 min 0 rcv 2

D/EGL_emulation: eglMakeCurrent: 0xa2605f00: ver 2 0 (tinfo 0xa26034f0)


API Key는 있지만 패키지에 연결된 SHA-1 값이 맞지 않아 인증 실패가 되었다는 메시지 입니다.

패키지를 등록 할 떄


android google map blank


항목 추가를 누르고 패키지와 SHA-1 지문을 입력하고 완료 만 누르면 반영이 되지 않습니다.


android google map blank


하단에 저장 버튼이 있어서 이것까지 눌려야 입력한 패키지가 반영이 됩니다만일 작업 컴퓨터가 변경이 되었다면 keytool로 다시 설치해서 SHA-1 값을 변경해서 저장하면 됩니다.


android google map blank


그러면 이번에는 지도가 잘 보입니다.


- copy coding -


구글에서 제공하는 안드로이드 용 지도 앱(단순히 정해준 위치의 지도를 보여주는 기능) 사용하기 예제를 이용하여 테스트 하고 사용 방법을 익혀 봅니다아주 단순하고 간단하게 만들어 볼 수 있습니다. 웹 주소는

https://developers.google.com/maps/documentation/android-sdk/start


이곳으로 여기에 가면 소스를 그대로 복사해서 테스트 해 볼 수 있습니다웹 페이지에 나와있는 순서대로 작업을 해봅니다물론 순서는 편리에 따라 바꾸어도 상관 없습니다.

 

Step 1. Download Android Studio


https://developer.android.com/studio/index.html


android google map sdk


자신의 운영체제에 맞는 패키지를 다운받아 설치 합니다. 현재 3.5버전 이고 다른 버전이라도 설치되어 있으면 패스. 저는 업데이트 했습니다.

 

Step 2. Install the Google Play services SDK


안드로이드 스튜디오 메뉴에서 팝업 창을 열고

Tools > SDK Manager > Appearance & Behavior > System Settings > Android SDK

우측에서 SDK Tools 탭을 선택 합니다.


android google map sdk


Google Play services 를 체크하여 설치 합니다기존에 설치를 했으면 패스.

 

Step 3. Create a Google Maps project


그냥 생각 나는 이름으로 프로젝트를 하나 생성 합니다.

Activityempty를 선택하고 생성 했습니다.


android google map sdk


Package nameAPI 사이트에 등록을 해야 하니 적당하게 입력 합니다저는 copycoding.tistory.mylocation으로 했습니다.


android google map sdk


Step 4. Get a Google Maps API key


구글에서 API를 사용할 수 있는 키를 생성 합니다. 그리고 package name을 이용하여 등록을 합니다.  기존에 생성한 API 키가 있다면 package name만 신규로 등록 합니다키 생성 방법은 검색하면 자세한 설명들이 바글바글 합니다저도 하나 설명한게 있습니다.

[안드로이드] google map 사용을 위한 API 생성(2018.11)


android google map sdk


Step 5. Hello Map! Take a look at the code


이제 프로젝트에 사이트에 있는 소스를 복사해서 붙여 넣기를 합니다사이트에는 두개의 소스가 있습니다.

 

activity_main.xml

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
   
xmlns:tools="http://schemas.android.com/tools"
   
android:layout_width="match_parent"
   
android:layout_height="match_parent"
   
android:id="@+id/map"
   
tools:context=".MapsActivity"
   
android:name="com.google.android.gms.maps.SupportMapFragment" />

 

MainActivity.java

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

   
private GoogleMap mMap;

   
@Override
   
protected void onCreate(Bundle savedInstanceState) {
       
super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);
       
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(
this);
    }

   
@Override
   
public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

       
// Add a marker in Sydney, Australia, and move the camera.
       
LatLng sydney = new LatLng(-34, 151);
        mMap.addMarker(
new MarkerOptions().position(sydney).title("Marker in Sydney"));
        mMap.moveCamera(
CameraUpdateFactory.newLatLng(sydney));
    }
}

 

이 두가지로만 하면 오류가 발생 합니다.

사이트에 없지만 추가를 해야 하는 항목이 두개 있습니다간단해서 생략 했을 수도 있습니다.


AndroidManifest.xml

<meta-data
   
android:name="com.google.android.geo.API_KEY"
   
android:value="API 키 값" >
</
meta-data>

Step 4에서 생성한 API 키를 입력 합니다.

 

build.gradle(Module: app)

implementation 'com.google.android.gms:play-services-maps:10.2.0'

라이브러리도 추가 해줍니다.

 

Step 6. Connect an Android device


테스트를 진행하기 위해 가상 디바이스를 생성 하거나 실제 핸드폰을 연결 합니다


android google map sdk


Step 7. Build and run your app


이제 프로그램을 실행 하기만 하면 끝 입니다.


android google map sdk


GPS를 이용 하는게 아니라서 방구석 처밖혀 인터넷만 연결되면 테스트가 가능 합니다.

줌 기능을 추가하지 않아 그냥 세계지도를 보는 느낌이네요.

 

전체 소스

 

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
   
xmlns:app="http://schemas.android.com/apk/res-auto"
   
xmlns:tools="http://schemas.android.com/tools"
   
android:layout_width="match_parent"
   
android:layout_height="match_parent"
   
tools:context=".MainActivity">

    <fragment
xmlns:android="http://schemas.android.com/apk/res/android"
       
xmlns:tools="http://schemas.android.com/tools"
       
android:layout_width="match_parent"
       
android:layout_height="match_parent"
       
android:id="@+id/map"
       
tools:context=".MapsActivity"
       
android:name="com.google.android.gms.maps.SupportMapFragment" />

</androidx.constraintlayout.widget.ConstraintLayout>

 

 

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
   
package="copycoding.tistory.gpsmap">
    <application
       
android:allowBackup="true"
       
android:icon="@mipmap/ic_launcher"
       
android:label="@string/app_name"
       
android:roundIcon="@mipmap/ic_launcher_round"
       
android:supportsRtl="true"
       
android:theme="@style/AppTheme">

        <meta-data
           
android:name="com.google.android.geo.API_KEY"
           
android:value="API Key "/>
        <activity
android:name=".MainActivity">
            <intent-filter>
                <action
android:name="android.intent.action.MAIN" />

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

</manifest>

 

 

build.gradle(Module: app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion
29
   
buildToolsVersion '29.0.2'
   
defaultConfig {
        applicationId
"copycoding.tistory.gpsmap"
       
minSdkVersion 16
        
targetSdkVersion 29
       
versionCode 1
       
versionName "1.0"
       
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
   
}
    buildTypes {
        release {
           
minifyEnabled false
           
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
       
}
    }
}

dependencies {
    implementation fileTree(
dir: 'libs', include: ['*.jar'])
    implementation
'androidx.appcompat:appcompat:1.1.0'
   
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
   
implementation 'com.google.android.gms:play-services-maps:10.2.0'
   
testImplementation 'junit:junit:4.12'
   
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
   
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

 

 

 

 

MainActivity.java

package copycoding.tistory.mylocation;

import
androidx.appcompat.app.AppCompatActivity;
import
androidx.fragment.app.FragmentActivity;

import
android.os.Bundle;

import
com.google.android.gms.maps.CameraUpdateFactory;
import
com.google.android.gms.maps.GoogleMap;
import
com.google.android.gms.maps.OnMapReadyCallback;
import
com.google.android.gms.maps.SupportMapFragment;
import
com.google.android.gms.maps.model.LatLng;
import
com.google.android.gms.maps.model.MarkerOptions;

public class
MainActivity extends FragmentActivity implements OnMapReadyCallback {

   
private GoogleMap mMap;

   
@Override
   
protected void onCreate(Bundle savedInstanceState) {
       
super.onCreate(savedInstanceState);
       
setContentView(R.layout.activity_main);

       
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.
map);
       
mapFragment.getMapAsync(this);
   
}

   
@Override
   
public void onMapReady(GoogleMap googleMap) {
       
mMap = googleMap;

       
// Add a marker in Sydney, Australia, and move the camera.
       
LatLng sydney = new LatLng(-34, 151);
       
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
       
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
   
}
}

 

 - copy coding -


1···51525354555657···118

+ Recent posts