1.1.4 • Published 6 years ago

easy-map v1.1.4

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

easy-map

🌏 Render a map on browser easily.

installation

Just download the js and include it in your HTML.

<!-- add easy.map in your html -->
<script type="text/javascript" src="PATH/TO/easy-map.min.js"></script>

<!-- if you use AMD or CommonJS -->
<script>
  require(["PATH/TO/easy-map"], function (EasyMap) {
    // Do something..
  });

  /* or */

  var EasyMap = require("easy-map");
</script>

NPM

$ yarn add easy-map
# or
$ npm i easy-map

Demo

$ npm run demo
# then access http://127.0.0.1:7777

How to use

Prerequisite

Parameters

ParameterTypeRemarks
mapTypestringRequired (It must be included in ['google'])
elementDOM NodeRequired
keystringRequired
sourceobjectSpecific location's information
source.latnumberSpecific location's latitude
source.lngnumberSpecific location's longitude
source.markerobjectMarker on Specific location
source.marker.iconstringWrite icon image's path
source.marker.widthnumberMarker's width (px)
source.marker.heightnumberMarker's height (px)
source.marker.verticalAlignstringtop, bottom, middle
source.marker.horizontalAlignstringright, left, center
source.infoWindowobjectMarker's infoWindow
source.infoWindow.contentstringinfoWindow's content
source.infoWindow.maxWidthnumberinfoWindow's max width (px)
source.infoWindow.isOpenbooleaninitial open status of source's infoWindow
source.infoWindow.backgroundColorstringinfoWindow's background color (hex code or color name)ONLY FOR NAVER
source.infoWindow.borderColorstringinfoWindow's border color (hex code or color name)ONLY FOR NAVER
source.infoWindow.borderWidthnumberinfoWindow's border width (px)ONLY FOR NAVER
source.infoWindow.anchorSizeobjectinfoWindow's anchor widthnew naver.maps.Size(30, 30)ONLY FOR NAVER
source.infoWindow.anchorSkewbooleaninfoWindow's anchor shapeONLY FOR NAVER
source.infoWindow.pixelOffsetobjectinfoWindow's offsetnew naver.maps.Point(20, -20)ONLY FOR NAVER
coordsarraySet of coordinates
coordsnobjectSame as source
closeInfoWindowAutobooleanClose automately when click a marker
clickedNestedMarkerfunctionCallback function when click nested markers
---
coordsn.infoWindow.contentstringIf you write {{distance m}}, you can get the distance between cooresn and sourceAvailable unites : m, km, ft, yd

Basic Usage

Google Map

const easyMap = new EasyMap({
  mapType: 'google',
  key: 'AIzaSyBL4Ugej1KvkfIrU2qOhoAkE85rKEcTApo',
  element: document.getElementById('map'),
  source: {
    lat: 37.5666103,
    lng: 126.9783882,
    marker: { icon: '//assets-cdn.github.com/images/modules/contact/heartocat.png', width: 48, height: 48, verticalAlign: 'top' },
    infoWindow: { content: '<div class="info-window">Source Marker</div>', maxWidth: 50 },
  },
  coords: [{
    lat: 37.5658528,
    lng: 126.9779845,
    name: 'Marker 1',
    marker: { icon: '//assets-cdn.github.com/images/modules/contact/heartocat.png', width: 36, height: 36, verticalAlign: 'middle' },
    infoWindow: { content: '<div class="info-window">Marker 1<br>distance is {{distance m}}</div>', maxWidth: 50 },
  }, {
    lat: 37.5658528,
    lng: 126.9779845,
    name: 'Marker 2',
    marker: { icon: '//assets-cdn.github.com/images/modules/contact/heartocat.png', width: 36, height: 36, verticalAlign: 'middle' },
    infoWindow: { content: '<div class="info-window">Marker 2<br>distance is {{distance km}}</div>', maxWidth: 50 },
  }],
  closeInfoWindowAuto: true,
  clickedNestedMarker: (cb, ids, strs) => {
    const userInput = prompt(`You clicked nested markers! Select on.\n${strs}`, '');

    cb(+userInput);
  },
});

easyMap.start();

Naver Map

const easyMap = new EasyMap({
  mapType: 'naver',
  key: 'ZINRRHtKwGpXNxXjcqwv',
  element: document.getElementById('map'),
  source: {
    lat: 37.5666103,
    lng: 126.9783882,
    marker: { icon: '//assets-cdn.github.com/images/modules/contact/heartocat.png', width: 48, height: 48, verticalAlign: 'top' },
    infoWindow: { content: '<div class="info-window">Source Marker</div>', maxWidth: 50 },
  },
  coords: [{
    lat: 37.5658528,
    lng: 126.9779845,
    name: 'Marker 1',
    marker: { icon: '//assets-cdn.github.com/images/modules/contact/heartocat.png', width: 36, height: 36, verticalAlign: 'middle' },
    infoWindow: { content: '<div class="info-window">Marker 1<br>distance is {{distance m}}</div>', maxWidth: 50 },
  }, {
    lat: 37.5658528,
    lng: 126.9779845,
    name: 'Marker 2',
    marker: { icon: '//assets-cdn.github.com/images/modules/contact/heartocat.png', width: 36, height: 36, verticalAlign: 'middle' },
    infoWindow: { content: '<div class="info-window">Marker 2<br>distance is {{distance km}}</div>', maxWidth: 50 },
  }],
  closeInfoWindowAuto: true,
  clickedNestedMarker: (cb, ids, strs) => {
    const userInput = prompt(`You clicked nested markers! Select on.\n${ strs }`, '');

    cb(+userInput);
  },
});

easyMap.start();

Browsers support

Google Maps

Naver Maps

Change log

1.0.0

  • Initial release

1.0.2

  • Add naver map
  • Bug fix

1.0.3

  • Bug fix
  • Change coding styles in switch-case (Use braces in switch-case).

1.1.0

  • Refactoring

1.1.2

  • Re-configure Webpack

1.1.4

  • Add daum map

Licence

Copyright (c) 2017 wonism

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago