Hi Tim, Thanks for your interest. I'm afraid I haven't taken much time to test or document this thoroughly.
Try setting your constructor's prototype to the OpenLayers view prototype: customMapConstructor.prototype = Exhibit.OLMap.prototype; Feel free to make a feature requests. Tim Waters wrote: > Hi, > > I'm using the new OpenLayers mapview extension [1] & [2] and need to > use a custom map constructor, to add in some custom layers and > controls, but am currently stuck with the SelectFeature control > configuration for the vector layer (the control that looks after what > happens when a marker is clicked). > > The constructor code, below was adapted partly from : > http://code.google.com/p/simile-widgets/source/browse/exhibit/trunk/src/webapp/api/extensions/map/scripts/olmap-view.js > > The map is displayed and vectors for the markers are added fine, but > when a marker is clicked I get an error: "self._onFeatureUnselect is > not a function" > It's clear that the self reference from the code is referring to the > OLMapView object. Is it possible to access this in the constructor?. > > I've tried > self = Exhibit.OLMapView.prototype; > but that also gave an error, any ideas? > > > function customMapConstructor(mapdiv){ > var map = new OpenLayers.Map({ > "div": mapdiv, > "controls": [], > "projection": new OpenLayers.Projection("EPSG:900913"), > "displayProjection": new OpenLayers.Projection("EPSG:4326"), > "units": "m", > "numZoomLevels": 18, > "maxResolution": 156543.0339, > "maxExtent": new OpenLayers.Bounds(-20037508.34, -20037508.34, > 20037508.34, 20037508.34) > }); > var mapnik = new OpenLayers.Layer.OSM.Mapnik(); > mapnik.setVisibility(true); > var vectors = new OpenLayers.Layer.Vector("Features", > {"wrapDateLine":true}); > > map.addLayers([mapnik, vectors]); > map.setCenter(new OpenLayers.LonLat(-73.4,41.7).transform > (map.displayProjection, map.getProjectionObject()), 7); > > //Stuck on this bit. > var self = this; > var selectControl = new OpenLayers.Control.SelectFeature(vectors, { > onSelect: function(feature) { > self._onFeatureSelect(self, feature); > }, > onUnselect: function(feature) { > self._onFeatureUnselect(self, feature); > } > }); > map.addControl(selectControl); > selectControl.activate(); > > map.addControl(new OpenLayers.Control.Navigation()); > map.addControl(new OpenLayers.Control.LayerSwitcher()); > map.events.register("click", null, > SimileAjax.WindowManager.cancelPopups); > > return map; > } > > > Cheers! > > Many thanks in advance, > > Tim > > > [1] http://www.simile-widgets.org/wiki/Exhibit/OpenLayers_Map_View > [2] > http://groups.google.com/group/simile-widgets/browse_thread/thread/ae59496c3a5bc2bd/fa9a6ad0ffdd774e?lnk=gst > > --~--~---------~--~----~------------~-------~--~----~ > You received this message because you are subscribed to the Google > Groups "SIMILE Widgets" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/simile-widgets?hl=en > -~----------~----~----~----~------~----~------~--~--- > -- Ryan Lee [email protected] http://simile.mit.edu/ -- You received this message because you are subscribed to the Google Groups "SIMILE Widgets" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/simile-widgets?hl=en.
