1.0.46 • Published 1 year ago

mapmyindia-react-custom-icons v1.0.46

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

MapmyIndia react

React component to implement MapmyIndia Interactive Map API

credits

Please refer @khotharish1207 (https://github.com/khotharish1207/mapmyindia-react) for original Repo I have just Modified below part of the code so that user can add Custom icons (dist/Map.js)

 var icon=L.divIcon(
        { className: "custom icon",
        html: ReactDOMServer.renderToString(m.icon_url) })

      var mk = new L.Marker(position, {
      draggable: draggable,
      title: title,
      icon:icon
    });
    title && mk.bindPopup(title);
    onDragend && mk.on("dragend", onDragend);
    onClick && mk.on("click", onClick);
    _this.map.addLayer(mk);

    _this.markers.push(mk);

    _this.map.setView(mk.getLatLng());

Getting Started

demo: https://mapmyindia-react-example.herokuapp.com/

Prerequisites

Integrate interactive maps from MapmyIndia into your browser application by simply including MapmyIndia's interactive map API in your script source in the head section.

<script src="https://apis.mapmyindia.com/advancedmaps/v1/<Lic_Key>/map_load?v=1.3"></script>

Installing

npm install mapmyindia-react-custom-icons --save

How to use

import Map from "mapmyindia-react";

class App extends React.Component {
	 render () {
		 return (
		 	 <Map
          markers={[
              {
                  position: [18.5314, 73.845],
                  draggable: true,
                  title: "Marker title",
                  onClick: e => {
                      console.log("clicked ");
                  },
                  onDragend: e => {
                      console.log("dragged");
                  }
              }
          ]}
          />
		 )
	 }
}

Props

proptypedefault value
centerarray18.5314, 73.8446
zoomControlbooltrue
locationbooltrue
heightstring500px
widthstring
zoomnumber15
hybridbooltrue
searchbooltrue
markersarray[]

Example for marker array

  [
    {
      position: [],       // [lat, lng]
      draggable: false,   // true / false
      title: '',          // string
      onClick: () => {},   // Marker click event listener
      onDragend: ()=> {}   // Marker dragend event listener (if draggable is set)
    }
  ]

Map events

Eventdefault value
onResize() => {}
onZoom() => {}
onMove() => {}
onClick() => {}
onDblclick() => {}
onMouseup() => {}
onMousedown() => {}
onMouseover() => {}
onMouseout() => {}
onKeypress() => {}
onMapLoad(mapObject) => {}

Updates

Now you can Pass Html elements or react components to the title prop of marker

title: <h4>{marker title}</h4>

Author

  • Harish S Khot

Updated by

  • Manideep Yelugoti

Acknowledgments

  • MapmyIndia Interactive Map API
1.0.46

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.4

1 year ago

1.0.43

1 year ago

1.0.30

1 year ago

1.0.45

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.27

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.10

2 years ago