void gourmap_ui_update_map (GourmapUi *ui, const double my_lat, const double my_lng, const double center_lat, const double center_lng, GList *poi_list) { GourmapUiPrivate *priv = GET_PRIVATE (ui); ClutterActor *marker; ClutterColor *color; Restaurant *rest; GList *list_i; /* remove previous markers */ champlain_marker_layer_remove_all (priv->marker_layer); champlain_view_set_zoom_level (priv->champ_view, priv->zoom); champlain_view_go_to (priv->champ_view, my_lat, my_lng); color = clutter_color_new (0xff, 0x20, 0x15, 0xbb); marker = champlain_label_new_with_text (_("I'm here"), "Serif 14", NULL, color); clutter_color_free (color); champlain_location_set_location (CHAMPLAIN_LOCATION (marker), my_lat, my_lng); champlain_marker_layer_add_marker (priv->marker_layer, CHAMPLAIN_MARKER (marker)); /* Put restaurant markers */ list_i = poi_list; color = clutter_color_new (0xff, 0x20, 0xff, 0xbb); while (list_i != NULL) { rest = (Restaurant *)list_i->data; marker = champlain_label_new_with_text (rest->name, "Serif 10", NULL, color); champlain_location_set_location (CHAMPLAIN_LOCATION (marker), rest->latitude, rest->longitude); champlain_marker_layer_add_marker (priv->marker_layer, CHAMPLAIN_MARKER (marker)); list_i = g_list_next (list_i); } clutter_color_free (color); champlain_marker_layer_show_all_markers (priv->marker_layer); }
static ChamplainBoundingBox * get_bounding_box (ChamplainLayer *layer) { ChamplainPathLayerPrivate *priv = GET_PRIVATE (layer); GList *elem; ChamplainBoundingBox *bbox; bbox = champlain_bounding_box_new (); for (elem = priv->nodes; elem != NULL; elem = elem->next) { ChamplainLocation *location = CHAMPLAIN_LOCATION (elem->data); gdouble lat, lon; lat = champlain_location_get_latitude (location); lon = champlain_location_get_longitude (location); champlain_bounding_box_extend (bbox, lat, lon); } if (bbox->left == bbox->right) { bbox->left -= 0.0001; bbox->right += 0.0001; } if (bbox->bottom == bbox->top) { bbox->bottom -= 0.0001; bbox->top += 0.0001; } return bbox; }
static void create_marker (EogImage *image, EogMapPlugin *plugin) { gdouble lon, lat; if (!image) return; if (!eog_image_has_data (image, EOG_IMAGE_DATA_EXIF) && !eog_image_load (image, EOG_IMAGE_DATA_EXIF, NULL, NULL)) return; if (get_coordinates (image, &lat, &lon)) { ChamplainLabel *marker; marker = CHAMPLAIN_LABEL (champlain_label_new ()); champlain_label_set_draw_background (CHAMPLAIN_LABEL (marker), FALSE); update_marker_image (marker, GTK_ICON_SIZE_MENU); g_object_set_data_full (G_OBJECT (image), "marker", marker, (GDestroyNotify) clutter_actor_destroy); g_object_set_data (G_OBJECT (marker), "image", image); champlain_location_set_location (CHAMPLAIN_LOCATION (marker), lat, lon); champlain_marker_layer_add_marker (plugin->layer, CHAMPLAIN_MARKER (marker)); g_signal_connect (marker, "button-release-event", G_CALLBACK (change_image), plugin); } }
void gth_map_view_real_set_file (GthPropertyView *base, GthFileData *file_data) { GthMapView *self = GTH_MAP_VIEW (base); int coordinates_available; double latitude; double longitude; coordinates_available = 0; if (file_data != NULL) { GthMetadata *metadata; metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "Exif::GPSInfo::GPSLatitude"); if (metadata != NULL) { latitude = exif_coordinate_to_decimal (gth_metadata_get_raw (metadata)); metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "Exif::GPSInfo::GPSLatitudeRef"); if (metadata != NULL) { if (g_strcmp0 (gth_metadata_get_raw (metadata), "S") == 0) latitude = - latitude; } coordinates_available++; } metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "Exif::GPSInfo::GPSLongitude"); if (metadata != NULL) { longitude = exif_coordinate_to_decimal (gth_metadata_get_raw (metadata)); metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "Exif::GPSInfo::GPSLongitudeRef"); if (metadata != NULL) { if (g_strcmp0 (gth_metadata_get_raw (metadata), "W") == 0) longitude = - longitude; } coordinates_available++; } } if (coordinates_available == 2) { char *position; gtk_widget_hide (self->priv->no_gps_label); gtk_widget_show (self->priv->embed); position = decimal_coordinates_to_string (latitude, longitude); champlain_label_set_text (CHAMPLAIN_LABEL (self->priv->marker), position); g_free (position); champlain_location_set_location (CHAMPLAIN_LOCATION (self->priv->marker), latitude, longitude); champlain_view_center_on (CHAMPLAIN_VIEW (self->priv->map_view), latitude, longitude); } else { gtk_widget_hide (self->priv->embed); gtk_widget_show (self->priv->no_gps_label); } }
static void append_point (ChamplainPathLayer *layer, gdouble lon, gdouble lat) { ChamplainCoordinate *coord; coord = champlain_coordinate_new_full (lon, lat); champlain_path_layer_add_node (layer, CHAMPLAIN_LOCATION (coord)); }
static gboolean gps_callback (GpsCallbackData *data) { lat += 0.005; lon += 0.005; champlain_view_center_on (data->view, lat, lon); champlain_location_set_location (CHAMPLAIN_LOCATION (data->marker), lat, lon); return TRUE; }
static ChamplainMarker * add_marker(PlacemarksPlugin *plugin, const gchar *name, gdouble lat, gdouble lon) { PlacemarksPluginPrivate *priv; priv = PLACEMARKS_PLUGIN (plugin)->priv; ChamplainMarker *marker; ClutterColor orange = { 0xf3, 0x94, 0x07, 0xbb }; marker = CHAMPLAIN_MARKER ( champlain_label_new_with_text (name, "Serif 14", NULL, NULL)); champlain_label_set_use_markup (CHAMPLAIN_LABEL (marker), TRUE); champlain_label_set_alignment (CHAMPLAIN_LABEL (marker), PANGO_ALIGN_RIGHT); champlain_label_set_color (CHAMPLAIN_LABEL (marker), &orange); champlain_location_set_location (CHAMPLAIN_LOCATION(marker), lat, lon); champlain_marker_layer_add_marker (priv->markers_layer, CHAMPLAIN_MARKER (marker)); return marker; }
static gboolean redraw_path (ClutterCanvas *canvas, cairo_t *cr, int width, int height, ChamplainPathLayer *layer) { ChamplainPathLayerPrivate *priv = layer->priv; GList *elem; ChamplainView *view = priv->view; gint viewport_x, viewport_y; gint anchor_x, anchor_y; /* layer not yet added to the view */ if (view == NULL) return FALSE; if (!priv->visible || width == 0.0 || height == 0.0) return FALSE; champlain_view_get_viewport_origin (priv->view, &viewport_x, &viewport_y); champlain_view_get_viewport_anchor (priv->view, &anchor_x, &anchor_y); if (canvas == CLUTTER_CANVAS (priv->right_canvas)) clutter_actor_set_position (priv->right_actor, viewport_x, viewport_y); else clutter_actor_set_position (priv->left_actor, -anchor_x, viewport_y); /* Clear the drawing area */ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); cairo_paint (cr); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL); for (elem = priv->nodes; elem != NULL; elem = elem->next) { ChamplainLocation *location = CHAMPLAIN_LOCATION (elem->data); gfloat x, y; x = champlain_view_longitude_to_x (view, champlain_location_get_longitude (location)); y = champlain_view_latitude_to_y (view, champlain_location_get_latitude (location)); if (canvas == CLUTTER_CANVAS (priv->right_canvas)) cairo_line_to (cr, x, y); else cairo_line_to (cr, x + (viewport_x + anchor_x), y); } if (priv->closed_path) cairo_close_path (cr); cairo_set_source_rgba (cr, priv->fill_color->red / 255.0, priv->fill_color->green / 255.0, priv->fill_color->blue / 255.0, priv->fill_color->alpha / 255.0); if (priv->fill) cairo_fill_preserve (cr); cairo_set_source_rgba (cr, priv->stroke_color->red / 255.0, priv->stroke_color->green / 255.0, priv->stroke_color->blue / 255.0, priv->stroke_color->alpha / 255.0); cairo_set_line_width (cr, priv->stroke_width); cairo_set_dash(cr, priv->dash, priv->num_dashes, 0); if (priv->stroke) cairo_stroke (cr); set_surface (CHAMPLAIN_EXPORTABLE (layer), cairo_get_target (cr)); return FALSE; }
static gboolean add_marker (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { int latitude_offset; int longitude_offset; double lat; double lon; gchar *title; gchar *latitude_str; gchar *longitude_str; gchar *check; ClutterActor *marker; ClutterActor *icon; PhidiasItemsGeo *item; item = data; latitude_offset = phidias_extra_column_get_index ((PhidiasExtraColumn*) g_ptr_array_index (item->priv->extras, 0)); longitude_offset = phidias_extra_column_get_index ((PhidiasExtraColumn*) g_ptr_array_index (item->priv->extras, 1)); gtk_tree_model_get (model, iter, ITEM_INFO_TITLE, &title, latitude_offset, &latitude_str, longitude_offset, &longitude_str, -1); if (latitude_str == NULL || longitude_str == NULL) goto end; check = NULL; lat = strtod (latitude_str, &check); if (*check != '\0') goto end; check = NULL; lon = strtod (longitude_str, &check); if (*check != '\0') goto end; check = g_markup_escape_text (title, -1); g_free (title); title = check; /* TODO Provide a proper ChamplainMarker implementation, able to store the icon, the title, the description, and able to react to clicks */ icon = do_marker_icon ("go-jump", 22); if (item->priv->show_text) { marker = champlain_label_new_with_text (title, "Serif 9", NULL, NULL); } else { marker = champlain_label_new_with_text (title, "Serif 0", NULL, NULL); champlain_label_set_image (CHAMPLAIN_LABEL (marker), icon); } g_object_set_data (G_OBJECT (marker), "icon", icon); champlain_location_set_location (CHAMPLAIN_LOCATION (marker), lat, lon); champlain_marker_layer_add_marker (item->priv->current_layer, CHAMPLAIN_MARKER (marker)); g_hash_table_insert (item->priv->markers, gtk_tree_path_to_string (path), marker); end: if (title != NULL) g_free (title); if (latitude_str != NULL) g_free (latitude_str); if (longitude_str != NULL) g_free (longitude_str); return FALSE; }