1 <%= javascript_include_tag '/openlayers/OpenLayers.js' %>
2 <%= javascript_include_tag '/openlayers/OpenStreetMap.js' %>
3 <%= javascript_include_tag 'map.js' %>
4 <div id="browse_map_changeset">
7 <span id="loading"><%= t 'browse.map.loading' %></span>
9 <script type="text/javascript">
10 OpenLayers.Lang.setCode("<%= I18n.locale.to_s %>");
13 This function borrowed from the latest version of OpenLayers.Layer.Vector. OSM is using an older version.
14 http://trac.osgeo.org/openlayers/browser/trunk/openlayers/lib/OpenLayers/Layer/Vector.js
16 function getFeaturesByAttribute(obj, attrName, attrValue) {
19 len = obj.features.length,
21 for(i = 0; i < len; i++) {
22 feature = obj.features[i];
23 if(feature && feature.attributes) {
24 if (feature.attributes[attrName] === attrValue) {
25 foundFeatures.push(feature);
31 function highlightChangesetMap(name) {
32 getFeaturesByAttribute(vectors,'name',name)[0].style.strokeColor='#ffff55';
35 function unHighlightChangesetMap(name) {
36 getFeaturesByAttribute(vectors,'name',name)[0].style.strokeColor='#ee9900';
40 var map = createMap("small_map", {
41 controls: [ new OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoom(), new OpenLayers.Control.PanZoomBar() ]
44 var bounds = new OpenLayers.Bounds();
45 <%= render :partial => 'changeset_map_add', :collection => @edits unless @edits.nil? %>
48 'featureselected': function(feature) {
49 document.getElementById('tr-' + feature.feature.attributes['name']).style.backgroundColor = '#ffff55';
50 feature.feature.style.strokeColor='#ffff00';
53 'featureunselected': function(feature) {
54 document.getElementById('tr-' + feature.feature.attributes['name']).style.backgroundColor = '';
55 feature.feature.style.strokeColor='#ee9900';
59 var selectControl = new OpenLayers.Control.SelectFeature(vectors,
60 {multiple: false, hover:true});
61 map.addControl(selectControl);
62 selectControl.activate();
64 <!-- if bounds were passed, just use those -->
66 bounds = new OpenLayers.Bounds(<%= @bbox %>);
70 $("loading").innerHTML = "";