Migration to API v3: Problems accessing OpenLayers objects

635 views
Skip to first unread message

drei...@gmail.com

unread,
Mar 7, 2014, 4:53:48 AM3/7/14
to geoadm...@googlegroups.com
Hi there,

I'm trying to migrate a simple map application with clickable markers to API v3. According to the new documentation, all OpenLayers 3 examples should also work with the SwissTopo Geo API v3. However, I cannot access objects like OpenLayers.Layer, OpenLayers.Features, etc.

When I try to use the layer created by ga.layer.create(...) and the map created by new ga.Map(), the objects are not actual OpenLayers layers nor maps. I get lots of errors like "layer.addFeatures is not a function".

I would appreciate any help to get one of the OpenLayers marker examples running:
- http://openlayers.org/dev/examples/marker-shadow.html
- http://openlayers.org/dev/examples/osm-marker-popup.html

Kind regards,
Matthias Dreier

drei...@gmail.com

unread,
Mar 7, 2014, 8:23:39 AM3/7/14
to geoadm...@googlegroups.com, drei...@gmail.com
OK, I saw that I was mixing OpenLayers 2.5 and OpenLayers 3, but still I have difficulties with the following v3 example: http://ol3js.org/en/master/examples/icon.html

Firebug tells me:
TypeError: map.getTarget(...).style is undefined

map.getTarget().style.cursor = '';

Eric Lemoine

unread,
Mar 10, 2014, 2:23:35 AM3/10/14
to geoadm...@googlegroups.com
If a string was set for the "target" option passed to the ol.Map constructor then map.getTarget will return a string. Try this:

var target = document.getElementById(map.getTarget());

Hope it helps,


--
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 94
Mail : eric.l...@camptocamp.com
http://www.camptocamp.com
Reply all
Reply to author
Forward
0 new messages