Export to GitHub

gmaps-utility-library - issue #3

Proper setLatLng behaviour


Posted on Mar 20, 2008 by Happy Dog

What steps will reproduce the problem? 1. create an instance of a LabeledMarker 2. add the marker to a map 3. call setLatLng on the marker

What is the expected output? What do you see instead? The marker should be moved with its label. Instead, the marker is moved to new position but the label stays in the original position.

What version of the product are you using? On what operating system? LabeledMarker v1.1, FF on Mac

Please provide any additional information below.

The solution is to use the GLatLng object from GMarker instead of internal latlng_ property. Changing the redraw method in hte following way ensures correct behaviour.

LabeledMarker.prototype.redraw = function(force) { GMarker.prototype.redraw.apply(this, arguments);

var latlng = this.getLatLng();

// Calculate the DIV coordinates of two opposite corners of our bounds to // get the size and position of our rectangle var p = this.map_.fromLatLngToDivPixel(latlng); var z = GOverlay.getZIndex(latlng.lat());

// Now position our div based on the div coordinates of our bounds this.div_.style.left = (p.x + this.labelOffset_.width) + "px"; this.div_.style.top = (p.y + this.labelOffset_.height) + "px"; this.div_.style.zIndex = z; // in front of the marker }

Comment #1

Posted on Jun 19, 2008 by Swift Camel

This was already reported and fixed in r616 which can be found under the dev trunk

http://gmaps-utility-library-dev.googlecode.com/svn/trunk/labeledmarker/

Comment #2

Posted on Jun 19, 2008 by Grumpy Bear

And in the release project as LabeledMarker 1.2: http://gmaps-utility-library.googlecode.com/svn/trunk/labeledmarker/1.2/src/labeledmarker.js

Status: Fixed

Labels:
Type-Defect Priority-Medium