Giter Site home page Giter Site logo

vue-naver-maps's Introduction

vue-naver-maps

npm npm npm npm npm

설명

vue-naver-mapsNaver Maps JavaScript API v3 을 Vue.js에서 간편하게 이용하게 할 수 있는 라이브러리입니다.
라이브러리가 로딩되지 않는 상태라도 이용할 수 있도록 제작되었습니다.

어떤한 케이스에서라도, 정상적으로 동작하지 않는 오류가 발생하는 경우에는 아래의 해결책을 시도해보세요. 먼저, onload이벤트로 map 객체를 받으세요. 그 다음, map 객체에 직접 접근하여 명령을 실행하시면 가능합니다.

문서

Docs 에는 vue-naver-maps의 객체 명세서 및 도움말, 예제가 있습니다.

라이선스

이 프로젝트의 라이선스는 MIT License 입니다.

안내

최근 Naver Maps JavaScript API v3의 업데이트로 오류가 발생하는 경우가 있습니다. 항상 최신버전을 유지하시는 것을 권장드립니다. 또한, 새로 추가된 기능이나 정상적으로 동작하지 않는 기능의 경우에는 직접 지도 객체에 접근하여 사용하시기 바랍니다.

업데이트

  • Vue.js 3.0 지원
  • TypeScript 지원(Vue.js 3.0 지원과 연동)

업데이트 목록

ChangeLog 를 참조하세요.

오류 발생시

오류 발생시 해결 커밋을 PR 남겨주시면 감사하겠습니다.

vue-naver-maps's People

Contributors

dependabot[bot] avatar devhun avatar dongkyuuuu avatar graup avatar hojinzs avatar jjangga0214 avatar shin-jaeheon avatar ssshow16 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vue-naver-maps's Issues

naver.maps.Map의 init 이벤트 관련

안녕하세요.
좋은 모듈을 배포해주셔서 감사합니다.

naver-map 컴포넌트에 naver.maps.Map에 정의된 다른 이벤트들을 호출하면 동작이 잘 됐는데
init 이벤트는 응답이 없어서 소스를 보니 Map.vue 파일에 init 이벤트 대신 init_stylemap 이벤트가 등록되어있는 것으로 보입니다.
아마 언젠가 이벤트명이 변경됐을 것으로 예상되는데요,
확인 부탁드립니다.

mapOption 에 lat, lng 값이 0 일 때 오류

  1. lat, lng 값을 0으로 두고 map 그리기 시도하면 다음과 같이 필수 값 에러 뜹니다.
    ex) <naver-maps :height="400" :width="600" :map-options="{lat:0,lng:0,zoom:10}" />
    console 에러 문구 :
    [Global Error Handler]: Error in: mounted hook: Error: mapOptions must be included lat and lng.
    (0.00001 값이라도 넣음 에러 사라지긴합니다)

  2. 추가로 https://shin-jaeheon.github.io/vue-naver-maps/#/kr/naver-maps
    위 문서에서 width 및 height, mapOptions는 필수입니다. 라고 되어있는데 initLayers 를 넣지 않으면 map 이 그려지지 않습니다.
    initLayers 안넣을 경우 console 에러 문구 :

Uncaught TypeError: Cannot read property 'map' of undefined
    at VueComponent.loadNaverMapsComponents (Map.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options:383)
    at i (maps.js?ncpClientId=zmuxox5od7:15)
    at exec (maps.js?ncpClientId=zmuxox5od7:15)
    at e.<anonymous> (maps.js?ncpClientId=zmuxox5od7:15)
    at sentryWrapped (helpers.js:72)

useStyleMap 사용시 에러


TypeError: Cannot read property 'getMapTypes' of undefined
    at eval (Map.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options:371)
    at new Promise ()
    at VueComponent.loadNaverMapsComponents (Map.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options:342)
    at VueComponent.mounted (Map.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options:421)
    at invokeWithErrorHandling (vue.esm.js?a026:1863)
    at callHook (vue.esm.js?a026:4228)
    at Object.insert (vue.esm.js?a026:3148)
    at invokeInsertHook (vue.esm.js?a026:6357)
    at VueComponent.patch [as __patch__] (vue.esm.js?a026:6576)
    at VueComponent.Vue._update (vue.esm.js?a026:3957)

useStyleMap 옵션 사용시 해당 에러 발생합니다.

window.naver.maps.StyleMapTypeOption 에서
window.naver.maps.NaverStyleMapTypeOption 로 변경된 것 같네요.

[Bug] Naver.map Touch Drag

Touch Drag로 지도 중심 좌표를 이동시킬 때
지도 밖의 빈 공간을 Drag해도 지도가 움직여 페이지 스크롤에 불편함이 있습니다.

네이버 클라우드 아이디 등록할 수 있게 해주세요

클라우드 서비스 이용할 때 주소입니다.

<script type="text/javascript" src="https://openapi.map.naver.com/openapi/v3/maps.js?ncpClientId=YOUR_CLIENT_ID"></script>

현재
Vue.use(naver, {
ncpClientID: '등록된 아이디',
useOpenAPI: true
})
변경해도 안되네요

Make components react to prop changes

Most of the components' props are not reactive, they only get applied on initial render (for example polyline's path and options). We should add some watchers to adapt the rendered Naver components according to changes on the props.

Vue.use 오류

Uncaught Error: Sorry, this plugin is only available in browsers at now. If you are using Nuxt.js, turn off ssr for this plugin.

�개발자도구 콘솔에 위와 같은 오류가 발생하며 모듈 사용이 불가능합니다.

vue-cli 를 사용하여

vue create 로 프로젝트 생성하고 npm install vue-naver-maps 해서 생성한 새 프로젝트 입니다.

버전은 아래와 같습니다.
vue : ^2.6.14
vue-naver-maps : ^0.14.5

아래는 오류가 발생한 개발자도구 스크린샷 입니다.
스크린샷 2023-05-02 오전 8 30 51

간헐적으로 아래와 같은 오류가 발생합니다.

Error in callback for watcher "lat": "TypeError: Cannot read property 'setPosition' of null"

타이밍 이슈 같은데 해결방법을 모르겠네요 ㅠㅜ
데이터를 비동기로 불러와서 사용하는데
지도가 데이터 보다 먼저 그려져서 생기는 문제 같습니다.
데이터 이후에 지도가 다시 그려지거나 데이터 불러오는 동안 지도 그려지는걸 멈추는 방법이 있을까요?

지도상의 여러개의 marker를 사용하는 예제가 필요합니다.

https://shin-jaeheon.github.io/vue-naver-maps/?spm=a2c6h.14275010.0.0.392417c5i6Rdw2#/?id=example
위 예제를 참조해서
<naver-maps
:height="height"
:width="width"
:mapOptions="mapOptions"
:initLayers="initLayers"
@load="onLoad">
<naver-info-window
class="info-window"
@load="onWindowLoad"
:isOpen="info"
:marker="marker">

<naver-marker :lat="37.5566668" :lng="126.924825" @click="onMarkerClicked" @load="onMarkerLoaded"/>
<naver-marker :lat="37.5566668" :lng="126.913825" @click="onMarkerClicked" @load="onMarkerLoaded"/>

naver-marker를 이용하여 마커를 화면에 보일 수 있는데요, 외부로 부터 마커 위치와 정보에 대한 json 데이터를 받아서 마커를 표시하고 싶습니다.
그래서 대신 :marker="marker"를 이용하려고,

<script> 아래에 marker: null 이 부분에 marker 정보에 대한 배열을 넣어서 화면에 보여지게 하고 싶습니다. 예제를 받아볼 수 있을까요?

버튼을 클릭했을 때 마커를 초기화 하거나 추가하고 싶어요.

<template>
  <v-card flat>
    <v-toolbar dark color="primary" >
      <v-toolbar-side-icon></v-toolbar-side-icon>
      <v-toolbar-title class="white--text">모니터링</v-toolbar-title>
      <v-spacer></v-spacer>     
      <v-text-field :value="train" placeholder="999" clearable> </v-text-field>
      <v-btn flat @click="to_current" >현재</v-btn>
    </v-toolbar>
    <naver-maps :width="map_width" :height="map_height" :mapOptions="mapOptions" @load="onMapLoad" >
      <div v-for="mark in marker_coords" :key="mark.index"> 
        <naver-marker :lat="mark.lat" :lng="mark.lng" @click="onMarkerClicked(mark.index)" @load="onMarkerLoad"/>
        <naver-info-window :isOpen="isOpen" :marker="marker" @load="onInfoLoad" >
          <h3>{{ info_msg }}</h3>
        </naver-info-window>
      </div>  
    </naver-maps> 
  </v-card>
</template>
<script>
export default {
  name: 'NaverMap',
  data() {
    return {
      map: null,
      train: "999",
      isOpen: false,
      infos: [
        {msg: "07:05:22"},
        {msg: "07:55:15"}
      ],
      info_msg: "",
      marker: null,
      marker_list: [],
      marker_coords: [
        {index: 0, lat: 36.331997, lng: 127.435926},
        {index: 1, lat: 35.878825, lng: 128.628072}
      ],
      map_width: 600,
      map_height: 400,
      mapOptions: {
        zoom: 3,
        lat: 36.331997,
        lng: 127.435926,
        zoomControl: false,
        zoomControlOptions: {
          position: 1
        }
      }
    }
  },
  created() {
    window.addEventListener('resize', this.handelResize);
    this.handelResize();
  },
  destroyed() {
    window.removeEventListener('resize', this.handelResize);
  },
  methods: {
    onMapLoad(map) {
      this.map = map;
    },
    onMarkerLoad(vue) {
      this.marker = vue.marker;
      this.marker_list.push(this.marker);
    },
    onInfoLoad(that) {
    },
    onMarkerClicked(index) {
      this.marker = this.marker_list[index];
      this.info_msg = this.infos[index].msg;
      this.isOpen = !this.isOpen;
    },
    handelResize() {
      this.map_width = window.innerWidth;
      this.map_height = window.innerHeight;
    },
    to_current() {
      // 하나 추가
      this.marker_coords.push({index: 2, lat: 35.873452, lng: 128.658072});
      console.log("marker_coords count -> " + this.marker_coords.length);
    }
  }
}
</script>

현재 버튼을 클릭하면 마커를 하나 더 추가하고 싶습니다.
또는 현재 마커를 전부 삭제하고 새로 생성하고 싶어요.
위코드를 작성했는데 마커가 생기지 않고 있습니다.
v-for 의 :key 값이 변경되면 그 하위 마커와 인포윈도우는 자동으로 변경되는줄 알았는데 그러지 않네요
도와주세요.

naver-info-window component 의 isOpen props 에러

templete 에는 도큐먼트에 안내된 바와 같이 아래처럼 적고,
<naver-info-window class="info-window" @load="onWindowLoad" :isOpen="info" :marker="marker"> </naver-info-window>
data 에 info 는 true 로 주었더니 다음의 에러가 떴습니다.

[Vue warn]: Error in callback for watcher "isOpen": "Error: position or anchor should be assigned." found in ---> <InfoWindow> at src/InfoWindow.vue <Map> at src/Map.vue <DetailInfo> at src/components/DetailInfo.vue <Detail> at src/pages/Detail.vue <VContent> <VApp> <App> at src/App.vue <Root>

Error: position or anchor should be assigned. at n.InfoWindow.open (maps.js?ncpClientId=5qehk43mhz:14) at VueComponent.isOpen (InfoWindow.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options:20) at Watcher.run (vue.runtime.esm.js?2b0e:4568) at flushSchedulerQueue (vue.runtime.esm.js?2b0e:4310) at Array.eval (vue.runtime.esm.js?2b0e:1980) at flushCallbacks (vue.runtime.esm.js?2b0e:1906)

포지션 또는 앵커를 할당하라고 하는데 도큐먼트에는 Boolean 값만 넣으면 되는 것 처럼 나와있거든요..
어떻게 수정하면 정보창을 사용할 수 있습니까?

[Bug] Webpack 4 -> 5

저희 프로젝트에서는 WEBPACK 4 를 사용중인데, 이번 0.14.4 업데이트 인 webpack 버전이 업그레이드 되며 오류가 발생하고 있습니다.
vue-naver-maps 를 0.14.3 으로 강제설치 하게하여 오류는 해결 했습니다만 webpack 버전의 경우 patch 버전이 아닌 minor 또는 major 버전의 증가가 되야 하지 않을까 싶습니다.

마커이미지, InfoWindow문의 드립니다.

마커이미지
this.maker_List[this.Maker_Count]= vue.marker;
this.maker_List[this.Maker_Count].setTitle(this.Maker_Count);
this.tableSelect[this.Maker_Count]=0;
//this.maker_List[this.Maker_Count].setIcon("http://static.naver.com/maps2/icons/pin_spot3.png");
this.maker_List[this.Maker_Count].setIcon("@/assets/images/taxi.png");
주석처리된 네이버에서 지원하는 마커이미지 Icon은 잘 됩니다.
현재 사용하고싶은 이미지가 있는데 이런식의 로컬에서 가지고와서 적용하는건 안되는지
만약 된다면 저기 코드가 왜 안되는지 알려주시면 감사하겠습니다.

InfoWindow
this.map_infoWindow.setPosition(this.marker_select.getPosition());
현재 InfoWindow 는 n.LatLng의 값으로만 위치를 변경할수 있습니다.
그 이외의 값은 최소 한번만 처리 되고 그 후 처리가 안됩니다. (마커 2개를 가지고 InfoWindow를 움직이시면 에러상황 나올꺼라고 생각합니다.)
처음 마커를 생성할때
<naver-marker :lat=templat :lng=templng
@click="ListMarkerClicked(index)" @load="TempMarkerLoaded" >
이런식의 코드가 되는데 여기서 생성방법이 n.LatLng값으로 셋팅됩니다.

전체 코드
전체 코드 메일 적어주시면 보내드리겠습니다.

naver-info-window 문의 드립니다.

<template>
  <div>
    <naver-maps
      :width="map_width"
      :height="map_height"
      :mapOptions="mapOptions"
      :initLayers="initLayers"
      @load="onLoad"
    >
      <naver-info-window
        class="info-window"
        :isOpen="isOpen"
        :marker="marker"
        @load="onInfoLoad"
      >
        <div class="info-window-container">
          <h3>{{ info_msg }}</h3>
        </div>
      </naver-info-window>
      <div v-for="mark in marker_coords" :key="mark.index">
        <naver-marker
          :lat="mark.lat"
          :lng="mark.lng"
          @click="onMarkerClicked(mark.index)"
          @load="onMarkerLoad"
        />
      </div>
    </naver-maps>
  </div>
</template>
<script>

위 소스에서 마커를 클릭 시 해당 이벤트 isOpen = true 로 변경되는 것은 확인 되었으나
naver-info-window 창이 뜨지 않습니다.
마커의 이벤트는 동작하는것으로 보아 naver-info-window (InfoWindow.vue) 의 이벤트가 나타나지 않는것 같습니다.
문서 상의 예제 소스로도 실행해본 결과 마커 클릭 시 창이 뜨지않습니다.

전체 코드
전체 코드 메일 적어주시면 보내드리겠습니다.

naver-maps without property mapOptions doesn't work

My Code

<naver-maps :width="600" :height="400"></naver-maps>

Error Message

[Vue warn]: Error in mounted hook: "TypeError: this.mapOptions is undefined"

found in

---> <Map> at src/Map.vue
       <Home> at src/views/Home.vue
         <App> at src/App.vue
           <Root> vue.runtime.esm.js:619

TypeError: "this.mapOptions is undefined"
    mounted Map.vue:406
    VueJS 11
    <anonymous> main.js:13
    js app.js:2273
    __webpack_require__ app.js:767
    fn app.js:130
    0 app.js:2346
    __webpack_require__ app.js:767
    <anonymous> app.js:902
    <anonymous> app.js:1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.