Skip to content

Beetrack/maps-factory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

maps-factory

Maps Factory is a abstraction layer for migrate between different maps providers. For the moment only some few methods are implemented for GoogleMap and LeaFletjs. If you want to contribute, any contribution of new missing methods or another layer will be appreciated.

init MapsFactory

//init MapsFactory
var map = new MapsFactory({
  div: "#map_id",
  lat: 45.2,
  lng: 54.3,
  zoom: 13,
  mapType: "Leafletjs" //or GoogleMaps
  });

addMarkers

//return marker object
map.addMarker({
   lat: <latitude (required)>,
   lng: <longitude (required)>,
   infoWindow: <info window content>,
   label: <label text>,
   icon: {
           image: <url path>,
           size: [<width>, <height>],
           sprite_position: [<width>, <height>],
           anchor: [<width>, <height>],
           popup_anchor: [<width>, <height>]
   },
   click: {
             active: <clickable>,
             callback: <click function>
   },
   drag: {
           active: <draggable>,
           callback: <drag end function ( obj = { position: {lat: <float>, lng: <float> } } )>
   }
 });

removeMarker

//input same marker object of addMarker
map.removeMarker(marker);

removeMarkers

map.removeMarkers();

hideInfoWindows

map.hideInfoWindows();

showInfoWindows

map.showInfoWindows(marker);

geocode

map.geocode( {
   input: <html input>,
   callback: <geocode end function ( { result: {lat: <float>, lng: <float>, name: <string> } } , status: "OK" | "ERROR" )>
   search_input: <(optional) html input>
   drag : {
    active: true | false,
    callback: <drag end function { position: {lat: <float>, lng: <float> } } >
   },
   position: {
     lat: lat,
     lng: lng
   }
 }
);

addCircle

map.addCircle( {
 {
   lat: <latitude (required)>,
   lng: <longitude (required)>,
   radius: <circle radius (require)>,
   strokeColor: <stroke color>,
   strokeOpacity: <strike opacity>,
   strokeWeight: <stroke line weight>,
   fillColor: <fill color>,
   fillOpacity: <fill opacity>
 }
);

fitBounds

map.fitBounds( [[40.712, -74.227], [40.774, -74.125]]);

fitBoundsWithMarkers

map.fitBoundsWithMarkers( [<markers objects>]);

drawPolyline

var bounds = [[-33.4205452,-70.5898197],[-32.4205452,-70.5898197],[-34.4105452,-70.5898197],[-32.4505452,-71.5898197]];
//return polyline
var polyline = map.drawPolyline({
  path: bounds,
  strokeColor: 'red',
  strokeOpacity: 1,
  strokeWeight: 3,
  fillColor: '#BBD',
  fillOpacity: 0.2
  });

removePolylines

map.removePolyline(<polyline object>)

examples

  • demo of each map provider on examples folder

Contributing

  • Create a new fork
  • Change only src files
  • Use grunt to change build configuration, add tests, lint-check, etc..

This project uses MIT-LICENSE.

About

Provider-agnostic map layer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •