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
var map = new MapsFactory({
div: "#map_id",
lat: 45.2,
lng: 54.3,
zoom: 13,
mapType: "Leafletjs" //or GoogleMaps
});
//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> } } )>
}
});
//input same marker object of addMarker
map.removeMarker(marker);
map.removeMarkers();
map.hideInfoWindows();
map.showInfoWindows(marker);
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
}
}
);
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>
}
);
map.fitBounds( [[40.712, -74.227], [40.774, -74.125]]);
map.fitBoundsWithMarkers( [<markers objects>]);
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
});
map.removePolyline(<polyline object>)
- demo of each map provider on examples folder
- Create a new fork
- Change only src files
- Use grunt to change build configuration, add tests, lint-check, etc..
This project uses MIT-LICENSE.