Add outline to markers
authorAndy Spencer <andy753421@gmail.com>
Wed, 10 Feb 2010 13:13:50 +0000 (13:13 +0000)
committerAndy Spencer <andy753421@gmail.com>
Wed, 10 Feb 2010 13:13:50 +0000 (13:13 +0000)
src/objects/gis-marker.c
src/plugins/map.c
src/plugins/test.c

index fc4beb1..33caab0 100644 (file)
 GisMarker *gis_marker_new(const gchar *label)
 {
        //g_debug("GisMarker: new - %s", label);
-       static const int RADIUS =   4;
-       static const int WIDTH  = 100;
-       static const int HEIGHT =  20;
+       static const gint OUTLINE =   2;
+       static const gint RADIUS  =   4;
+       static const gint WIDTH   = 120;
+       static const gint HEIGHT  =  40;
 
        GisMarker *marker = g_object_new(GIS_TYPE_MARKER, NULL);
-       marker->xoff  = RADIUS;
-       marker->yoff  = HEIGHT-RADIUS;
+       marker->xoff  = RADIUS+OUTLINE;
+       marker->yoff  = HEIGHT-(RADIUS+OUTLINE);
        marker->label = g_strdup(label);
        marker->cairo = cairo_create(cairo_image_surface_create(
                                CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT));
+
+       cairo_select_font_face(marker->cairo, "sans-serif",
+                       CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
+       cairo_set_font_size(marker->cairo, 14);
+
+       /* Draw outline */
+       cairo_set_source_rgba(marker->cairo, 0, 0, 0, 1);
+       cairo_set_line_width(marker->cairo, OUTLINE*2);
+
+       cairo_arc(marker->cairo, marker->xoff, marker->yoff, RADIUS, 0, 2*G_PI);
+       cairo_stroke(marker->cairo);
+
+       cairo_move_to(marker->cairo, marker->xoff+4, marker->yoff-8);
+       cairo_text_path(marker->cairo, marker->label);
+       cairo_stroke(marker->cairo);
+
+       /* Draw filler */
        cairo_set_source_rgba(marker->cairo, 1, 1, 1, 1);
+
        cairo_arc(marker->cairo, marker->xoff, marker->yoff, RADIUS, 0, 2*G_PI);
        cairo_fill(marker->cairo);
+
        cairo_move_to(marker->cairo, marker->xoff+4, marker->yoff-8);
-       cairo_set_font_size(marker->cairo, 10);
        cairo_show_text(marker->cairo, marker->label);
        return marker;
 }
index 0ae8ef6..a0f28dc 100644 (file)
@@ -188,7 +188,7 @@ GisPluginMap *gis_plugin_map_new(GisViewer *viewer)
                        G_CALLBACK(_on_location_changed), map);
 
        /* Add renderers */
-       gis_viewer_add(viewer, GIS_OBJECT(map->tiles), GIS_LEVEL_OVERLAY, 0);
+       gis_viewer_add(viewer, GIS_OBJECT(map->tiles), GIS_LEVEL_OVERLAY-1, 0);
 
        return map;
 }
index 47eadd5..4dbc838 100644 (file)
@@ -50,7 +50,7 @@ GisPluginTest *gis_plugin_test_new(GisViewer *viewer)
 
        GisMarker *marker = gis_marker_new("St. Charles");
        gis_point_set_lle(gis_object_center(marker), 38.841847, -90.491982, 0);
-       GIS_OBJECT(marker)->lod = EARTH_R/4;
+       GIS_OBJECT(marker)->lod = EARTH_R;
        test->marker = gis_viewer_add(test->viewer, GIS_OBJECT(marker), GIS_LEVEL_OVERLAY, 0);
 
        return test;