Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

easy-map

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy-map

This is a open source project to represent map in your web page easily.

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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

  • You need a Map Key to use map API.
    • You can get the key on Google maps API page

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 width
new naver.maps.Size(30, 30)
ONLY FOR NAVER
source.infoWindow.anchorSkewbooleaninfoWindow's anchor shape
ONLY FOR NAVER
source.infoWindow.pixelOffsetobjectinfoWindow's offset
new naver.maps.Point(20, -20)
ONLY FOR NAVER
coordsarraySet of coordinates
coords[n]objectSame as source
closeInfoWindowAutobooleanClose automately when click a marker
clickedNestedMarkerfunctionCallback function when click nested markers
---
coords[n].infoWindow.contentstringIf you write {{distance m}}, you can get the distance between coores[n] and source
Available 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.

Keywords

FAQs

Package last updated on 16 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc