Skip to content

Instantly share code, notes, and snippets.

@DrSensor
Last active July 6, 2017 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrSensor/79a6ef13047e585de598667b0a95c2df to your computer and use it in GitHub Desktop.
Save DrSensor/79a6ef13047e585de598667b0a95c2df to your computer and use it in GitHub Desktop.
[WIP] Helper script for loading Leaflet to Ionic 2
import lxml.html
def add_css_code(webpageString, linkString):
root = lxml.html.fromstring(webpageString)
link = lxml.html.fromstring(linkString).find('.//link')
head = root.find('.//head')
title = head.find('title')
if title == None:
where = 0
else:
where = head.index(title) + 1
head.insert(where, link)
return lxml.html.tostring(root)
webpageString1 = "<html><head><title>test</title></head><body>webpage content</body></html>"
webpageString2 = "<html><head></head><body>webpage content</body></html>"
linkString = "<link rel='stylesheet' type='text/css'>"
print(add_css_code(webpageString1, linkString))
print(add_css_code(webpageString2, linkString))

ionic start

ionic start ionic2-map-leaflet tabs --v2


add leaflet lib

mkdir src/assets/images/

cp node_modules/leaflet/dist/leaflet.css src/assets

cp node_modules/leaflet/dist/images/* src/assets/images


add page to show map

ionic g page map

update 'src/pages/map/*'

update 'src/pages/tabs/*'

update declarations, entryComponents in 'app.module.ts'

include external leaflet.css from assets into 'index.html'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment