Labels: Can display labels in 3 formats - #5
Conversation
srappel
left a comment
There was a problem hiding this comment.
Wow this cleans up the formatting a lot! I like the text justified to the side of the lines. Decimal minutes makes more sense than trying to cram minutes and seconds in there like I was.
srappel
left a comment
There was a problem hiding this comment.
I'm still having a minor issue that when I scroll all the way to the west and reach the 180th meridian, the numbers to the west of it are labeled as W when they are in the Eastern Hemisphere. The same happens scrolling to 180 to the East.
|
I solved your minor issue. However, labelling is only working for longitude which are between -360 and 360 degrees. |
| font: '12px Verdana', | ||
| lngLineCurved: 0, | ||
| latLineCurved: 0, | ||
| dmd: false, // Labels: Display Degrees - Decimal Minutes instead of Decimal Degrees |
There was a problem hiding this comment.
I would like a format options instead (with dmd as possible value) instead. There are more than 2 coordinate formats.
There was a problem hiding this comment.
I'll put an option named format which can have one of the following values:
- dd: Decimal Degrees (default value)
- dmd: Degrees - Decimal Minutes
- dms: Degrees - Minutes - Seconds
| if (this.options.dmd) { | ||
| // todo: format type of float | ||
| if (lng > 180) { | ||
| return this.__deg_to_dmd(360 - lng) + ' W'; |
There was a problem hiding this comment.
Use modulus 360 (i.e. lng % 360) instead.
Or better yet, use wrapLatLng() of the map's CRS. (i.e this._map.options.crs.warpLatLng(latlng)) on the appropriate place, or even this._map.options.crs.warpLatLng([0, lng]).lng. That should care of maps with non-default CRSs.
| ctx.stroke(); | ||
| if (self.options.showLabel && label) { | ||
| var _yy = ll.y + (txtHeight/2)-2; | ||
| var _yy = ll.y - (txtHeight/2) + 2; |
There was a problem hiding this comment.
Why this change? Seems unrelated at first sight.
There was a problem hiding this comment.
This change is about labels placements.
| if (self.options.showLabel && label) { | ||
| ctx.fillText(lngstr, tt.x - (txtWidth/2), txtHeight+1); | ||
| ctx.fillText(lngstr, bb.x - (txtWidth/2), hh-3); | ||
| ctx.fillText(lngstr, tt.x + 3, txtHeight+1); |
There was a problem hiding this comment.
Why this change? Seems unrelated at first sight.
There was a problem hiding this comment.
This change is about labels placements.
|
I make a new commit according to your changes request. |
Hi,
I've commited the following modification: