Posts

Showing posts with the label leaflet

A leaflet template for ionic

Leaflet is a very useful javascript library to insert map into an app. It has lots of extensions, which simplify it's use. I use it mainly in ionic's app, so I have created a repo on GitHub as a start point. It's extends the  side menu template  with leaflet. The key points are: Get a GeoJson  through an api call (markersApi.js) Create a map (with OSM as baselayer). Add the GeoJson to the map (using the  marker-cluster library ). Add a marker on tap. Add the map to the html To add leaflet map in ionic (and angular) there is a directive to simplify it: angular-leaflet-directive  (or you can use ui-leaflet ). In the html you can just put: <leaflet data-tap-disabled="true" defaults="map.defaults" id="map" layers="map.layers" lf-center="map.center"></leaflet> And after you have incluse in the app's model dependencies, the angular-leaflet directive, and have defined an object in the controlle...