[libchamplain] local-rendering-demo: Add button to request new map data
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libchamplain] local-rendering-demo: Add button to request new map data
- Date: Sun, 24 Jan 2010 20:09:00 +0000 (UTC)
commit 84e7b23cf404596e9fd8a4257077b960463dd71d
Author: Simon Wenner <simon wenner ch>
Date: Wed Jul 8 01:22:06 2009 +0200
local-rendering-demo: Add button to request new map data
demos/local-rendering.c | 48 +++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 44 insertions(+), 4 deletions(-)
---
diff --git a/demos/local-rendering.c b/demos/local-rendering.c
index e0bb2ea..f8a7138 100644
--- a/demos/local-rendering.c
+++ b/demos/local-rendering.c
@@ -43,7 +43,7 @@ on_destroy (GtkWidget *widget, gpointer data)
}
static void
-load_map_data (ChamplainMapSource *source)
+load_local_map_data (ChamplainMapSource *source)
{
ChamplainLocalMapDataSource *map_data_source;
@@ -56,6 +56,20 @@ load_map_data (ChamplainMapSource *source)
}
static void
+load_network_map_data (ChamplainMapSource *source)
+{
+ ChamplainNetworkMapDataSource *map_data_source;
+
+ map_data_source = CHAMPLAIN_NETWORK_MAP_DATA_SOURCE (
+ champlain_memphis_map_source_get_map_data_source (
+ CHAMPLAIN_MEMPHIS_MAP_SOURCE (source)));
+
+ champlain_network_map_data_source_load_map_data (map_data_source,
+ coords[map_index][1] - 0.008, coords[map_index][0] - 0.008,
+ coords[map_index][1] + 0.008, coords[map_index][0] + 0.008);
+}
+
+static void
zoom_to_map_data (GtkWidget *widget, ChamplainView *view)
{
champlain_view_center_on (CHAMPLAIN_VIEW(view), coords[map_index][0],
@@ -64,6 +78,24 @@ zoom_to_map_data (GtkWidget *widget, ChamplainView *view)
}
static void
+request_osm_data_cb (GtkWidget *widget, ChamplainView *view)
+{
+ gdouble lat, lon;
+ ChamplainMapSource *source;
+ g_object_get (G_OBJECT (view), "latitude", &lat, "longitude", &lon, NULL);
+ g_object_get (G_OBJECT (view), "map-source", &source, NULL);
+
+ if (g_strcmp0 (champlain_map_source_get_id (source), "memphis-network") == 0)
+ {
+ ChamplainNetworkMapDataSource *data_source =
+ champlain_memphis_map_source_get_map_data_source (
+ CHAMPLAIN_MEMPHIS_MAP_SOURCE(source));
+ champlain_network_map_data_source_load_map_data (data_source,
+ lon - 0.008, lat - 0.008, lon + 0.008, lat + 0.008);
+ }
+}
+
+static void
map_source_changed (GtkWidget *widget, ChamplainView *view)
{
gchar* id;
@@ -85,7 +117,9 @@ map_source_changed (GtkWidget *widget, ChamplainView *view)
if (source != NULL)
{
if (g_strcmp0 (id, "memphis-local") == 0)
- load_map_data (source);
+ load_local_map_data (source);
+ else if (g_strcmp0 (id, "memphis-network") == 0)
+ load_network_map_data (source);
g_object_set (G_OBJECT (view), "map-source", source, NULL);
g_object_unref (source);
@@ -112,7 +146,9 @@ map_data_changed (GtkWidget *widget, ChamplainView *view)
g_object_get (G_OBJECT (view), "map-source", &source, NULL);
if (g_strcmp0 (champlain_map_source_get_id (source), "memphis-local") == 0)
- load_map_data (source);
+ load_local_map_data (source);
+ else if (g_strcmp0 (champlain_map_source_get_id (source), "memphis-network") == 0)
+ load_network_map_data (source);
}
static void
@@ -130,7 +166,7 @@ rules_changed (GtkWidget *widget, ChamplainView *view)
gtk_tree_model_get (model, &iter, 0, &file, -1);
g_object_get (G_OBJECT (view), "map-source", &source, NULL);
- if (g_strcmp0 (champlain_map_source_get_id (source), "memphis-local") == 0)
+ if (strncmp (champlain_map_source_get_id (source), "memphis", 7) == 0)
champlain_memphis_map_source_load_rules (
CHAMPLAIN_MEMPHIS_MAP_SOURCE(source),
file);
@@ -355,6 +391,10 @@ main (int argc,
g_signal_connect (button, "changed", G_CALLBACK (rules_changed), view);
gtk_box_pack_start (GTK_BOX (menubox), button, FALSE, FALSE, 0);
+ button = gtk_button_new_with_label ("Request OSM data");
+ g_signal_connect (button, "clicked", G_CALLBACK (request_osm_data_cb), view);
+ gtk_box_pack_start (GTK_BOX (menubox), button, FALSE, FALSE, 0);
+
/* viewport */
viewport = gtk_viewport_new (NULL, NULL);
gtk_viewport_set_shadow_type (GTK_VIEWPORT(viewport), GTK_SHADOW_ETCHED_IN);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]