hi
I'm currently testing brython. I want to create a html page with brython and openlayer3.
Currently I use this link but is what you have an example to use brython and openlayer3 for a simple map.
I try to convert the first exemple for brython: https://openlayers.org/en/latest/doc/quickstart.html
thancks
(excuse me for my bad english)
--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+unsubscribe@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/dfc89a14-515b-46d1-8d16-af8472869dfb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
2017-06-07 15:36 GMT+02:00 jean claude meilland <meill...@gmail.com>:
hi
I'm currently testing brython. I want to create a html page with brython and openlayer3.
Currently I use this link but is what you have an example to use brython and openlayer3 for a simple map.
I try to convert the first exemple for brython: https://openlayers.org/en/latest/doc/quickstart.htmlHi, Jean Claude,Here you have an example I did some time ago using openlayers2:
https://github.com/kikocorreoso/map2wiki/blob/master/src/templates/index.htmlHere you have even a step by step tutorial using OpenLayers2:
https://github.com/kikocorreoso/brythonmagic/blob/master/notebooks/OpenLayers%20(python)%20tutorial.ipynbAdapt the examples to openlayers3 should be quite easy.
Thank you very much kiko, I will look at this.
2017-06-07 18:53 GMT+02:00 Kiko <kikoco...@gmail.com>:2017-06-07 15:36 GMT+02:00 jean claude meilland <meill...@gmail.com>:
hi
I'm currently testing brython. I want to create a html page with brython and openlayer3.
Currently I use this link but is what you have an example to use brython and openlayer3 for a simple map.
I try to convert the first exemple for brython: https://openlayers.org/en/latest/doc/quickstart.htmlHi, Jean Claude,Here you have an example I did some time ago using openlayers2:
https://github.com/kikocorreoso/map2wiki/blob/master/src/templates/index.htmlHere you have even a step by step tutorial using OpenLayers2:
https://github.com/kikocorreoso/brythonmagic/blob/master/notebooks/OpenLayers%20(python)%20tutorial.ipynbAdapt the examples to openlayers3 should be quite easy.It is the brython version of the quick start example here: http://openlayers.org/en/latest/doc/quickstart.htmlI hope it helps.
thancks
(excuse me for my bad english)
--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
I use with vim two expression list:
Here are some feedback.
To convert a javascript map to brython map with OpenLayer I use:
- Add after the <script> tag
import window
ol = window.ol- Remove keyword var
- Put the keyword new at the end
For example we transform
var map = new ol.Map ({
in
map = ol.Map.new(- Edit to have a python dictionary
target: 'map' is replaced by 'target': 'map'- remove getElemenById() replace true with True or false with False etc ....
I use with vim two expression list:
- '<,'>s/^\(.*\)new\([^(]*\)/\1\2\.new/
- '<,'>s/^ *\([^:][^:]*\):/'\1':/g
I have several questions but I will ask them on another thread.
Le mercredi 7 juin 2017 15:36:45 UTC+2, jean claude meilland a écrit :
hi
I'm currently testing brython. I want to create a html page with brython and openlayer3.
Currently I use this link but is what you have an example to use brython and openlayer3 for a simple map.
I try to convert the first exemple for brython: https://openlayers.org/en/latest/doc/quickstart.html
thancks
(excuse me for my bad english)
--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+unsubscribe@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/4ba76c1f-5d6c-4f71-ab22-c0db01a2baff%40googlegroups.com.
It is quite similar in this case but when you have to apply some logics to the script (loops, conditionals,...) you can use a more pythonic interface \o/
map.on('singleclick', function(e) {
var feature = map.forEachFeatureAtPixel(e.pixel, function(feature) {
return feature;
});
var infoElement = document.getElementById('info');
infoElement.innerHTML = feature ? feature.get('title') : '';
});
Here is my example:
Is fonction Lamda?
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="https://www.brython.info/src/brython.js"></script>
<script type="text/javascript" src="https://openlayers.org/en/v4.1.1/build/ol.js"></script>
<link rel="stylesheet" type="text/css" href="https://openlayers.org/en/v4.1.1/css/ol.css">
<style>
#map {
height: 400px;
width: 100%;
}
.ol-attribution a {
color: black;
}
</style>
</head>
<body onload="brython(1)">
<div id="map" class ="map"> </div>
<div id="info"></div>
<script type="text/python">
from browser import window, document
ol = window.ol
tremblement_terre= ol.layer.Vector.new({
'title': 'Earthquakes',
'source': ol.source.Vector.new({
'url': 'https://raw.githubusercontent.com/boundlessgeo/ol3-workshop/master/src/data/layers/7day-M2.5.json',
'format': ol.format.GeoJSON.new()
}),
'style': ol.style.Style.new({
'image': ol.style.Circle.new({
'radius': 3,
'fill': ol.style.Fill.new({'color': 'white'})
})
})
})
map = ol.Map.new({
'target': 'map',
'layers': [
ol.layer.Tile.new({
'title': 'Global Imagery',
'source': ol.source.TileWMS.new({
'url': 'https://ahocevar.com/geoserver/wms',
'params': {'LAYERS': 'nasa:bluemarble', 'TILED': True}
})
}),
tremblement_terre
],
'view': ol.View.new({
'projection': 'EPSG:4326',
'center': [5.7626, 45.1734],
'zoom': 1,
'maxResolution': 0.703125
})
})
def info(ev):
document["info"] <= "{} {} ".format(ev.x,ev.y)
???????????????????????????????
document["map"].bind('click',info)
</script>
</body>
</html>
--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+unsubscribe@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/1e28c541-289e-4c19-acfc-14773fc84073%40googlegroups.com.
def get_feature(e):
ft = map.forEachFeatureAtPixel(e.pixel, lambda feature, layer: feature)
info_element = document['info']
#info_element.text = ft.getKeys()
try:
info_element.text = ft.get('title')
except:
pass
map.on('singleclick', get_feature)
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
Thanks again for your help
The function below works fine.
def get_feature(e):
ft = map.forEachFeatureAtPixel(e.pixel, lambda feature, layer: feature)
info_element = document['info']
#info_element.text = ft.getKeys()
try:
info_element.text = ft.get('title')
except:
pass
map.on('singleclick', get_feature)
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/1da07222-6ad9-46fd-a5b6-080cc16b0520%40googlegroups.com.
Could you share the complete example so there is a record of it in the ML?
def get_feature(e):
ft = map.forEachFeatureAtPixel(e.pixel, lambda feature, layer: feature)
info_element = document['info']
#info_element.text = ft.getKeys()
try:
info_element.text = ft.get('title')
except:
info_element.text = ""
map.on('singleclick', get_feature)
</script>
</body>
</html> Saisissez le code ici...
Le mardi 13 juin 2017 17:34:08 UTC+2, kiko (on pybonacci) a écrit :Could you share the complete example so there is a record of it in the ML?
I hope I have understood what you are asking for.
--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/c3b83d21-275e-4462-9a0a-2be68417039e%40googlegroups.com.