20,741
edits
m (→Background) |
m (→Background) |
||
| Line 11: | Line 11: | ||
Using the Canvas system, it has now become trivial to create new map layers of symbols with geographic positions which are transparently mapped to screen coordinates by the canvas system automatically. | Using the Canvas system, it has now become trivial to create new map layers of symbols with geographic positions which are transparently mapped to screen coordinates by the canvas system automatically. | ||
To illustrate just how powerful this new feature is, take a look at the following foreach loop which places all the parking positions in the shown map dialog (for the full code, see this [https://gitorious.org/~tomprogs/fg/toms-fgdata/commit/9a40c82bc06c33fb59b95188ea000d69e760b75a commit]). | |||
<syntaxhighlight lang="php"> | |||
193 foreach(var park; me._apt.parking()) | |||
194 { | |||
195 var icon_park = me.grp_apt.createChild("text"); | |||
196 icon_park.setDrawMode(9); | |||
197 icon_park.setText(park.name); | |||
198 icon_park.setFont("LiberationFonts/LiberationMono-Bold.ttf"); | |||
199 icon_park.setGeoPosition(park.lat, park.lon); | |||
200 icon_park.setSize(15, 1.3); | |||
201 } | |||
</syntaxhighlight> | |||
As can be seen in line 199, the canvas system directly uses geographic coordinates, so there's no explicit conversion to screen coordinates or other projection handling required. In other words: what you get from the Nasal DB, can be directly used here. | |||
== Background: Automatic geographic mapping (Implemented) == | == Background: Automatic geographic mapping (Implemented) == | ||