OpenLayers OpenLayers

Ticket #1031 (closed feature: fixed)

Opened 1 year ago

Last modified 1 year ago

API call for changing a marker's icon.

Reported by: openlayers Assigned to: euzuro
Priority: minor Milestone: 2.6 Release
Component: Marker Version: SVN
Keywords: Cc: penyaskito@gmail.com
State:

Description

I would like to suggest a method for changing the icon from a marker; this is useful for giving visual indication that a marker was selected, for example. I tried instantiating a new icon object and replacing marker.icon, but this didn't work.

I'm currently using the following solution, suggested at #openlayers, of altering the src attribute in marker.icon.imageDiv.firstChild:

marker.events.register('click', marker, function() {
  // Reset all markers.
  for (var i=0; i<buoys.markers.length; i++) {
    markers.markers[i].icon.imageDiv.firstChild.setAttribute(
      'src', 'js/OpenLayers/img/marker.png');
  }
  this.icon.imageDiv.firstChild.setAttribute('src', 'js/OpenLayers/img/marker-gold.png');
});

Attachments

icon.seturl.patch (2.3 kB) - added by crschmidt on 09/30/07 12:11:13.
add setURL to marker, icon

Change History

09/30/07 11:26:17 changed by penyaskito

  • cc set to penyaskito@gmail.com.
  • milestone set to 2.6 Release.

09/30/07 12:11:13 changed by crschmidt

  • attachment icon.seturl.patch added.

add setURL to marker, icon

09/30/07 12:11:22 changed by crschmidt

  • keywords set to review.

10/03/07 11:56:03 changed by euzuro

  • keywords changed from review to commit.

good patch. all tests pass ie6/ff. please commit

10/03/07 12:18:11 changed by crschmidt

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to fixed.

Closed by r4784