Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
OpenStreetMap in BIRT
MikeyD
Hi,
I have been working on adding geographic maps to my reports, but do not want to use Google Maps (because of restrictive license). Therefore I started working with OpenStreetMap and OpenLayers.
I changed the Google Maps sample and I have my OpenStreetMap map working when I render the report to HTML.
However, I can only make it work as you can see in the attached example: by clicking on the text below the map area. I would like to have the map opened when the report is opened. I have tried a number of things, but unfortunately have been unsuccessful.
Could someone tell me how I can "trigger" my map to open when the report is opened?
Thanks for your support.
Kind regards,
Mikey
Find more posts tagged with
Comments
JasonW
Mikey,
Can you post the example?
Jason
MikeyD
Sorry, I forgot to add the example.
JasonW
I changed your script to remove the mapit funciton and just run the script and it works in FF but no IE
<div style="width:100%; height:500px" id="map"></div>
<script src="
http://www.openlayers.org/api/OpenLayers.js"></script>
;
<script src="
http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>
;
<script type="text/javascript">
var lat=47.07703
var lon=5.147095
var zoom=4
var map;
//function mapinit() {
map = new OpenLayers.Map ("map", {
controls:[
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.Attribution()],
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
maxResolution: 156543.0399,
numZoomLevels: 19,
units: 'm',
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
} );
layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
map.addLayer(layerMapnik);
layerTilesAtHome = new OpenLayers.Layer.OSM.Osmarender("Osmarender");
map.addLayer(layerTilesAtHome);
layerCycleMap = new OpenLayers.Layer.OSM.CycleMap("CycleMap");
map.addLayer(layerCycleMap);
layerMarkers = new OpenLayers.Layer.Markers("Markers");
map.addLayer(layerMarkers);
var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
map.setCenter (lonLat, zoom);
var size = new OpenLayers.Size(32,37);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new OpenLayers.Icon('
http://google-maps-icons.googlecode.com/files/supermarket.png',size)
;
layerMarkers.addMarker(new OpenLayers.Marker(lonLat,icon));
//}
</script>
MikeyD
Hi Jason,
Thanks!!!
On my machine it works both in FF and IE. In Safari it does not work (yet), but I will dive into that later. Most of my users are on FF and IE anyhow.
Thanks again for your great support so I can finally use maps in my reports.
Kind regards,
Mikey
JasonW
Mikey,
Glad to hear. It would be great if you could submit your example to devshare. This is a very cool example.
Jason
MikeyD
Hi Jason,<br />
<br />
I just posted an example to devshare: <a class='bbc_url' href='
http://www.birt-exchange.org/devshare/birt-report-designers/990-openstreetmap-maps-within-your-birt-reports/'>OpenStreetMap
maps within your BIRT reports - Designs & Code - BIRT Exchange</a><br />
<br />
Kind regards,<br />
<br />
Mikey
JasonW
Thanks for posting
Jason
caribe
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="52665" data-time="1250722682" data-date="19 August 2009 - 03:58 PM"><p>
I changed your script to remove the mapit funciton and just run the script and it works in FF but no IE<br />
<br />
<br />
<div style="width:100%; height:500px" id="map"></div><br />
<br />
<script src="<a class='bbc_url' href='
http://www.openlayers.org/api/OpenLayers.js"></script>'>http://www.openlayers.org/api/OpenLayers.js"></script></a><br
/>
<br />
<script src="<a class='bbc_url' href='
http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>'>http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script></a><br
/>
<br />
<br />
<br />
<script type="text/javascript"><br />
<br />
var lat=47.07703<br />
<br />
var lon=5.147095<br />
<br />
var zoom=4<br />
<br />
var map;<br />
<br />
<br />
<br />
//function mapinit() {<br />
<br />
map = new OpenLayers.Map ("map", {<br />
<br />
controls:[<br />
<br />
new OpenLayers.Control.Navigation(),<br />
<br />
new OpenLayers.Control.PanZoomBar(),<br />
<br />
new OpenLayers.Control.LayerSwitcher(),<br />
<br />
new OpenLayers.Control.Attribution()],<br />
<br />
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),<br />
<br />
maxResolution: 156543.0399,<br />
<br />
numZoomLevels: 19,<br />
<br />
units: 'm',<br />
<br />
projection: new OpenLayers.Projection("EPSG:900913"),<br />
<br />
displayProjection: new OpenLayers.Projection("EPSG:4326")<br />
<br />
} );<br />
<br />
<br />
<br />
<br />
<br />
layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");<br />
<br />
map.addLayer(layerMapnik);<br />
<br />
layerTilesAtHome = new OpenLayers.Layer.OSM.Osmarender("Osmarender");<br />
<br />
map.addLayer(layerTilesAtHome);<br />
<br />
layerCycleMap = new OpenLayers.Layer.OSM.CycleMap("CycleMap");<br />
<br />
map.addLayer(layerCycleMap);<br />
<br />
layerMarkers = new OpenLayers.Layer.Markers("Markers");<br />
<br />
map.addLayer(layerMarkers);<br />
<br />
<br />
<br />
var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());<br />
<br />
map.setCenter (lonLat, zoom);<br />
<br />
<br />
<br />
var size = new OpenLayers.Size(32,37);<br />
<br />
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);<br />
<br />
var icon = new OpenLayers.Icon('<a class='bbc_url' href='
http://google-maps-icons.googlecode.com/files/supermarket.png',size'>http://google-maps-icons.googlecode.com/files/supermarket.png',size</a>);<br
/>
<br />
layerMarkers.addMarker(new OpenLayers.Marker(lonLat,icon));<br />
<br />
<br />
//}<br />
<br />
</script><br /></p></blockquote>
<br />
<br />
but how show a point of the map, without clicking the zoom?
Max Bo
<p>Hi,</p><p> </p><p>Is this report still available somewhere out there? I have browsed and searched the devshare but it always redirects me to the devshare start page.</p><p> </p><p>Would be great, if someone could upload this one again!</p><p> </p><p>Max</p>