-#include <Elementary.h>
-#include "Ecore_Con.h"
-#include "Eina.h"
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#include "Elementary.h"
#include "elm_priv.h"
+#include "els_scroller.h"
-/**
- * @defgroup Map Map
- * @ingroup Elementary
- *
- * This is a widget specifically for displaying the map. It uses basically
- * OpenStreetMap provider. but it can be added custom providers.
- *
- * Signals that you can add callbacks for are:
- *
- * "clicked" - This is called when a user has clicked the map without dragging
- * around.
- *
- * "press" - This is called when a user has pressed down on the map.
- *
- * "longpressed" - This is called when a user has pressed down on the map for
- * a long time without dragging around.
- *
- * "clicked,double" - This is called when a user has double-clicked the map.
- *
- * "load,detail" - Map detailed data load begins.
- *
- * "loaded,detail" - This is called when all parts of the map are loaded.
- *
- * "zoom,start" - Zoom animation started.
- *
- * "zoom,stop" - Zoom animation stopped.
- *
- * "zoom,change" - Zoom changed when using an auto zoom mode.
- *
- * "scroll" - the content has been scrolled (moved)
- *
- * "scroll,anim,start" - scrolling animation has started
- *
- * "scroll,anim,stop" - scrolling animation has stopped
- *
- * "scroll,drag,start" - dragging the contents around has started
- *
- * "scroll,drag,stop" - dragging the contents around has stopped
- *
- * "downloaded" - This is called when map images are downloaded
- *
- * "route,load" - This is called when route request begins
- *
- * "route,loaded" - This is called when route request ends
- *
- * "name,load" - This is called when name request begins
- *
- * "name,loaded- This is called when name request ends
- *
- * TODO : doxygen
- */
+#define OVERLAY_CLASS_ZOOM_MAX 255
+#ifdef HAVE_ELEMENTARY_ECORE_CON
typedef struct _Widget_Data Widget_Data;
+typedef struct _Path Path;
+typedef struct _Color Color;
+typedef struct _Region Region;
typedef struct _Pan Pan;
typedef struct _Grid Grid;
typedef struct _Grid_Item Grid_Item;
+typedef struct _Overlay_Default Overlay_Default;
+typedef struct _Overlay_Class Overlay_Class;
+typedef struct _Overlay_Group Overlay_Group;
+typedef struct _Overlay_Bubble Overlay_Bubble;
+typedef struct _Overlay_Route Overlay_Route;
+typedef struct _Overlay_Line Overlay_Line;
+typedef struct _Overlay_Polygon Overlay_Polygon;
+typedef struct _Overlay_Circle Overlay_Circle;
+typedef struct _Overlay_Scale Overlay_Scale;
typedef struct _Marker_Group Marker_Group;
-typedef struct _Mod_Api Mod_Api;
-typedef struct _Event Event;
-typedef struct _Route_Node Route_Node;
-typedef struct _Route_Waypoint Route_Waypoint;
-typedef struct _Url_Data Url_Data;
+typedef struct _Marker_Bubble Marker_Bubble;
+typedef struct _Path_Node Path_Node;
+typedef struct _Path_Waypoint Path_Waypoint;
typedef struct _Route_Dump Route_Dump;
typedef struct _Name_Dump Name_Dump;
+typedef struct _Delayed_Data Delayed_Data;
+typedef struct _Source_Tile Source_Tile;
+typedef struct _Source_Route Source_Route;
+typedef struct _Source_Name Source_Name;
+
+typedef char *(*Elm_Map_Module_Source_Name_Func)(void);
+typedef int (*Elm_Map_Module_Tile_Zoom_Min_Func)(void);
+typedef int (*Elm_Map_Module_Tile_Zoom_Max_Func)(void);
+typedef char *(*Elm_Map_Module_Tile_Url_Func)(const Evas_Object *obj, int x, int y, int zoom);
+typedef Eina_Bool (*Elm_Map_Module_Tile_Geo_to_Coord_Func)(const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y);
+typedef Eina_Bool (*Elm_Map_Module_Tile_Coord_to_Geo_Func)(const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat);
+typedef double (*Elm_Map_Module_Tile_Scale_Func)(const Evas_Object *obj, double lon, double lat, int zoom);
+typedef char *(*Elm_Map_Module_Route_Url_Func)(const Evas_Object *obj, const char *type_name, int method, double flon, double flat, double tlon, double tlat);
+typedef char *(*Elm_Map_Module_Name_Url_Func)(const Evas_Object *obj, int method, const char *name, double lon, double lat);
+
+#define ROUND(z) (((z) < 0) ? (int)ceil((z) - 0.005) : (int)floor((z) + 0.005))
+#define EVAS_MAP_POINT 4
+#define DEFAULT_TILE_SIZE 256
+#define MAX_CONCURRENT_DOWNLOAD 10
+#define MARER_MAX_NUMBER 30
+#define OVERLAY_GROUPING_SCALE 2
+
+#define CACHE_ROOT "/tmp/elm_map"
+#define CACHE_TILE_ROOT CACHE_ROOT"/%d/%d/%d"
+#define CACHE_TILE_PATH "%s/%d.png"
+#define CACHE_ROUTE_ROOT CACHE_ROOT"/route"
+#define CACHE_NAME_ROOT CACHE_ROOT"/name"
+
+#define ROUTE_YOURS_URL "http://www.yournavigation.org/api/dev/route.php"
+#define ROUTE_TYPE_MOTORCAR "motocar"
+#define ROUTE_TYPE_BICYCLE "bicycle"
+#define ROUTE_TYPE_FOOT "foot"
+#define YOURS_DISTANCE "distance"
+#define YOURS_DESCRIPTION "description"
+#define YOURS_COORDINATES "coordinates"
+
+#define NAME_NOMINATIM_URL "http://nominatim.openstreetmap.org"
+#define NOMINATIM_RESULT "result"
+#define NOMINATIM_PLACE "place"
+#define NOMINATIM_ATTR_LON "lon"
+#define NOMINATIM_ATTR_LAT "lat"
-#define DEST_DIR_ZOOM_PATH "/tmp/elm_map/%d/%d/"
-#define DEST_DIR_PATH DEST_DIR_ZOOM_PATH"%d/"
-#define DEST_FILE_PATH "%s%d.png"
-#define DEST_ROUTE_XML_FILE "/tmp/elm_map-route-XXXXXX"
-#define DEST_NAME_XML_FILE "/tmp/elm_map-name-XXXXXX"
+enum _Route_Xml_Attribute
+{
+ ROUTE_XML_NONE,
+ ROUTE_XML_DISTANCE,
+ ROUTE_XML_DESCRIPTION,
+ ROUTE_XML_COORDINATES,
+ ROUTE_XML_LAST
+} Route_Xml_Attibute;
-#define ROUTE_YOURS_URL "http://www.yournavigation.org/api/dev/route.php"
-#define ROUTE_TYPE_MOTORCAR "motocar"
-#define ROUTE_TYPE_BICYCLE "bicycle"
-#define ROUTE_TYPE_FOOT "foot"
-#define YOURS_DISTANCE "distance"
-#define YOURS_DESCRIPTION "description"
-#define YOURS_COORDINATES "coordinates"
-
-// TODO: fix monav & ors url
-#define ROUTE_MONAV_URL "http://"
-#define ROUTE_ORS_URL "http:///"
-
-#define NAME_NOMINATIM_URL "http://nominatim.openstreetmap.org"
-#define NOMINATIM_RESULT "result"
-#define NOMINATIM_PLACE "place"
-#define NOMINATIM_ATTR_LON "lon"
-#define NOMINATIM_ATTR_LAT "lat"
-
-#define PINCH_ZOOM_MIN 0.25
-#define PINCH_ZOOM_MAX 3.0
-
-// Map sources
-// Currently the size of a tile must be 256*256
-// and the size of the map must be pow(2.0, z)*tile_size
-typedef struct _Map_Sources_Tab
-{
- Elm_Map_Sources source;
+enum _Name_Xml_Attribute
+{
+ NAME_XML_NONE,
+ NAME_XML_NAME,
+ NAME_XML_LON,
+ NAME_XML_LAT,
+ NAME_XML_LAST
+} Name_Xml_Attibute;
+
+enum _Track_Xml_Attribute
+{
+ TRACK_XML_NONE,
+ TRACK_XML_COORDINATES,
+ TRACK_XML_LAST
+} Track_Xml_Attibute;
+
+struct _Path
+{
+ Evas_Coord x, y;
+};
+
+struct _Region
+{
+ double lon, lat;
+};
+
+struct _Delayed_Data
+{
+ void (*func)(void *data);
+ Widget_Data *wd;
+ Elm_Map_Zoom_Mode mode;
+ int zoom;
+ double lon, lat;
+ Eina_List *markers;
+ Eina_List *overlays;
+};
+
+// Map Tile source
+// FIXME: Currently tile size must be 256*256
+// and the map size is pow(2.0, z) * (tile size)
+struct _Source_Tile
+{
const char *name;
int zoom_min;
int zoom_max;
- ElmMapSourceURLFunc url_cb;
- Elm_Map_Route_Sources route_source;
- ElmMapRouteSourceURLFunc route_url_cb;
- ElmMapNameSourceURLFunc name_url_cb;
-} Map_Sources_Tab;
-
-#define ZOOM_MAX 18
-
-//Zemm min is supposed to be 0
-static char *_mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char *_osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char *_cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char *_maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char *_module_url_cb(Evas_Object *obj, int x, int y, int zoom);
-static char * _custom1_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char * _custom2_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char * _custom3_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char * _custom4_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char * _custom5_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-static char * _custom6_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom);
-
-static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-/*
-static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
-static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
- */
-static char *_route_custom1_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-static char *_route_custom2_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-static char *_route_custom3_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-static char *_route_custom4_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-static char *_route_custom5_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-static char *_route_custom6_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
-/*
-static char *_route_module_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
- */
-
-static char *_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat);
-static char *_name_custom1_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
-static char *_name_custom2_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
-static char *_name_custom3_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
-static char *_name_custom4_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
-static char *_name_custom5_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
-static char *_name_custom6_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__);
-
-static Map_Sources_Tab map_sources_tab[] =
-{
- {ELM_MAP_SOURCE_MAPNIK, "Mapnik", 0, 18, _mapnik_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb},
- {ELM_MAP_SOURCE_OSMARENDER, "Osmarender", 0, 17, _osmarender_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb},
- {ELM_MAP_SOURCE_CYCLEMAP, "Cycle Map", 0, 17, _cyclemap_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb},
- {ELM_MAP_SOURCE_MAPLINT, "Maplint", 12, 16, _maplint_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb},
- {ELM_MAP_SOURCE_CUSTOM_1, "Custom 1", 0, 18, _custom1_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_1, _route_custom1_url_cb, _name_custom1_url_cb},
- {ELM_MAP_SOURCE_CUSTOM_2, "Custom 2", 0, 18, _custom2_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_2, _route_custom2_url_cb, _name_custom2_url_cb},
- {ELM_MAP_SOURCE_CUSTOM_3, "Custom 3", 0, 18, _custom3_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_3, _route_custom3_url_cb, _name_custom3_url_cb},
- {ELM_MAP_SOURCE_CUSTOM_4, "Custom 4", 0, 18, _custom4_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_4, _route_custom4_url_cb, _name_custom4_url_cb},
- {ELM_MAP_SOURCE_CUSTOM_5, "Custom 5", 0, 18, _custom5_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_5, _route_custom5_url_cb, _name_custom5_url_cb},
- {ELM_MAP_SOURCE_CUSTOM_6, "Custom 6", 0, 18, _custom6_url_cb, ELM_MAP_ROUTE_SOURCE_CUSTOM_6, _route_custom6_url_cb, _name_custom6_url_cb},
- {ELM_MAP_SOURCE_MODULE, "Module", 0, 18, _module_url_cb, ELM_MAP_ROUTE_SOURCE_YOURS, _yours_url_cb, _nominatim_url_cb}
+ Elm_Map_Module_Tile_Url_Func url_cb;
+ Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord;
+ Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo;
+ Elm_Map_Module_Tile_Scale_Func scale_cb;
};
-struct _Url_Data
+// Map Route Source
+struct _Source_Route
{
- Ecore_Con_Url *con_url;
+ const char *name;
+ Elm_Map_Module_Route_Url_Func url_cb;
+};
- FILE *fd;
- char *fname;
+// Map Name Source
+struct _Source_Name
+{
+ const char *name;
+ Elm_Map_Module_Name_Url_Func url_cb;
};
-struct _Elm_Map_Marker_Class
+struct _Color
{
- const char *style;
- int zoom_displayed;
-
- struct _Elm_Map_Marker_Class_Func {
- ElmMapMarkerGetFunc get;
- ElmMapMarkerDelFunc del; //if NULL the object will be destroyed with evas_object_del()
- ElmMapMarkerIconGetFunc icon_get;
- } func;
-
- struct { //this part is private, do not modify these values
- Eina_Bool set : 1;
- Evas_Coord edje_w, edje_h;
- } priv;
+ int r, g, b, a;
};
-struct _Elm_Map_Marker
+struct _Overlay_Group
{
Widget_Data *wd;
- Elm_Map_Marker_Class *clas;
- Elm_Map_Group_Class *clas_group;
- double longitude, latitude;
+ Elm_Map_Overlay *overlay; // virtual group type overlay
+ Elm_Map_Overlay *clas; // class overlay for this virtual group
+ Overlay_Default *ovl; // rendered overlay
+ Eina_List *members;
+ Eina_Bool in : 1;
+ Eina_Bool boss : 1;
+};
- Evas_Coord map_size;
- Evas_Coord x[ZOOM_MAX+1], y[ZOOM_MAX+1];
- void *data;
+struct _Overlay_Default
+{
+ Widget_Data *wd;
+ Evas_Coord w, h;
+
+ double lon, lat;
+ Evas_Coord x, y;
+
+ // Display priority is content > icon > clas_obj > clas_icon > layout
+ Evas_Object *content;
+ Evas_Object *icon;
- Marker_Group *groups[ZOOM_MAX+1];
+ Color c;
+ // if clas_content or icon exists, do not inherit from class
+ Evas_Object *clas_content; // Duplicated from class content
+ Evas_Object *clas_icon; // Duplicated from class icon
+ Evas_Object *layout;
+};
+struct _Overlay_Class
+{
+ Widget_Data *wd;
+ Eina_List *members;
+ int zoom_max;
Evas_Object *content;
+ Evas_Object *icon;
+};
+
+struct _Overlay_Bubble
+{
+ Widget_Data *wd;
+ Evas_Object *pobj;
+ Evas_Object *obj, *sc, *bx;
+ double lon, lat;
+ Evas_Coord x, y, w, h;
+};
+
+struct _Overlay_Route
+{
+ Widget_Data *wd;
+
+ Evas_Object *obj;
+ Eina_List *paths;
+ Eina_List *nodes;
+};
+
+struct _Overlay_Line
+{
+ Widget_Data *wd;
+ double flon, flat, tlon, tlat;
+ Evas_Object *obj;
+};
+
+struct _Overlay_Polygon
+{
+ Widget_Data *wd;
+ Eina_List *regions; // list of Regions
+ Evas_Object *obj;
+};
+
+struct _Overlay_Circle
+{
+ Widget_Data *wd;
+ double lon, lat;
+ double radius; // Intial pixel in intial view
+ double ratio; // initial-radius/map-size
+ Evas_Object *obj;
+};
+
+struct _Overlay_Scale
+{
+ Widget_Data *wd;
+ Evas_Coord x, y;
+ Evas_Coord w, h;
+ Evas_Object *obj;
+ };
+
+struct _Elm_Map_Overlay
+{
+ Widget_Data *wd;
+
+ Eina_Bool paused : 1;
+ Eina_Bool hide : 1;
+ Evas_Coord zoom_min;
+ Color c;
+ void *data; // user set data
+
+ Elm_Map_Overlay_Type type;
+ void *ovl; // Overlay Data for each type
+
+ Elm_Map_Overlay_Get_Cb cb;
+ void *cb_data;
+
+ // These are not used if overlay type is class or group
+ Overlay_Group *grp;
+};
+
+struct _Elm_Map_Marker_Class
+{
+ const char *style;
+ struct _Elm_Map_Marker_Class_Func
+ {
+ Elm_Map_Marker_Get_Func get;
+ Elm_Map_Marker_Del_Func del; //if NULL the object will be destroyed with evas_object_del()
+ Elm_Map_Marker_Icon_Get_Func icon_get;
+ } func;
};
struct _Elm_Map_Group_Class
{
+ Widget_Data *wd;
+
+ Eina_List *markers;
+ int zoom_displayed; // display the group if the zoom is >= to zoom_display
+ int zoom_grouped; // group the markers only if the zoom is <= to zoom_groups
const char *style;
void *data;
- int zoom_displayed; // display the group if the zoom is >= to zoom_display
- int zoom_grouped; // group the markers only if the zoom is <= to zoom_groups
+ struct
+ {
+ Elm_Map_Group_Icon_Get_Func icon_get;
+ } func;
+
Eina_Bool hide : 1;
+};
+
+struct _Marker_Bubble
+{
+ Widget_Data *wd;
+ Evas_Object *pobj;
+ Evas_Object *obj, *sc, *bx;
+};
- struct {
- ElmMapGroupIconGetFunc icon_get;
- } func;
+struct _Elm_Map_Marker
+{
+ Widget_Data *wd;
+ Elm_Map_Marker_Class *clas;
+ Elm_Map_Group_Class *group_clas;
+ double longitude, latitude;
+ Evas_Coord w, h;
+ Evas_Object *obj;
- struct { //this part is private, do not modify these values
- Eina_Bool set : 1;
- Evas_Coord edje_w, edje_h;
- Evas_Coord edje_max_w, edje_max_h;
+ Evas_Coord x, y;
+ Eina_Bool grouped : 1;
+ Eina_Bool leader : 1; // if marker is group leader
+ Marker_Group *group;
- Eina_List *objs_used;
- Eina_List *objs_notused;
- } priv;
+ Marker_Bubble *bubble;
+ Evas_Object *content;
+ void *data;
};
struct _Marker_Group
{
Widget_Data *wd;
- Eina_Matrixsparse_Cell *cell;
Elm_Map_Group_Class *clas;
+ Evas_Coord w, h;
+ Evas_Object *obj;
- Eina_List *markers;
- long long sum_x, sum_y;
Evas_Coord x, y;
- Evas_Coord w, h;
+ Eina_List *markers;
- Evas_Object *obj, *bubble, *sc, *bx, *rect;
- Eina_Bool open : 1;
- Eina_Bool bringin : 1;
- Eina_Bool update_nbelems : 1;
- Eina_Bool update_resize : 1;
- Eina_Bool update_raise : 1;
- Eina_Bool delete_object : 1;
+ Marker_Bubble *bubble;
};
struct _Elm_Map_Route
{
Widget_Data *wd;
- Route_Node *n;
- Route_Waypoint *w;
- Ecore_Con_Url *con_url;
-
- int type;
- int method;
- int x, y;
+ char *fname;
+ Elm_Map_Route_Type type;
+ Elm_Map_Route_Method method;
double flon, flat, tlon, tlat;
+ Elm_Map_Route_Cb cb;
+ void *data;
+ Ecore_File_Download_Job *job;
- Eina_List *nodes, *path;
- Eina_List *waypoint;
- struct {
- int node_count;
- int waypoint_count;
- const char *nodes;
- const char *waypoints;
- double distance; /* unit : km */
- } info;
-
- Eina_List *handlers;
- Url_Data ud;
-
- struct {
- int r;
- int g;
- int b;
- int a;
- } color;
-
- Eina_Bool inbound : 1;
+ Eina_List *nodes;
+ Eina_List *waypoint;
+ struct
+ {
+ int node_count;
+ int waypoint_count;
+ const char *nodes;
+ const char *waypoints;
+ double distance; /* unit : km */
+ } info;
+
+ Path_Node *n;
+ Path_Waypoint *w;
};
-struct _Route_Node
+struct _Path_Node
{
Widget_Data *wd;
int idx;
- struct {
- double lon, lat;
- char *address;
- } pos;
+ struct
+ {
+ double lon, lat;
+ char *address;
+ } pos;
};
-struct _Route_Waypoint
+struct _Path_Waypoint
{
Widget_Data *wd;
{
Widget_Data *wd;
- Ecore_Con_Url *con_url;
int method;
char *address;
double lon, lat;
- Url_Data ud;
- Ecore_Event_Handler *handler;
+
+ char *fname;
+ Ecore_File_Download_Job *job;
+ Elm_Map_Name_Cb cb;
+ void *data;
+};
+
+struct _Route_Dump
+{
+ int id;
+ char *fname;
+ double distance;
+ char *description;
+ char *coordinates;
+};
+
+struct _Name_Dump
+{
+ int id;
+ char *address;
+ double lon;
+ double lat;
};
struct _Grid_Item
{
+ Grid *g;
+
Widget_Data *wd;
Evas_Object *img;
- //Evas_Object *txt;
const char *file;
- struct {
- int x, y, w, h;
- } src, out;
- Eina_Bool want : 1;
- Eina_Bool download : 1;
- Eina_Bool have : 1;
+ const char *url;
+ int x, y; // Tile coordinate
+ Eina_Bool file_have : 1;
+
Ecore_File_Download_Job *job;
- int try_num;
};
struct _Grid
{
Widget_Data *wd;
- int tsize; // size of tile (tsize x tsize pixels)
int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
- int iw, ih; // size of image in pixels
- int w, h; // size of grid image in pixels (represented by grid)
- int gw, gh; // size of grid in tiles
+ int tw, th; // size of grid in tiles
Eina_Matrixsparse *grid;
};
+struct _Pan
+{
+ Evas_Object_Smart_Clipped_Data __clipped_data;
+ Widget_Data *wd;
+};
+
struct _Widget_Data
{
Evas_Object *obj;
Evas_Object *scr;
+ Evas_Object *ges;
Evas_Object *pan_smart;
- Evas_Object *rect;
- Evas_Object *sep_maps_markers; //map objects are below this object and marker objects are on top
- Pan *pan;
- Evas_Coord pan_x, pan_y, minw, minh;
+ Evas_Object *sep_maps_markers; // Tiles are below this and overlays are on top
+ Evas_Map *map;
+
+ Eina_Array *src_tile_mods;
+ Source_Tile *src_tile;
+ Eina_List *src_tiles;
+ const char **src_tile_names;
+
+ Eina_Array *src_route_mods;
+ Source_Route *src_route;
+ Eina_List *src_routes;
+ const char **src_route_names;
+
+ Eina_Array *src_name_mods;
+ Source_Name *src_name;
+ Eina_List *src_names;
+ const char **src_name_names;
+
+ int zoom_min, zoom_max;
+ int tsize;
int id;
+ Eina_List *grids;
+
int zoom;
- int zoom_method;
+ double zoom_detail;
+ double prev_lon, prev_lat;
+ Evas_Coord ox, oy;
+ struct
+ {
+ int w, h; // Current pixel width, heigth of a grid
+ int tile; // Current pixel size of a grid item
+ } size;
Elm_Map_Zoom_Mode mode;
-
- Ecore_Job *calc_job;
- Ecore_Timer *scr_timer;
- Ecore_Timer *long_timer;
+ struct
+ {
+ double zoom;
+ double diff;
+ int cnt;
+ } ani;
+ Ecore_Timer *zoom_timer;
Ecore_Animator *zoom_animator;
- double t_start, t_end;
- struct {
- int w, h;
- int ow, oh, nw, nh;
- struct {
- double x, y;
- } spos;
- } size;
- struct {
- Eina_Bool show : 1;
- Evas_Coord x, y ,w ,h;
- } show;
- int tsize;
- int nosmooth;
- int preload_num;
- Eina_List *grids;
- Eina_Bool resized : 1;
- Eina_Bool on_hold : 1;
- Eina_Bool paused : 1;
- Eina_Bool paused_markers : 1;
- struct {
- Eina_Bool enabled;
- double lon, lat;
- } center_on;
-
- Ecore_Job *markers_place_job;
- Eina_Matrixsparse *markers[ZOOM_MAX+1];
- Eina_List *cells_displayed; // list of Eina_Matrixsparse_Cell
- Evas_Coord markers_max_num;
- int marker_max_w, marker_max_h;
- int marker_zoom;
- Eina_List *opened_bubbles; //opened bubbles, list of Map_Group *
-
- Eina_List *groups_clas; // list of Elm_Map_Group_Class*
- Eina_List *markers_clas; // list of Elm_Map_Markers_Class*
-
- Elm_Map_Sources source;
- Elm_Map_Route_Sources route_source;
- Mod_Api *api;
- Eina_List *s_event_list;
int try_num;
int finish_num;
-
+ int download_num;
+ Eina_List *download_list;
+ Ecore_Idler *download_idler;
Eina_Hash *ua;
const char *user_agent;
- Eina_List *route;
- Evas_Event_Mouse_Down ev;
- Eina_List *names;
- int multi_count;
- struct {
- Evas_Coord cx, cy;
- double level, diff;
- } pinch;
+ Evas_Coord pan_x, pan_y;
+ Eina_List *delayed_jobs;
+
+ Ecore_Timer *scr_timer;
+ Ecore_Timer *long_timer;
+ Evas_Event_Mouse_Down ev;
+ Eina_Bool on_hold : 1;
+ Eina_Bool paused : 1;
- struct {
+ double pinch_zoom;
+ struct
+ {
Evas_Coord cx, cy;
double a, d;
- } rotate;
+ } rotate;
- struct {
- Evas_Coord cx, cy;
- double level;
- } pinch_zoom;
-};
+ Eina_Bool wheel_disabled : 1;
-struct _Mod_Api
-{
- Eina_Bool (*obj_hook) (Evas_Object *obj);
- Eina_Bool (*obj_unhook) (Evas_Object *obj);
- char * (*obj_url_request) (Evas_Object *obj, int x, int y, int zoom);
- Eina_Bool (*obj_convert_coord_into_geo) (const Evas_Object *obj, int zoom, int x, int y, int size, double *lon, double *lat);
- Eina_Bool (*obj_convert_geo_into_coord) (const Evas_Object *obj, int zoom, double lon, double lat, int size, int *x, int *y);
+ unsigned int markers_max_num;
+ Eina_Bool paused_markers : 1;
+ Eina_List *group_classes;
+ Eina_List *marker_classes;
+ Eina_List *markers;
+
+ Eina_List *routes;
+ Eina_List *track;
+ Eina_List *names;
+
+ Eina_List *overlays;
};
-struct _Pan
+
+static char *_mapnik_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
+static char *_osmarender_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
+static char *_cyclemap_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
+static char *_mapquest_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
+static char *_mapquest_aerial_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom);
+static char *_yours_url_cb(const Evas_Object *obj __UNUSED__, const char *type_name, int method, double flon, double flat, double tlon, double tlat);
+static char *_nominatim_url_cb(const Evas_Object *obj, int method, const char *name, double lon, double lat);
+/*
+static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
+static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat);
+*/
+static double _scale_cb(const Evas_Object *obj __UNUSED__, double lon __UNUSED__, double lat, int zoom);
+
+const Source_Tile src_tiles[] =
{
- Evas_Object_Smart_Clipped_Data __clipped_data;
- Widget_Data *wd;
+ {"Mapnik", 0, 18, _mapnik_url_cb, NULL, NULL, _scale_cb},
+ {"Osmarender", 0, 17, _osmarender_url_cb, NULL, NULL, _scale_cb},
+ {"CycleMap", 0, 16, _cyclemap_url_cb, NULL, NULL, _scale_cb},
+ {"MapQuest", 0, 18, _mapquest_url_cb, NULL, NULL, _scale_cb},
+ {"MapQuest Open Aerial", 0, 11, _mapquest_aerial_url_cb, NULL, NULL, _scale_cb}
};
-struct _Event
+// FIXME: Fix more open sources
+const Source_Route src_routes[] =
{
- int device;
-
- struct {
- Evas_Coord x, y;
- } start;
-
- struct {
- Evas_Coord x, y;
- } prev;
-
- Evas_Coord x, y, w, h;
+ {"Yours", _yours_url_cb} // http://www.yournavigation.org/
+ //{"Monav", _monav_url_cb},
+ //{"ORS", _ors_url_cb}, // http://www.openrouteservice.org
+};
- Evas_Object *object;
- Ecore_Timer *hold_timer;
+// Refer : http://wiki.openstreetmap.org/wiki/FAQ
+// meters per pixel when latitude is 0 (equator)
+// meters per pixel = _osm_scale_meter[zoom] * cos (latitude)
+const double _osm_scale_meter[] =
+{78206, 39135.758482, 19567.879241, 9783.939621, 4891.969810,
+ 2445.984905, 1222.992453, 611.496226, 305.748113, 152.874057, 76.437028,
+ 38.218514, 19.109257, 9.554629, 4.777314, 2.388657, 1.194329, 0.597164,
+ 0.29858};
- int pinch_start_dis;
- int pinch_dis;
-};
+// Scale in meters
+const double _scale_tb[] =
+{10000000, 5000000, 2000000, 1000000, 500000, 200000, 100000, 50000,
+ 20000, 10000, 5000, 2000, 1000, 500, 500, 200, 100, 50, 20, 10, 5, 2, 1};
-struct _Route_Dump
+// FIXME: Add more open sources
+const Source_Name src_names[] =
{
- int id;
- char *fname;
- double distance;
- char *description;
- char *coordinates;
+ {"Nominatim", _nominatim_url_cb}
};
-enum _Route_Xml_Attribute
-{
- ROUTE_XML_NONE,
- ROUTE_XML_DISTANCE,
- ROUTE_XML_DESCRIPTION,
- ROUTE_XML_COORDINATES,
- ROUTE_XML_LAST
-} Route_Xml_Attibute;
-
-struct _Name_Dump
-{
- int id;
- char *address;
- double lon;
- double lat;
-};
-
-enum _Name_Xml_Attribute
-{
- NAME_XML_NONE,
- NAME_XML_NAME,
- NAME_XML_LON,
- NAME_XML_LAT,
- NAME_XML_LAST
-} Name_Xml_Attibute;
-
-enum _Zoom_Method
-{
- ZOOM_METHOD_NONE,
- ZOOM_METHOD_IN,
- ZOOM_METHOD_OUT,
- ZOOM_METHOD_LAST
-} Zoom_Mode;
-
static const char *widtype = NULL;
+static Evas_Smart_Class parent_sc = EVAS_SMART_CLASS_INIT_NULL;
+static Evas_Smart_Class sc;
+static Evas_Smart *smart;
+static int idnum = 1;
-static const char SIG_CHANGED[] = "changed";
-static const char SIG_CLICKED[] = "clicked";
-static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
-static const char SIG_LOADED_DETAIL[] = "loaded,detail";
-static const char SIG_LOAD_DETAIL[] = "load,detail";
-static const char SIG_LONGPRESSED[] = "longpressed";
-static const char SIG_PRESS[] = "press";
-static const char SIG_SCROLL[] = "scroll";
-static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
-static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
-static const char SIG_ZOOM_CHANGE[] = "zoom,change";
-static const char SIG_ZOOM_START[] = "zoom,start";
-static const char SIG_ZOOM_STOP[] = "zoom,stop";
-static const char SIG_DOWNLOADED[] = "downloaded";
-static const char SIG_ROUTE_LOAD[] = "route,load";
-static const char SIG_ROUTE_LOADED[] = "route,loaded";
-static const char SIG_NAME_LOAD[] = "name,load";
-static const char SIG_NAME_LOADED[] = "name,loaded";
+static const char SIG_CLICKED[] = "clicked";
+static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
+static const char SIG_PRESS[] = "press";
+static const char SIG_LONGPRESSED[] = "longpressed";
+static const char SIG_SCROLL[] = "scroll";
+static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
+static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
+static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
+static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
+static const char SIG_ZOOM_START[] = "zoom,start";
+static const char SIG_ZOOM_STOP[] = "zoom,stop";
+static const char SIG_ZOOM_CHANGE[] = "zoom,change";
+static const char SIG_TILE_LOAD[] = "tile,load";
+static const char SIG_TILE_LOADED[] = "tile,loaded";
+static const char SIG_TILE_LOADED_FAIL[] = "tile,loaded,fail";
+static const char SIG_ROUTE_LOAD[] = "route,load";
+static const char SIG_ROUTE_LOADED[] = "route,loaded";
+static const char SIG_ROUTE_LOADED_FAIL[] = "route,loaded,fail";
+static const char SIG_NAME_LOAD[] = "name,load";
+static const char SIG_NAME_LOADED[] = "name,loaded";
+static const char SIG_NAME_LOADED_FAIL[] = "name,loaded,fail";
+static const char SIG_OVERLAY_CLICKED[] = "overlay,clicked";
static const Evas_Smart_Cb_Description _signals[] = {
- {SIG_CHANGED, ""},
{SIG_CLICKED, ""},
{SIG_CLICKED_DOUBLE, ""},
- {SIG_LOADED_DETAIL, ""},
- {SIG_LOAD_DETAIL, ""},
- {SIG_LONGPRESSED, ""},
{SIG_PRESS, ""},
+ {SIG_LONGPRESSED, ""},
{SIG_SCROLL, ""},
{SIG_SCROLL_DRAG_START, ""},
{SIG_SCROLL_DRAG_STOP, ""},
- {SIG_ZOOM_CHANGE, ""},
+ {SIG_SCROLL_ANIM_START, ""},
+ {SIG_SCROLL_ANIM_STOP, ""},
{SIG_ZOOM_START, ""},
{SIG_ZOOM_STOP, ""},
- {SIG_DOWNLOADED, ""},
+ {SIG_ZOOM_CHANGE, ""},
+ {SIG_TILE_LOAD, ""},
+ {SIG_TILE_LOADED, ""},
+ {SIG_TILE_LOADED_FAIL, ""},
{SIG_ROUTE_LOAD, ""},
{SIG_ROUTE_LOADED, ""},
+ {SIG_ROUTE_LOADED_FAIL, ""},
{SIG_NAME_LOAD, ""},
{SIG_NAME_LOADED, ""},
+ {SIG_NAME_LOADED_FAIL, ""},
+ {SIG_OVERLAY_CLICKED, ""},
{NULL, NULL}
};
-static void _pan_calculate(Evas_Object *obj);
-
-static Eina_Bool _hold_timer_cb(void *data);
-static void _rect_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _del_hook(Evas_Object *obj);
-static void _theme_hook(Evas_Object *obj);
-static void _on_focus_hook(void *data, Evas_Object *obj);
-static void _sizing_eval(Evas_Object *obj);
-static void _calc_job(void *data);
-static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src,
- Evas_Callback_Type type, void *event_info);
-static void grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
-static void grid_clear(Evas_Object *obj, Grid *g);
-static Grid *grid_create(Evas_Object *obj);
-static void grid_load(Evas_Object *obj, Grid *g);
-
-
-static void _group_object_create(Marker_Group *group);
-static void _group_object_free(Marker_Group *group);
-static void _group_open_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
-static void _group_bringin_cb(void *data, Evas_Object *obj, const char *emission, const char *soure);
-static void _group_bubble_create(Marker_Group *group);
-static void _group_bubble_free(Marker_Group *group);
-static void _group_bubble_place(Marker_Group *group);
-
-static int _group_bubble_content_update(Marker_Group *group);
-static void _group_bubble_content_free(Marker_Group *group);
-static void marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
-static void _bubble_sc_hits_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
-
-static void _mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
-static void _mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
-static void _mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
-
-static void _mouse_multi_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
-static void _mouse_multi_up(void *data, Evas *evas, Evas_Object *obj, void *event_info);
-static void _mouse_multi_move(void *data, Evas *evas, Evas_Object *obj, void *event_info);
-
-static void route_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
-
-static int
-get_multi_device(Evas_Object *obj)
+static void
+_edj_marker_size_get(Widget_Data *wd, Evas_Coord *w, Evas_Coord *h)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Eina_List *l;
- Event *ev;
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ EINA_SAFETY_ON_NULL_RETURN(w);
+ EINA_SAFETY_ON_NULL_RETURN(h);
- EINA_LIST_FOREACH(wd->s_event_list, l, ev)
- {
- if (ev->device) return ev->device;
- }
- return 0;
+ Evas_Object *edj;
+ const char *s;
+
+ edj = edje_object_add(evas_object_evas_get(wd->obj));
+ _elm_theme_object_set(wd->obj, edj, "map/marker", "radio",
+ elm_widget_style_get(wd->obj));
+ s = edje_object_data_get(edj, "size_w");
+ if (s) *w = atoi(s);
+ else *w = 0;
+ s = edje_object_data_get(edj, "size_h");
+ if (s) *h = atoi(s);
+ else *h = 0;
+ evas_object_del(edj);
}
-static int
-get_distance(Evas_Coord x1, Evas_Coord y1, Evas_Coord x2, Evas_Coord y2)
+static void
+_rotate(Evas_Coord x, Evas_Coord y, Evas_Coord cx, Evas_Coord cy, double degree, Evas_Coord *xx, Evas_Coord *yy)
{
- int dx = x1 - x2;
- int dy = y1 - y2;
- return sqrt((dx * dx) + (dy * dy));
+ double r = (degree * M_PI) / 180.0;
+ if (xx) *xx = ((x - cx) * cos(r)) + ((y - cy) * cos(r + M_PI_2)) + cx;
+ if (yy) *yy = ((x - cx) * sin(r)) + ((y - cy) * sin(r + M_PI_2)) + cy;
}
-static Event *
-create_event_object(void *data, Evas_Object *obj, int device)
+static void
+_obj_rotate(Widget_Data *wd, Evas_Object *obj)
{
- Widget_Data *wd = elm_widget_data_get(data);
- Event *ev = calloc(1, sizeof(Event));
+ Evas_Coord w, h, ow, oh;
+ evas_map_util_points_populate_from_object(wd->map, obj);
- EINA_SAFETY_ON_NULL_RETURN_VAL(ev, NULL);
+ evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
+ evas_object_image_size_get(obj, &w, &h);
+ if ((w > ow) || (h > oh))
+ {
+ evas_map_point_image_uv_set(wd->map, 0, 0, 0);
+ evas_map_point_image_uv_set(wd->map, 1, w, 0);
+ evas_map_point_image_uv_set(wd->map, 2, w, h);
+ evas_map_point_image_uv_set(wd->map, 3, 0, h);
+ }
+ evas_map_util_rotate(wd->map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
- ev->object = obj;
- ev->device = device;
- evas_object_geometry_get(obj, &ev->x, &ev->y, &ev->w, &ev->h);
- wd->s_event_list = eina_list_append(wd->s_event_list, ev);
- return ev;
+ evas_object_map_set(obj, wd->map);
+ evas_object_map_enable_set(obj, EINA_TRUE);
}
-static Event*
-get_event_object(void *data, int device)
+static void
+_obj_place(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
{
- Widget_Data *wd = elm_widget_data_get(data);
- Eina_List *l;
- Event *ev;
+ EINA_SAFETY_ON_NULL_RETURN(obj);
- EINA_LIST_FOREACH(wd->s_event_list, l, ev)
- {
- if (ev->device == device) break;
- ev = NULL;
- }
- return ev;
+ evas_object_move(obj, x, y);
+ evas_object_resize(obj, w, h);
+ evas_object_show(obj);
}
static void
-destroy_event_object(void *data, Event *ev)
+_coord_to_region_convert(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord size, double *lon, double *lat)
{
- Widget_Data *wd = elm_widget_data_get(data);
- EINA_SAFETY_ON_NULL_RETURN(ev);
- ev->pinch_dis = 0;
- wd->s_event_list = eina_list_remove(wd->s_event_list, ev);
- if (ev->hold_timer)
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ int zoom = floor(log(size / wd->size.tile) / log(2));
+ if ((wd->src_tile) && (wd->src_tile->coord_to_geo))
{
- ecore_timer_del(ev->hold_timer);
- ev->hold_timer = NULL;
+ if (wd->src_tile->coord_to_geo(wd->obj, zoom, x, y, size, lon, lat))
+ return;
}
- free(ev);
-}
-static Mod_Api *
-module(Evas_Object *obj __UNUSED__)
-{
- static Elm_Module *m = NULL;
- if (m) goto ok;
- if (!(m = _elm_module_find_as("map/api"))) return NULL;
-
- m->api = malloc(sizeof(Mod_Api));
- if (!m->api) return NULL;
- ((Mod_Api *)(m->api) )->obj_hook =
- _elm_module_symbol_get(m, "obj_hook");
- ((Mod_Api *)(m->api) )->obj_unhook =
- _elm_module_symbol_get(m, "obj_unhook");
- ((Mod_Api *)(m->api) )->obj_url_request =
- _elm_module_symbol_get(m, "obj_url_request");
- ((Mod_Api *)(m->api) )->obj_convert_coord_into_geo =
- _elm_module_symbol_get(m, "obj_convert_coord_into_geo");
- ((Mod_Api *)(m->api) )->obj_convert_geo_into_coord =
- _elm_module_symbol_get(m, "obj_convert_geo_into_coord");
-ok:
- return m->api;
+ if (lon) *lon = (x / (double)size * 360.0) - 180;
+ if (lat)
+ {
+ double n = ELM_PI - (2.0 * ELM_PI * y / size);
+ *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
+ }
}
static void
-obj_rotate_zoom(void *data, Evas_Object *obj)
+_region_to_coord_convert(Widget_Data *wd, double lon, double lat, Evas_Coord size, Evas_Coord *x, Evas_Coord *y)
{
- ELM_CHECK_WIDTYPE(data, widtype);
- Widget_Data *wd = elm_widget_data_get(data);
- if ((!wd->pinch.cx) && (!wd->pinch.cy))
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ int zoom = floor(log(size / 256) / log(2));
+ if ((wd->src_tile) && (wd->src_tile->geo_to_coord))
{
- wd->pinch.cx = wd->rotate.cx;
- wd->pinch.cy = wd->rotate.cy;
+ if (wd->src_tile->geo_to_coord(wd->obj, zoom, lon, lat, size, x, y)) return;
}
- Evas_Map *map = evas_map_new(4);
- if (!map) return;
-
- evas_map_util_points_populate_from_object_full(map, obj, 0);
- evas_map_util_zoom(map, wd->pinch.level, wd->pinch.level, wd->pinch.cx, wd->pinch.cy);
- evas_map_util_rotate(map, wd->rotate.d, wd->rotate.cx, wd->rotate.cy);
- evas_object_map_enable_set(obj, EINA_TRUE);
- evas_object_map_set(obj, map);
- evas_map_free(map);
+ if (x) *x = floor((lon + 180.0) / 360.0 * size);
+ if (y)
+ *y = floor((1.0 - log(tan(lat * ELM_PI / 180.0) + (1.0 / cos(lat * ELM_PI / 180.0)))
+ / ELM_PI) / 2.0 * size);
}
static void
-route_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py, Evas_Coord ox __UNUSED__, Evas_Coord oy __UNUSED__, Evas_Coord ow, Evas_Coord oh)
+_viewport_coord_get(Widget_Data *wd, Evas_Coord *vx, Evas_Coord *vy, Evas_Coord *vw, Evas_Coord *vh)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
+ EINA_SAFETY_ON_NULL_RETURN(wd);
- Eina_List *lr, *lp, *ln;
- Route_Node *n;
- Evas_Object *p;
- Elm_Map_Route *r;
- int nodes;
- int x, y, rx, ry;
- Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
+ Evas_Coord x, y, w, h;
+ elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
+ elm_smart_scroller_child_viewport_size_get(wd->scr, &w, &h);
+ if (w > wd->size.w) x -= ((w - wd->size.w) / 2);
+ if (h > wd->size.h) y -= ((h - wd->size.h) / 2);
+ if (vx) *vx = x;
+ if (vy) *vy = y;
+ if (vw) *vw = w;
+ if (vh) *vh = h;
+}
- EINA_LIST_FOREACH(wd->route, lr, r)
- {
- EINA_LIST_FOREACH(r->path, lp, p)
- {
- evas_object_hide(p);
- }
+// Map coordinates to canvas geometry without rotate
+static void
+_coord_to_canvas_no_rotate(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord *xx, Evas_Coord *yy)
+{
+ Evas_Coord vx, vy, sx, sy;
+ _viewport_coord_get(wd, &vx, &vy, NULL, NULL);
+ evas_object_geometry_get(wd->pan_smart, &sx, &sy, NULL, NULL);
+ if (xx) *xx = x - vx + sx;
+ if (yy) *yy = y - vy + sy;
+}
- evas_object_geometry_get(wd->rect, &rx, &ry, NULL, NULL);
- nodes = eina_list_count(r->nodes);
+// Map coordinates to canvas geometry
+static void
+_coord_to_canvas(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord *xx, Evas_Coord *yy)
+{
+ _coord_to_canvas_no_rotate(wd, x, y, &x, &y);
+ _rotate(x, y, wd->rotate.cx, wd->rotate.cy, wd->rotate.d, &x, &y);
+ if (xx) *xx = x;
+ if (yy) *yy = y;
+}
- EINA_LIST_FOREACH(r->nodes, ln, n)
- {
- if ((!wd->zoom) || ((n->idx) &&
- ((n->idx % (int)ceil((double)nodes/(double)size*100.0))))) continue;
- if (r->inbound)
- {
- elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
- if ((x >= px - ow) && (x <= (px + ow*2)) &&
- (y >= py - oh) && (y <= (py + oh*2)))
- {
- x = x - px + rx;
- y = y - py + ry;
-
- p = eina_list_nth(r->path, n->idx);
- evas_object_line_xy_set(p, r->x, r->y, x, y);
- evas_object_color_set(p, r->color.r, r->color.g, r->color.b, r->color.a);
- evas_object_raise(p);
- obj_rotate_zoom(obj, p);
- evas_object_show(p);
- r->x = x;
- r->y = y;
- }
- else r->inbound = EINA_FALSE;
- }
- else
- {
- elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y);
- if ((x >= px - ow) && (x <= (px + ow*2)) &&
- (y >= py - oh) && (y <= (py + oh*2)))
- {
- r->x = x - px + rx;
- r->y = y - py + ry;
- r->inbound = EINA_TRUE;
- }
- else r->inbound = EINA_FALSE;
- }
- }
- r->inbound = EINA_FALSE;
- }
+// Canvas geometry to map coordinates
+static void
+_canvas_to_coord(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Evas_Coord *xx, Evas_Coord *yy)
+{
+ Evas_Coord vx, vy, sx, sy;
+ _viewport_coord_get(wd, &vx, &vy, NULL, NULL);
+ evas_object_geometry_get(wd->pan_smart, &sx, &sy, NULL, NULL);
+ _rotate(x - sx + vx, y - sy + vy, wd->rotate.cx - sx + vx,
+ wd->rotate.cy - sy + vy, -wd->rotate.d, &x, &y);
+ if (xx) *xx = x;
+ if (yy) *yy = y;
}
static void
-rect_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
+_region_show(void *data)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Evas_Coord ax, ay, gw, gh, hh, ww;
- if (!wd) return;
- evas_object_geometry_get(wd->rect, NULL, NULL, &ww, &hh);
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Delayed_Data *dd = data;
+ int x, y, w, h;
- ax = 0;
- ay = 0;
- gw = wd->size.w;
- gh = wd->size.h;
+ _region_to_coord_convert(dd->wd, dd->lon, dd->lat, dd->wd->size.w, &x, &y);
+ _viewport_coord_get(dd->wd, NULL, NULL, &w, &h);
+ x = x - (w / 2);
+ y = y - (h / 2);
+ elm_smart_scroller_child_region_show(dd->wd->scr, x, y, w, h);
+ evas_object_smart_changed(dd->wd->pan_smart);
+}
- if ((ww == gw) && (hh == gh)) return;
+static void
+_bubble_update(Marker_Bubble *bubble, Eina_List *contents)
+{
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ EINA_SAFETY_ON_NULL_RETURN(contents);
- if (ow > gw) ax = (ow - gw) / 2;
- if (oh > gh) ay = (oh - gh) / 2;
- evas_object_move(wd->rect,
- ox + 0 - px + ax,
- oy + 0 - py + ay);
- evas_object_resize(wd->rect, gw, gh);
+ Eina_List *l;
+ Evas_Object *c;
- if (wd->show.show)
- {
- wd->show.show = EINA_FALSE;
- elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
- }
+ elm_box_clear(bubble->bx);
+ EINA_LIST_FOREACH(contents, l, c) elm_box_pack_end(bubble->bx, c);
}
static void
-marker_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
+_bubble_place(Marker_Bubble *bubble)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Evas_Coord ax, ay, gw, gh, tx, ty;
- Eina_List *l, *markers;
- Eina_Matrixsparse_Cell *cell;
- Marker_Group *group;
- int xx, yy, ww, hh;
- char buf[PATH_MAX];
- int y, x;
- int g_xx, g_yy, g_hh, g_ww;
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
- if (!wd) return;
- if (g != eina_list_data_get(wd->grids)) return;
-
- ax = 0;
- ay = 0;
- gw = wd->size.w;
- gh = wd->size.h;
- if (ow > gw) ax = (ow - gw) / 2;
- if (oh > gh) ay = (oh - gh) / 2;
+ Evas_Coord x, y, w, h;
+ Evas_Coord xx, yy, ww, hh;
+ const char *s;
- if (wd->zoom != wd->marker_zoom)
- {
- EINA_LIST_FREE(wd->cells_displayed, cell)
- {
- EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
- {
- if (group->obj) _group_object_free(group);
- }
- }
- }
- wd->marker_zoom = wd->zoom;
+ if ((!bubble->obj) || (!bubble->pobj)) return;
+ evas_object_geometry_get(bubble->pobj, &x, &y, &w, NULL);
- if ((wd->paused_markers)
- && ((wd->size.nw != wd->size.w) || (wd->size.nh != wd->size.h)) )
- return;
+ s = edje_object_data_get(bubble->obj, "size_w");
+ if (s) ww = atoi(s);
+ else ww = 0;
- g_xx = wd->pan_x / wd->tsize;
- if (g_xx < 0) g_xx = 0;
- g_yy = wd->pan_y / wd->tsize;
- if (g_yy < 0) g_yy = 0;
- g_ww = ow / wd->tsize + 1;
- if (g_xx + g_ww >= g->gw) g_ww = g->gw - g_xx - 1;
- g_hh = oh / wd->tsize + 1;
- if (g_yy + g_hh >= g->gh) g_hh = g->gh - g_yy - 1;
+ edje_object_size_min_calc(bubble->obj, NULL, &hh);
+ s = edje_object_data_get(bubble->obj, "size_h");
+ if (s) h = atoi(s);
+ else h = 0;
+ if (hh < h) hh = h;
- //hide groups no more displayed
- EINA_LIST_FREE(wd->cells_displayed, cell)
- {
- eina_matrixsparse_cell_position_get(cell, (unsigned long *)&y, (unsigned long *)&x);
- if ((y < g_yy) || (y > g_yy + g_hh) || (x < g_xx) || (x > g_xx + g_ww))
- {
- EINA_LIST_FOREACH(eina_matrixsparse_cell_data_get(cell), l, group)
- {
- if (group->obj) _group_object_free(group);
- }
- }
- }
+ xx = x + (w / 2) - (ww / 2);
+ yy = y - hh;
- for (y = g_yy; y <= g_yy + g_hh; y++)
- {
- for (x = g_xx; x <= g_xx + g_ww; x++)
- {
- if (!wd->markers[wd->zoom]) continue;
- eina_matrixsparse_cell_idx_get(wd->markers[wd->zoom], y, x, &cell);
- if (!cell) continue;
- wd->cells_displayed = eina_list_append(wd->cells_displayed, cell);
- markers = eina_matrixsparse_cell_data_get(cell);
- EINA_LIST_FOREACH(markers, l, group)
- {
- if (!group->markers) continue;
- if (group->clas->zoom_displayed > wd->zoom) continue;
+ _obj_place(bubble->obj, xx, yy, ww, hh);
+ evas_object_raise(bubble->obj);
+}
- xx = group->x;
- yy = group->y;
- ww = group->w;
- hh = group->h;
+static void
+_bubble_sc_hints_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Marker_Bubble *bubble = data;
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ _bubble_place(data);
+}
- if (eina_list_count(group->markers) == 1)
- {
- Elm_Map_Marker *m = eina_list_data_get(group->markers);
- ww = m->clas->priv.edje_w;
- hh = m->clas->priv.edje_h;
- }
+static void
+_bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Marker_Bubble *bubble = data;
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ _bubble_place(bubble);
+}
- if (ww <= 0) ww = 1;
- if (hh <= 0) hh = 1;
+static void
+_bubble_hide_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Marker_Bubble *bubble = data;
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ evas_object_hide(bubble->obj);
+}
- if ((gw != g->w) && (g->w > 0))
- {
- tx = xx;
- xx = ((long long )gw * xx) / g->w;
- ww = (((long long)gw * (tx + ww)) / g->w) - xx;
- }
- if ((gh != g->h) && (g->h > 0))
- {
- ty = yy;
- yy = ((long long)gh * yy) / g->h;
- hh = (((long long)gh * (ty + hh)) / g->h) - yy;
- }
+static void
+_bubble_show_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Marker_Bubble *bubble = data;
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ _bubble_place(bubble);
+}
- if ((!group->clas->hide)
- && (xx-px+ax+ox >= ox) && (xx-px+ax+ox<= ox+ow)
- && (yy-py+ay+oy >= oy) && (yy-py+ay+oy<= oy+oh))
- {
- if (!group->obj) _group_object_create(group);
-
- if (group->update_nbelems)
- {
- group->update_nbelems = EINA_FALSE;
- if (eina_list_count(group->markers) > 1)
- {
- snprintf(buf, sizeof(buf), "%d", eina_list_count(group->markers));
- edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", buf);
- }
- else
- edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", "");
- }
- evas_object_move(group->obj,
- xx - px + ax + ox - ww/2,
- yy - py + ay + oy - hh/2);
- if ((!wd->paused_markers) || (group->update_resize))
- {
- group->update_resize = EINA_FALSE;
- evas_object_resize(group->obj, ww, hh);
- obj_rotate_zoom(obj, group->obj);
- }
- if (group->update_raise)
- {
- group->update_raise = EINA_FALSE;
- evas_object_raise(group->obj);
- obj_rotate_zoom(obj, group->obj);
- evas_object_show(group->obj);
- }
- if (group->bubble) _group_bubble_place(group);
- }
- else if (group->obj)
- {
- _group_object_free(group);
- }
- }
- }
- }
+static void
+_bubble_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Marker_Bubble *bubble = data;
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ _bubble_place(bubble);
}
static void
-grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
+_bubble_free(Marker_Bubble* bubble)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Evas_Coord ax, ay, gw, gh, tx, ty;
- int xx, yy, ww, hh;
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
- if (!wd) return;
+ evas_object_del(bubble->bx);
+ evas_object_del(bubble->sc);
+ evas_object_del(bubble->obj);
+ free(bubble);
+}
- ax = 0;
- ay = 0;
- gw = wd->size.w;
- gh = wd->size.h;
- if (ow > gw) ax = (ow - gw) / 2;
- if (oh > gh) ay = (oh - gh) / 2;
+static Marker_Bubble*
+_bubble_create(Evas_Object *pobj, Widget_Data *wd)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(pobj, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
- Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
- Eina_Matrixsparse_Cell *cell;
+ Marker_Bubble *bubble = ELM_NEW(Marker_Bubble);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(bubble, NULL);
- EINA_ITERATOR_FOREACH(it, cell)
- {
- Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
+ bubble->wd = wd;
+ bubble->pobj = pobj;
+ evas_object_event_callback_add(pobj, EVAS_CALLBACK_HIDE, _bubble_hide_cb,
+ bubble);
+ evas_object_event_callback_add(pobj, EVAS_CALLBACK_SHOW, _bubble_show_cb,
+ bubble);
+ evas_object_event_callback_add(pobj, EVAS_CALLBACK_MOVE, _bubble_move_cb,
+ bubble);
- xx = gi->out.x;
- yy = gi->out.y;
- ww = gi->out.w;
- hh = gi->out.h;
- if ((gw != g->w) && (g->w > 0))
- {
- tx = xx;
- xx = ((long long )gw * xx) / g->w;
- ww = (((long long)gw * (tx + ww)) / g->w) - xx;
- }
- if ((gh != g->h) && (g->h > 0))
- {
- ty = yy;
- yy = ((long long)gh * yy) / g->h;
- hh = (((long long)gh * (ty + hh)) / g->h) - yy;
- }
- evas_object_move(gi->img,
- xx - px + ax + ox,
- yy - py + ay + oy);
+ bubble->obj = edje_object_add(evas_object_evas_get(pobj));
+ _elm_theme_object_set(wd->obj, bubble->obj , "map", "marker_bubble",
+ elm_widget_style_get(wd->obj));
+ evas_object_event_callback_add(bubble->obj, EVAS_CALLBACK_MOUSE_UP,
+ _bubble_mouse_up_cb, bubble);
- evas_object_resize(gi->img, ww, hh);
+ bubble->sc = elm_scroller_add(bubble->obj);
+ elm_widget_style_set(bubble->sc, "map_bubble");
+ elm_scroller_content_min_limit(bubble->sc, EINA_FALSE, EINA_TRUE);
+ elm_scroller_policy_set(bubble->sc, ELM_SCROLLER_POLICY_AUTO,
+ ELM_SCROLLER_POLICY_OFF);
+ elm_scroller_bounce_set(bubble->sc, _elm_config->thumbscroll_bounce_enable,
+ EINA_FALSE);
+ edje_object_part_swallow(bubble->obj, "elm.swallow.content", bubble->sc);
+ evas_object_event_callback_add(bubble->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _bubble_sc_hints_changed_cb, bubble);
- obj_rotate_zoom(obj, gi->img);
- /*evas_object_move(gi->txt,
- xx - px + ax + ox,
- yy - py + ay + oy);
+ bubble->bx = elm_box_add(bubble->sc);
+ evas_object_size_hint_align_set(bubble->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(bubble->bx, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_box_horizontal_set(bubble->bx, EINA_TRUE);
+ elm_object_content_set(bubble->sc, bubble->bx);
- evas_object_resize(gi->txt, ww, hh);
- */
- }
- eina_iterator_free(it);
+ return bubble;
}
static void
-grid_clear(Evas_Object *obj, Grid *g)
+_marker_group_update(Marker_Group* group, Elm_Map_Group_Class *clas, Eina_List *markers)
{
- Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(group);
+ EINA_SAFETY_ON_NULL_RETURN(clas);
+ EINA_SAFETY_ON_NULL_RETURN(markers);
+ Widget_Data *wd = clas->wd;
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
char buf[PATH_MAX];
+ Eina_List *l;
+ Elm_Map_Marker *marker;
+ int cnt = 0;
+ int sum_x = 0, sum_y = 0;
- if (!wd) return;
- if (!g->grid) return;
+ EINA_LIST_FOREACH(markers, l, marker)
+ {
+ sum_x += marker->x;
+ sum_y += marker->y;
+ cnt++;
+ }
- Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
- Eina_Matrixsparse_Cell *cell;
+ group->x = sum_x / cnt;
+ group->y = sum_y / cnt;
+ _edj_marker_size_get(wd, &group->w, &group->h);
+ group->w *=2;
+ group->h *=2;
+ group->clas = clas;
+ group->markers = markers;
- snprintf(buf, sizeof(buf), DEST_DIR_ZOOM_PATH, wd->id, g->zoom);
- ecore_file_recursive_rm(buf);
+ if (clas->style) elm_layout_theme_set(group->obj, "map/marker", clas->style,
+ elm_widget_style_get(wd->obj));
+ else elm_layout_theme_set(group->obj, "map/marker", "radio",
+ elm_widget_style_get(wd->obj));
- EINA_ITERATOR_FOREACH(it, cell)
- {
- Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
- evas_object_del(gi->img);
- //evas_object_del(gi->txt);
- if (gi->want)
- {
- gi->want = EINA_FALSE;
- wd->preload_num--;
- if (!wd->preload_num)
- {
- edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
- "elm,state,busy,stop", "elm");
- evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
- }
- }
+ if (clas->func.icon_get)
+ {
+ Evas_Object *icon = NULL;
- if (gi->job)
- {
- DBG("DOWNLOAD abort %s", gi->file);
- ecore_file_download_abort(gi->job);
- ecore_file_remove(gi->file);
- gi->job = NULL;
- wd->try_num--;
- }
- if (gi->file)
- eina_stringshare_del(gi->file);
+ icon = elm_object_part_content_get(group->obj, "elm.icon");
+ if (icon) evas_object_del(icon);
- free(gi);
+ icon = clas->func.icon_get(wd->obj, clas->data);
+ elm_object_part_content_set(group->obj, "elm.icon", icon);
}
- eina_matrixsparse_free(g->grid);
- eina_iterator_free(it);
- g->grid = NULL;
- g->gw = 0;
- g->gh = 0;
+ snprintf(buf, sizeof(buf), "%d", cnt);
+ edje_object_part_text_set(elm_layout_edje_get(group->obj), "elm.text", buf);
+
+ if (group->bubble)
+ {
+ Eina_List *contents = NULL;
+
+ EINA_LIST_FOREACH(group->markers, l, marker)
+ {
+ Evas_Object *c = marker->clas->func.get(marker->wd->obj,
+ marker, marker->data);
+ if (c) contents = eina_list_append(contents, c);
+ }
+ _bubble_update(group->bubble, contents);
+ }
}
static void
-_tile_update(Grid_Item *gi)
+_marker_group_bubble_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
{
- gi->want = EINA_FALSE;
- gi->download = EINA_FALSE;
- evas_object_image_file_set(gi->img, gi->file, NULL);
- if (evas_object_image_load_error_get(gi->img) != EVAS_LOAD_ERROR_NONE)
- ecore_file_remove(gi->file);
-
- obj_rotate_zoom(gi->wd->obj, gi->img);
- evas_object_show(gi->img);
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Marker_Group *group = data;
+ Eina_List *l;
+ Elm_Map_Marker *marker;
+ Eina_List *contents = NULL;
- //evas_object_text_text_set(gi->txt, gi->file);
- //evas_object_show(gi->txt);
+ if (!group->bubble) group->bubble = _bubble_create(group->obj, group->wd);
- gi->have = EINA_TRUE;
- gi->wd->preload_num--;
- if (!gi->wd->preload_num)
+ EINA_LIST_FOREACH(group->markers, l, marker)
{
- edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr),
- "elm,state,busy,stop", "elm");
- evas_object_smart_callback_call(gi->wd->obj, SIG_LOADED_DETAIL, NULL);
+ if (group->wd->markers_max_num <= eina_list_count(contents)) break;
+ Evas_Object *c = marker->clas->func.get(marker->wd->obj,
+ marker, marker->data);
+ if (c) contents = eina_list_append(contents, c);
}
+ _bubble_update(group->bubble, contents);
+ _bubble_place(group->bubble);
}
-
static void
-_tile_downloaded(void *data, const char *file __UNUSED__, int status)
+_marker_group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
{
- Grid_Item *gi = data;
+ EINA_SAFETY_ON_NULL_RETURN(data);
- gi->download = EINA_FALSE;
- gi->job = NULL;
+ double lon, lat;
+ Marker_Group *group = data;
+ _coord_to_region_convert(group->wd, group->x, group->y, group->wd->size.w,
+ &lon, &lat);
+ elm_map_region_bring_in(group->wd->obj, lon, lat);
+}
+
+static void
+_marker_group_free(Marker_Group* group)
+{
+ EINA_SAFETY_ON_NULL_RETURN(group);
- DBG("DOWNLOAD done %s", gi->file);
- if ((gi->want) && (!status)) _tile_update(gi);
+ if (group->bubble) _bubble_free(group->bubble);
- if (status)
- {
- DBG("Download failed %s (%d) ", gi->file, status);
- ecore_file_remove(gi->file);
- }
- else
- gi->wd->finish_num++;
+ eina_list_free(group->markers);
+ evas_object_del(group->obj);
- evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOADED, NULL);
+ free(group);
}
-static Grid *
-grid_create(Evas_Object *obj)
+static Marker_Group*
+_marker_group_create(Widget_Data *wd)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Grid *g;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
- g = calloc(1, sizeof(Grid));
+ Marker_Group *group = ELM_NEW(Marker_Group);
- g->zoom = wd->zoom;
- g->tsize = wd->tsize;
- g->wd = wd;
+ group->wd = wd;
+ group->obj = elm_layout_add(wd->obj);
+ evas_object_smart_member_add(group->obj, wd->pan_smart);
+ evas_object_stack_above(group->obj, wd->sep_maps_markers);
+ elm_layout_theme_set(group->obj, "map/marker", "radio",
+ elm_widget_style_get(wd->obj));
+ edje_object_signal_callback_add(elm_layout_edje_get(group->obj),
+ "open", "elm", _marker_group_bubble_open_cb,
+ group);
+ edje_object_signal_callback_add(elm_layout_edje_get(group->obj),
+ "bringin", "elm", _marker_group_bringin_cb,
+ group);
+ return group;
+}
- if (g->zoom > map_sources_tab[wd->source].zoom_max) return NULL;
- if (g->zoom < map_sources_tab[wd->source].zoom_min) return NULL;
+static void
+_marker_update(Elm_Map_Marker *marker)
+{
+ EINA_SAFETY_ON_NULL_RETURN(marker);
+ Elm_Map_Marker_Class *clas = marker->clas;
+ EINA_SAFETY_ON_NULL_RETURN(clas);
- int size = pow(2.0, wd->zoom);
- g->gw = size;
- g->gh = size;
+ if (clas->style) elm_layout_theme_set(marker->obj, "map/marker", clas->style,
+ elm_widget_style_get(marker->wd->obj));
+ else elm_layout_theme_set(marker->obj, "map/marker", "radio",
+ elm_widget_style_get(marker->wd->obj));
- g->w = g->tsize * g->gw;
- g->h = g->tsize * g->gh;
+ if (clas->func.icon_get)
+ {
+ Evas_Object *icon = NULL;
- g->grid = eina_matrixsparse_new(g->gh, g->gw, NULL, NULL);
+ icon = elm_object_part_content_get(marker->obj, "elm.icon");
+ if (icon) evas_object_del(icon);
- return g;
+ icon = clas->func.icon_get(marker->wd->obj, marker, marker->data);
+ elm_object_part_content_set(marker->obj, "elm.icon", icon);
+ }
+ _region_to_coord_convert(marker->wd, marker->longitude, marker->latitude,
+ marker->wd->size.w, &(marker->x), &(marker->y));
+
+ if (marker->bubble)
+ {
+ if (marker->content) evas_object_del(marker->content);
+ if (marker->clas->func.get)
+ marker->content = marker->clas->func.get(marker->wd->obj, marker,
+ marker->data);
+ if (marker->content)
+ {
+ Eina_List *contents = NULL;
+ contents = eina_list_append(contents, marker->content);
+ _bubble_update(marker->bubble, contents);
+ }
+ }
}
+
+
static void
-grid_load(Evas_Object *obj, Grid *g)
+_marker_place(Widget_Data *wd)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- int x, y;
- int size;
- Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, tx, ty, gw, gh, xx, yy, ww, hh;
- Eina_Iterator *it;
- Eina_Matrixsparse_Cell *cell;
- Grid_Item *gi;
+ EINA_SAFETY_ON_NULL_RETURN(wd);
- if (!wd) return;
- evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
- evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
+ Eina_List *l;
- gw = wd->size.w;
- gh = wd->size.h;
+ Elm_Map_Marker *marker;
+ Elm_Map_Group_Class *group_clas;
- if ((gw <= 0) || (gh <= 0)) return;
+ Evas_Coord gw, gh;
- size = g->tsize;
- if ((gw != g->w) && (g->w > 0))
- size = ((long long)gw * size) / g->w;
- if (size < (g->tsize / 2)) return; // else we will load to much tiles
+ if (wd->paused_markers || (!eina_list_count(wd->markers))) return;
- it = eina_matrixsparse_iterator_new(g->grid);
+ _edj_marker_size_get(wd, &gw, &gh);
+ gw *= 2;
+ gh *= 2;
- EINA_ITERATOR_FOREACH(it, cell)
+ EINA_LIST_FOREACH(wd->markers, l, marker)
{
- gi = eina_matrixsparse_cell_data_get(cell);
-
- xx = gi->out.x;
- yy = gi->out.y;
- ww = gi->out.w;
- hh = gi->out.h;
+ _marker_update(marker);
+ marker->grouped = EINA_FALSE;
+ marker->leader = EINA_FALSE;
+ }
- if ((gw != g->w) && (g->w > 0))
- {
- tx = xx;
- xx = ((long long )gw * xx) / g->w;
- ww = (((long long)gw * (tx + ww)) / g->w) - xx;
- }
- if ((gh != g->h) && (g->h > 0))
+ EINA_LIST_FOREACH(wd->group_classes, l, group_clas)
+ {
+ Eina_List *ll;
+ EINA_LIST_FOREACH(group_clas->markers, ll, marker)
{
- ty = yy;
- yy = ((long long)gh * yy) / g->h;
- hh = (((long long)gh * (ty + hh)) / g->h) - yy;
- }
+ Eina_List *lll;
+ Elm_Map_Marker *mm;
+ Eina_List *markers = NULL;
- if (!ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
- yy - wd->pan_y + oy,
- ww, hh,
- cvx, cvy, cvw, cvh))
- {
- if (gi->want)
+ if (marker->grouped) continue;
+ if (group_clas->zoom_grouped < wd->zoom)
{
- evas_object_hide(gi->img);
- //evas_object_hide(gi->txt);
- evas_object_image_file_set(gi->img, NULL, NULL);
- gi->want = EINA_FALSE;
- gi->have = EINA_FALSE;
-
- if (gi->job)
- {
- DBG("DOWNLOAD abort %s", gi->file);
- ecore_file_download_abort(gi->job);
- ecore_file_remove(gi->file);
- gi->job = NULL;
- wd->try_num--;
- }
- gi->download = EINA_FALSE;
- wd->preload_num--;
- if (!wd->preload_num)
- {
- edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
- "elm,state,busy,stop", "elm");
- evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL,
- NULL);
- }
-
+ marker->grouped = EINA_FALSE;
+ continue;
}
- else if (gi->have)
+
+ EINA_LIST_FOREACH(group_clas->markers, lll, mm)
{
- evas_object_hide(gi->img);
- //evas_object_hide(gi->txt);
- evas_object_image_preload(gi->img, 1);
- evas_object_image_file_set(gi->img, NULL, NULL);
- gi->have = EINA_FALSE;
- gi->want = EINA_FALSE;
+ if (marker == mm || mm->grouped) continue;
+ if (ELM_RECTS_INTERSECT(mm->x, mm->y, mm->w, mm->h,
+ marker->x, marker->y, gw, gh))
+ {
+ // mm is group follower.
+ mm->leader = EINA_FALSE;
+ mm->grouped = EINA_TRUE;
+ markers = eina_list_append(markers, mm);
+ }
}
+ if (eina_list_count(markers) >= 1)
+ {
+ // marker is group leader.
+ marker->leader = EINA_TRUE;
+ marker->grouped = EINA_TRUE;
+ markers = eina_list_append(markers, marker);
+
+ if (!marker->group) marker->group = _marker_group_create(wd);
+ _marker_group_update(marker->group, group_clas, markers);
+ }
}
}
- eina_iterator_free(it);
-
- xx = wd->pan_x / size;
- if (xx < 0) xx = 0;
-
- yy = wd->pan_y / size;
- if (yy < 0) yy = 0;
- ww = ow / size + 1;
- if (xx + ww >= g->gw) ww = g->gw - xx - 1;
-
- hh = oh / size + 1;
- if (yy + hh >= g->gh) hh = g->gh - yy - 1;
-
- for (y = yy; y <= yy + hh; y++)
+ EINA_LIST_FOREACH(wd->markers, l, marker)
{
- for (x = xx; x <= xx + ww; x++)
+
+ if (marker->grouped ||
+ (marker->group_clas &&
+ (marker->group_clas->hide ||
+ marker->group_clas->zoom_displayed > wd->zoom)))
+ evas_object_hide(marker->obj);
+ else
{
- gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
+ Evas_Coord x, y;
+ _coord_to_canvas(wd, marker->x, marker->y, &x, &y);
+ _obj_place(marker->obj, x - (marker->w / 2), y - (marker->h / 2),
+ marker->w, marker->h);
+ }
+ }
- if ((!gi) && (g != eina_list_data_get(wd->grids)))
- continue;
+ EINA_LIST_FOREACH(wd->markers, l, marker)
+ {
+ Marker_Group *group = marker->group;
+ if (!group) continue;
- if (!gi)
- {
- gi = calloc(1, sizeof(Grid_Item));
- gi->src.x = x * g->tsize;
- gi->src.y = y * g->tsize;
- gi->src.w = g->tsize;
- gi->src.h = g->tsize;
-
- gi->out.x = gi->src.x;
- gi->out.y = gi->src.y;
- gi->out.w = gi->src.w;
- gi->out.h = gi->src.h;
-
- gi->wd = wd;
-
- gi->img = evas_object_image_add(evas_object_evas_get(obj));
- evas_object_image_scale_hint_set
- (gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
- evas_object_image_filled_set(gi->img, 1);
-
- evas_object_smart_member_add(gi->img, wd->pan_smart);
- elm_widget_sub_object_add(obj, gi->img);
- evas_object_pass_events_set(gi->img, EINA_TRUE);
- evas_object_stack_below(gi->img, wd->sep_maps_markers);
-
-/* gi->txt = evas_object_text_add(evas_object_evas_get(obj));
- evas_object_text_font_set(gi->txt, "Vera", 12);
- evas_object_color_set(gi->txt, 100, 100, 100, 255);
- evas_object_smart_member_add(gi->txt,
- wd->pan_smart);
- elm_widget_sub_object_add(obj, gi->txt);
- evas_object_pass_events_set(gi->txt, EINA_TRUE);
-*/
- eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
- }
-
- if ((!gi->have) && (!gi->download))
- {
- char buf[PATH_MAX], buf2[PATH_MAX];
- char *source;
-
- gi->want = EINA_TRUE;
-
- snprintf(buf, sizeof(buf), DEST_DIR_PATH, wd->id, g->zoom, x);
- if (!ecore_file_exists(buf))
- ecore_file_mkpath(buf);
-
- snprintf(buf2, sizeof(buf2), DEST_FILE_PATH, buf, y);
-
- source = map_sources_tab[wd->source].url_cb(obj, x, y, g->zoom);
- if ((!source) || (strlen(source)==0)) continue;
-
- eina_stringshare_replace(&gi->file, buf2);
-
- if ((ecore_file_exists(buf2)) || (g == eina_list_data_get(wd->grids)))
- {
- gi->download = EINA_TRUE;
- wd->preload_num++;
- if (wd->preload_num == 1)
- {
- edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
- "elm,state,busy,start", "elm");
- evas_object_smart_callback_call(obj,
- SIG_LOAD_DETAIL,
- NULL);
- }
-
- if (ecore_file_exists(buf2))
- _tile_update(gi);
- else
- {
- DBG("DOWNLOAD %s \t in %s", source, buf2);
- ecore_file_download_full(source, buf2, _tile_downloaded, NULL, gi, &(gi->job), wd->ua);
- if (!gi->job)
- DBG("Can't start to download %s", buf);
- else
- wd->try_num++;
- }
- }
- if (source) free(source);
- }
- else if (gi->have)
- {
- obj_rotate_zoom(obj, gi->img);
- evas_object_show(gi->img);
- }
+ if (!marker->leader || (group->clas->hide) ||
+ (group->clas->zoom_displayed > wd->zoom))
+ evas_object_hide(group->obj);
+ else
+ {
+ Evas_Coord x, y;
+ _coord_to_canvas(wd, group->x, group->y, &x, &y);
+ _obj_place(group->obj, x - (group->w / 2), y - (group->h / 2),
+ group->w, group->h);
}
}
}
static void
-grid_clearall(Evas_Object *obj)
+_grid_item_coord_get(Grid_Item *gi, int *x, int *y, int *w, int *h)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Grid *g;
+ EINA_SAFETY_ON_NULL_RETURN(gi);
- if (!wd) return;
- EINA_LIST_FREE(wd->grids, g)
- {
- grid_clear(obj, g);
- free(g);
- }
+ if (x) *x = gi->x * gi->wd->size.tile;
+ if (y) *y = gi->y * gi->wd->size.tile;
+ if (w) *w = gi->wd->size.tile;
+ if (h) *h = gi->wd->size.tile;
}
-static void
-_smooth_update(Evas_Object *obj)
+static Eina_Bool
+_grid_item_in_viewport(Grid_Item *gi)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Eina_List *l;
- Grid *g;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(gi, EINA_FALSE);
- if (!wd) return;
- EINA_LIST_FOREACH(wd->grids, l, g)
- {
- Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
- Eina_Matrixsparse_Cell *cell;
+ Evas_Coord vx, vy, vw, vh;
+ Evas_Coord x, y, w, h;
- EINA_ITERATOR_FOREACH(it, cell)
- {
- Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
- evas_object_image_smooth_scale_set(gi->img, (!wd->nosmooth));
- }
- eina_iterator_free(it);
- }
+ _viewport_coord_get(gi->wd, &vx, &vy, &vw, &vh);
+ _grid_item_coord_get(gi, &x, &y, &w, &h);
+ return ELM_RECTS_INTERSECT(x, y, w, h, vx, vy, vw, vh);
}
static void
-_grid_raise(Grid *g)
+_grid_item_update(Grid_Item *gi)
{
- Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
- Eina_Matrixsparse_Cell *cell;
-
- g->wd->size.w = g->w;
- g->wd->size.h = g->h;
+ evas_object_image_file_set(gi->img, gi->file, NULL);
+ if (!gi->wd->zoom_timer && !gi->wd->scr_timer)
+ evas_object_image_smooth_scale_set(gi->img, EINA_TRUE);
+ else evas_object_image_smooth_scale_set(gi->img, EINA_FALSE);
- EINA_ITERATOR_FOREACH(it, cell)
+ Evas_Load_Error err = evas_object_image_load_error_get(gi->img);
+ if (err != EVAS_LOAD_ERROR_NONE)
{
- Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
- evas_object_raise(gi->img);
- //evas_object_raise(gi->txt);
+ ERR("Image loading error (%s): %s", gi->file, evas_load_error_str(err));
+ ecore_file_remove(gi->file);
+ gi->file_have = EINA_FALSE;
+ }
+ else
+ {
+ Evas_Coord x, y, w, h;
+ _grid_item_coord_get(gi, &x, &y, &w, &h);
+ _coord_to_canvas_no_rotate(gi->wd, x, y, &x, &y);
+ _obj_place(gi->img, x, y, w, h);
+ _obj_rotate(gi->wd, gi->img);
+ gi->file_have = EINA_TRUE;
}
- eina_iterator_free(it);
-}
-
-static Eina_Bool
-_scr_timeout(void *data)
-{
- Widget_Data *wd = elm_widget_data_get(data);
- if (!wd) return ECORE_CALLBACK_CANCEL;
- wd->nosmooth--;
- if (!wd->nosmooth) _smooth_update(data);
- wd->scr_timer = NULL;
- return ECORE_CALLBACK_CANCEL;
}
static void
-_scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+_grid_item_load(Grid_Item *gi)
{
- Widget_Data *wd = elm_widget_data_get(data);
- if (!wd) return;
- if (!wd->scr_timer)
+ EINA_SAFETY_ON_NULL_RETURN(gi);
+ if (gi->file_have) _grid_item_update(gi);
+ else if (!gi->job)
{
- wd->nosmooth++;
- if (wd->nosmooth == 1) _smooth_update(data);
+ gi->wd->download_list = eina_list_remove(gi->wd->download_list, gi);
+ gi->wd->download_list = eina_list_append(gi->wd->download_list, gi);
}
- if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
- wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
}
static void
-zoom_do(Evas_Object *obj)
+_grid_item_unload(Grid_Item *gi)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Evas_Coord xx, yy, ow, oh;
+ EINA_SAFETY_ON_NULL_RETURN(gi);
+ if (gi->file_have)
+ {
+ evas_object_hide(gi->img);
+ evas_object_image_file_set(gi->img, NULL, NULL);
+ }
+ else if (gi->job)
+ {
+ ecore_file_download_abort(gi->job);
+ ecore_file_remove(gi->file);
+ gi->job = NULL;
+ gi->wd->try_num--;
+ }
+ else gi->wd->download_list = eina_list_remove(gi->wd->download_list, gi);
- if (!wd) return;
+}
- wd->size.w = wd->size.nw;
- wd->size.h = wd->size.nh;
+static Grid_Item *
+_grid_item_create(Grid *g, Evas_Coord x, Evas_Coord y)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(g, NULL);
+ char buf[PATH_MAX];
+ char buf2[PATH_MAX];
+ char *url;
+ Grid_Item *gi;
- elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
- elm_map_utils_convert_geo_into_coord(obj, wd->center_on.lon, wd->center_on.lat, wd->size.w, &xx, &yy);
- xx -= ow / 2;
- yy -= oh / 2;
+ gi = ELM_NEW(Grid_Item);
+ gi->wd = g->wd;
+ gi->g = g;
+ gi->x = x;
+ gi->y = y;
- if (xx < 0) xx = 0;
- else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
- if (yy < 0) yy = 0;
- else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
+ gi->file_have = EINA_FALSE;
+ gi->job = NULL;
- wd->show.show = EINA_TRUE;
- wd->show.x = xx;
- wd->show.y = yy;
- wd->show.w = ow;
- wd->show.h = oh;
+ gi->img = evas_object_image_add(evas_object_evas_get(g->wd->obj));
+ evas_object_image_smooth_scale_set(gi->img, EINA_FALSE);
+ evas_object_image_scale_hint_set(gi->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
+ evas_object_image_filled_set(gi->img, EINA_TRUE);
+ evas_object_smart_member_add(gi->img, g->wd->pan_smart);
+ evas_object_pass_events_set(gi->img, EINA_TRUE);
+ evas_object_stack_below(gi->img, g->wd->sep_maps_markers);
+
+ snprintf(buf, sizeof(buf), CACHE_TILE_ROOT, g->wd->id, g->zoom, x);
+ snprintf(buf2, sizeof(buf2), CACHE_TILE_PATH, buf, y);
+ if (!ecore_file_exists(buf)) ecore_file_mkpath(buf);
+
+ eina_stringshare_replace(&gi->file, buf2);
+ url = g->wd->src_tile->url_cb(g->wd->obj, x, y, g->zoom);
+ if ((!url) || (!strlen(url)))
+ {
+ eina_stringshare_replace(&gi->url, NULL);
+ ERR("Getting source url failed: %s", gi->file);
+ }
+ else eina_stringshare_replace(&gi->url, url);
+ if (url) free(url);
+ eina_matrixsparse_data_idx_set(g->grid, y, x, gi);
+ return gi;
+}
- if (wd->calc_job) ecore_job_del(wd->calc_job);
- wd->calc_job = ecore_job_add(_calc_job, wd);
+static void
+_grid_item_free(Grid_Item *gi)
+{
+ EINA_SAFETY_ON_NULL_RETURN(gi);
+ _grid_item_unload(gi);
+ if (gi->g && gi->g->grid) eina_matrixsparse_data_idx_set(gi->g->grid,
+ gi->y, gi->x, NULL);
+ if (gi->url) eina_stringshare_del(gi->url);
+ if (gi->file) eina_stringshare_del(gi->file);
+ if (gi->img) evas_object_del(gi->img);
+ if (gi->file_have) ecore_file_remove(gi->file);
+ free(gi);
}
-static Eina_Bool
-_zoom_anim(void *data)
+static void
+_downloaded_cb(void *data, const char *file __UNUSED__, int status)
{
- Evas_Object *obj = data;
- Widget_Data *wd = elm_widget_data_get(obj);
- double t;
-
- if (!wd) return ECORE_CALLBACK_CANCEL;
- t = ecore_loop_time_get();
- if (t >= wd->t_end)
- t = 1.0;
- else if (wd->t_end > wd->t_start)
- t = (t - wd->t_start) / (wd->t_end - wd->t_start);
- else
- t = 1.0;
- if (wd->zoom_method == ZOOM_METHOD_IN) t = 1.0 + (t * t);
- else if (wd->zoom_method == ZOOM_METHOD_OUT) t = 1.0 - (t * t);
- else return ECORE_CALLBACK_CANCEL;
+ Grid_Item *gi = data;
- if ((t >= 2.0) || (t <= 0.5))
+ if (status == 200)
{
- double lon, lat;
- Evas_Coord sx, sy, sw, sh;
- elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
- elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
- sx += sw / 2;
- sy += sh / 2;
- elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, &lon, &lat);
-
- wd->pinch.level = 1.0;
- wd->center_on.enabled = EINA_TRUE;
- wd->center_on.lon = lon;
- wd->center_on.lat = lat;
- zoom_do(obj);
- wd->zoom_animator = NULL;
- evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
- return ECORE_CALLBACK_CANCEL;
+ DBG("Download success from %s to %s", gi->url, gi->file);
+ _grid_item_update(gi);
+ gi->wd->finish_num++;
+ evas_object_smart_callback_call(gi->wd->obj, SIG_TILE_LOADED, NULL);
}
else
{
- Evas_Coord x, y, w, h;
- float half_w, half_h;
-
- evas_object_geometry_get(data, &x, &y, &w, &h);
- half_w = (float)w * 0.5;
- half_h = (float)h * 0.5;
-
- wd->pinch.level = t;
- wd->pinch.cx = x + half_w;
- wd->pinch.cy = y + half_h;
- if (wd->calc_job) ecore_job_del(wd->calc_job);
- wd->calc_job = ecore_job_add(_calc_job, wd);
- return ECORE_CALLBACK_RENEW;
+ WRN("Download failed from %s to %s (%d) ", gi->url, gi->file, status);
+ ecore_file_remove(gi->file);
+ gi->file_have = EINA_FALSE;
+ evas_object_smart_callback_call(gi->wd->obj, SIG_TILE_LOADED_FAIL, NULL);
}
+
+ gi->job = NULL;
+ gi->wd->download_num--;
+ if (!gi->wd->download_num)
+ edje_object_signal_emit(elm_smart_scroller_edje_object_get(gi->wd->scr),
+ "elm,state,busy,stop", "elm");
}
static Eina_Bool
-_long_press(void *data)
+_download_job(void *data)
{
- Widget_Data *wd = elm_widget_data_get(data);
- if (!wd) return ECORE_CALLBACK_CANCEL;
- wd->long_timer = NULL;
- evas_object_smart_callback_call(data, SIG_LONGPRESSED, &wd->ev);
- return ECORE_CALLBACK_CANCEL;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
+ Widget_Data *wd = data;
+
+ Eina_List *l, *ll;
+ Grid_Item *gi;
+
+ if (!eina_list_count(wd->download_list))
+ {
+ wd->download_idler = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ EINA_LIST_REVERSE_FOREACH_SAFE(wd->download_list, l, ll, gi)
+ {
+ if ((gi->g->zoom != wd->zoom) || !(_grid_item_in_viewport(gi)))
+ {
+ wd->download_list = eina_list_remove(wd->download_list, gi);
+ continue;
+ }
+ if (wd->download_num >= MAX_CONCURRENT_DOWNLOAD)
+ return ECORE_CALLBACK_RENEW;
+
+ Eina_Bool ret = ecore_file_download_full(gi->url, gi->file,
+ _downloaded_cb, NULL,
+ gi, &(gi->job), wd->ua);
+ if ((!ret) || (!gi->job))
+ ERR("Can't start to download from %s to %s", gi->url, gi->file);
+ else
+ {
+ wd->download_list = eina_list_remove(wd->download_list, gi);
+ wd->try_num++;
+ wd->download_num++;
+ evas_object_smart_callback_call(gi->wd->obj, SIG_TILE_LOAD,
+ NULL);
+ if (wd->download_num == 1)
+ edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
+ "elm,state,busy,start", "elm");
+ }
+ }
+ return ECORE_CALLBACK_RENEW;
}
static void
-_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
+_grid_viewport_get(Grid *g, int *x, int *y, int *w, int *h)
{
- ELM_CHECK_WIDTYPE(data, widtype);
- Widget_Data *wd = elm_widget_data_get(data);
- Evas_Event_Mouse_Down *ev = event_info;
- Event *ev0;
+ EINA_SAFETY_ON_NULL_RETURN(g);
+ int xx, yy, ww, hh;
+ Evas_Coord vx, vy, vw, vh;
- ev0 = get_event_object(data, 0);
- if (ev0) return;
- ev0 = create_event_object(data, obj, 0);
- if (!ev0) return;
+ _viewport_coord_get(g->wd, &vx, &vy, &vw, &vh);
+ if (vx < 0) vx = 0;
+ if (vy < 0) vy = 0;
- ev0->hold_timer = NULL;
- ev0->prev.x = ev->output.x;
- ev0->prev.y = ev->output.y;
+ xx = (vx / g->wd->size.tile) - 1;
+ if (xx < 0) xx = 0;
- if (!wd) return;
- if (ev->button != 1) return;
- if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
- else wd->on_hold = EINA_FALSE;
- if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
- evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, ev);
- else
- evas_object_smart_callback_call(data, SIG_PRESS, ev);
- if (wd->long_timer) ecore_timer_del(wd->long_timer);
- wd->ev.output.x = ev->output.x;
- wd->ev.output.y = ev->output.y;
- wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
+ yy = (vy / g->wd->size.tile) - 1;
+ if (yy < 0) yy = 0;
+
+ ww = (vw / g->wd->size.tile) + 3;
+ if (xx + ww >= g->tw) ww = g->tw - xx;
+
+ hh = (vh / g->wd->size.tile) + 3;
+ if (yy + hh >= g->th) hh = g->th - yy;
+
+ if (x) *x = xx;
+ if (y) *y = yy;
+ if (w) *w = ww;
+ if (h) *h = hh;
}
static void
-_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
+_grid_unload(Grid *g)
{
- Evas_Event_Mouse_Move *move = event_info;
- Event *ev0;
+ EINA_SAFETY_ON_NULL_RETURN(g);
+ Eina_Iterator *it;
+ Eina_Matrixsparse_Cell *cell;
+ Grid_Item *gi;
- ev0 = get_event_object(data, 0);
- if (!ev0) return;
- ev0->prev.x = move->cur.output.x;
- ev0->prev.y = move->cur.output.y;
+ it = eina_matrixsparse_iterator_new(g->grid);
+ EINA_ITERATOR_FOREACH(it, cell)
+ {
+ gi = eina_matrixsparse_cell_data_get(cell);
+ _grid_item_unload(gi);
+ }
+ eina_iterator_free(it);
}
static void
-_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
+_grid_load(Grid *g)
{
- ELM_CHECK_WIDTYPE(data, widtype);
- Widget_Data *wd = elm_widget_data_get(data);
- Evas_Event_Mouse_Up *ev = event_info;
- int mdevice;
- Event *ev0;
- Event *ev1;
+ EINA_SAFETY_ON_NULL_RETURN(g);
+ int x, y, xx, yy, ww, hh;
+ Eina_Iterator *it;
+ Eina_Matrixsparse_Cell *cell;
+ Grid_Item *gi;
- ev0 = get_event_object(data, 0);
- if (ev0)
+ it = eina_matrixsparse_iterator_new(g->grid);
+ EINA_ITERATOR_FOREACH(it, cell)
{
- mdevice = get_multi_device(data);
- if (mdevice == 0)
- {
- if (ev0->hold_timer)
- {
- ecore_timer_del(ev0->hold_timer);
- ev0->hold_timer = NULL;
- }
- elm_smart_scroller_hold_set(wd->scr, 0);
- elm_smart_scroller_freeze_set(wd->scr, 0);
- }
- else
- {
- ev1 = get_event_object(data, mdevice);
- if (ev1)
- ev1->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev1);
- }
- destroy_event_object(data, ev0);
+ gi = eina_matrixsparse_cell_data_get(cell);
+ if (!_grid_item_in_viewport(gi)) _grid_item_unload(gi);
}
+ eina_iterator_free(it);
- if (!wd) return;
- if (ev->button != 1) return;
- if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
- else wd->on_hold = EINA_FALSE;
- if (wd->long_timer)
+ _grid_viewport_get(g, &xx, &yy, &ww, &hh);
+ for (y = yy; y < yy + hh; y++)
{
- ecore_timer_del(wd->long_timer);
- wd->long_timer = NULL;
+ for (x = xx; x < xx + ww; x++)
+ {
+ gi = eina_matrixsparse_data_idx_get(g->grid, y, x);
+ if (!gi) gi = _grid_item_create(g, x, y);
+ _grid_item_load(gi);
+ }
}
- if (!wd->on_hold) evas_object_smart_callback_call(data, SIG_CLICKED, ev);
- wd->on_hold = EINA_FALSE;
}
static void
-_mouse_multi_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info)
+_grid_place(Widget_Data *wd)
{
- ELM_CHECK_WIDTYPE(data, widtype);
- Widget_Data *wd = elm_widget_data_get(data);
- Event *ev;
- Evas_Event_Multi_Down *down = event_info;
-
- elm_smart_scroller_hold_set(wd->scr, 1);
- elm_smart_scroller_freeze_set(wd->scr, 1);
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ Eina_List *l;
+ Grid *g;
- ev = create_event_object(data, obj, down->device);
- if (!ev)
+ EINA_LIST_FOREACH(wd->grids, l, g)
{
- DBG("Failed : create_event_object");
- goto done;
+ if (wd->zoom == g->zoom) _grid_load(g);
+ else _grid_unload(g);
}
- wd->multi_count++;
+ if (!wd->download_idler) wd->download_idler = ecore_idler_add(_download_job, wd);
+}
- ev->hold_timer = NULL;
- ev->start.x = ev->prev.x = down->output.x;
- ev->start.y = ev->prev.y = down->output.y;
- ev->pinch_start_dis = 0;
- wd->pinch.level = 1.0;
- wd->pinch.diff = 1.0;
+static void
+_grid_all_create(Widget_Data *wd)
+{
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ EINA_SAFETY_ON_NULL_RETURN(wd->src_tile);
-done:
- if (wd->long_timer)
+ int zoom;
+ for (zoom = wd->src_tile->zoom_min; zoom <= wd->src_tile->zoom_max; zoom++)
{
- ecore_timer_del(wd->long_timer);
- wd->long_timer = NULL;
+ Grid *g;
+ int tnum;
+ g = ELM_NEW(Grid);
+ g->wd = wd;
+ g->zoom = zoom;
+ tnum = pow(2.0, g->zoom);
+ g->tw = tnum;
+ g->th = tnum;
+ g->grid = eina_matrixsparse_new(g->th, g->tw, NULL, NULL);
+ wd->grids = eina_list_append(wd->grids, g);
}
- return;
}
static void
-_mouse_multi_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
+_grid_all_clear(Widget_Data *wd)
{
- ELM_CHECK_WIDTYPE(data, widtype);
- Widget_Data *wd = elm_widget_data_get(data);
- Evas_Event_Multi_Move *move = event_info;
- int dis_new;
- double t, tt, a, a_diff;
- Event *ev0;
- Event *ev;
-
- ev = get_event_object(data, move->device);
- if (!ev) return;
+ EINA_SAFETY_ON_NULL_RETURN(wd);
- ev0 = get_event_object(data, 0);
- if (!ev0) return;
-
- if (wd->multi_count >= 1)
+ Grid *g;
+ EINA_LIST_FREE(wd->grids, g)
{
- Evas_Coord x, y, w, h;
- float half_w, half_h;
-
- evas_object_geometry_get(data, &x, &y, &w, &h);
- half_w = (float)w * 0.5;
- half_h = (float)h * 0.5;
- dis_new = get_distance(ev0->prev.x, ev0->prev.y, ev->prev.x, ev->prev.y);
-
- if (!ev->pinch_start_dis) ev->pinch_start_dis = dis_new;
- else
+ Eina_Matrixsparse_Cell *cell;
+ Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
+ EINA_ITERATOR_FOREACH(it, cell)
{
- ev->pinch_dis = dis_new;
- tt = wd->pinch.diff;
- wd->pinch.diff = (double)(ev->pinch_dis - ev->pinch_start_dis);
- t = (wd->pinch.diff * 0.01) + 1.0;
- if ((!wd->zoom) || ((wd->zoom + (int)t - 1) <= map_sources_tab[wd->source].zoom_min) ||
- ((wd->zoom + (int)t - 1) >= map_sources_tab[wd->source].zoom_max) ||
- (t > PINCH_ZOOM_MAX) || (t < PINCH_ZOOM_MIN))
- {
- wd->pinch.diff = tt;
- goto do_nothing;
- }
- else
- {
- wd->pinch.level = (wd->pinch.diff * 0.01) + 1.0;
- wd->pinch.cx = x + half_w;
- wd->pinch.cy = y + half_h;
- }
-
- a = (double)(ev->prev.y - ev0->prev.y) / (double)(ev->prev.x - ev0->prev.x);
- if (!wd->rotate.a) wd->rotate.a = a;
- else
- {
-
- a_diff = wd->rotate.a - a;
- if (a_diff > 0) wd->rotate.d -= 1.0;
- else if (a_diff < 0) wd->rotate.d += 1.0;
- wd->rotate.a = a;
- wd->rotate.cx = x + half_w;
- wd->rotate.cy = y + half_h;
- }
-
- if (wd->calc_job) ecore_job_del(wd->calc_job);
- wd->calc_job = ecore_job_add(_calc_job, wd);
+ Grid_Item *gi;
+ gi = eina_matrixsparse_cell_data_get(cell);
+ if (gi) _grid_item_free(gi);
}
+ eina_iterator_free(it);
+
+ eina_matrixsparse_free(g->grid);
+ free(g);
}
-do_nothing:
- ev->prev.x = move->cur.output.x;
- ev->prev.y = move->cur.output.y;
}
static void
-_mouse_multi_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
+_track_place(Widget_Data *wd)
{
- ELM_CHECK_WIDTYPE(data, widtype);
- Widget_Data *wd = elm_widget_data_get(data);
- Evas_Event_Multi_Up *up = event_info;
- Event *ev0;
- Event *ev;
- Eina_Bool tp;
- double t = 0.0;
+#ifdef ELM_EMAP
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ Eina_List *l;
+ Evas_Object *route;
+ int xmin, xmax, ymin, ymax;
+ Evas_Coord px, py, ow, oh;
+ px = wd->pan_x;
+ py = wd->pan_y;
+ _viewport_coord_get(wd, NULL, NULL, &ow, &oh);
- wd->multi_count--;
- if (wd->calc_job) ecore_job_del(wd->calc_job);
- if (wd->zoom_animator)
+ Evas_Coord size = wd->size.w;
+
+ EINA_LIST_FOREACH(wd->track, l, route)
{
- ecore_animator_del(wd->zoom_animator);
- wd->zoom_animator = NULL;
+ double lon_min, lon_max;
+ double lat_min, lat_max;
+ elm_route_longitude_min_max_get(route, &lon_min, &lon_max);
+ elm_route_latitude_min_max_get(route, &lat_min, &lat_max);
+ _region_to_coord_convert(wd, lon_min, lat_max, size, &xmin, &ymin);
+ _region_to_coord_convert(wd, lon_max, lat_min, size, &xmax, &ymax);
+
+ if( !(xmin < px && xmax < px) && !(xmin > px+ow && xmax > px+ow))
+ {
+ if( !(ymin < py && ymax < py) && !(ymin > py+oh && ymax > py+oh))
+ {
+ //display the route
+ evas_object_move(route, xmin - px, ymin - py);
+ evas_object_resize(route, xmax - xmin, ymax - ymin);
+
+ evas_object_raise(route);
+ _obj_rotate(wd, route);
+ evas_object_show(route);
+
+ continue;
+ }
+ }
+ //the route is not display
+ evas_object_hide(route);
}
- tp = wd->paused;
- wd->paused = EINA_TRUE;
- if (wd->pinch.diff >= 0.0) t = wd->pinch.diff * 0.01;
- else if (wd->pinch.diff < 0.0) t = -1.0 / ((wd->pinch.diff * 0.01) + 1.0);
- elm_map_zoom_set(data, wd->zoom + (int)ceil(t));
- wd->pinch.level = 1.0;
- wd->paused = tp;
- wd->rotate.a = 0.0;
+#else
+ (void) wd;
+#endif
+}
- ev = get_event_object(data, up->device);
- if (!ev)
+static void
+_delayed_do(Widget_Data *wd)
+{
+ Delayed_Data *dd;
+ dd = eina_list_nth(wd->delayed_jobs, 0);
+ if (dd && !dd->wd->zoom_animator)
{
- DBG("Cannot get multi device");
- return;
+ dd->func(dd);
+ wd->delayed_jobs = eina_list_remove(wd->delayed_jobs, dd);
+ free(dd);
}
+}
- ev0 = get_event_object(data, 0);
- if (ev0)
- ev0->hold_timer = ecore_timer_add(0.35, _hold_timer_cb, ev0);
- else
+static void
+_smooth_update(Widget_Data *wd)
+{
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ Eina_List *l;
+ Grid *g;
+
+ EINA_LIST_FOREACH(wd->grids, l, g)
{
- if (ev->hold_timer)
+ Eina_Iterator *it = eina_matrixsparse_iterator_new(g->grid);
+ Eina_Matrixsparse_Cell *cell;
+
+ EINA_ITERATOR_FOREACH(it, cell)
{
- ecore_timer_del(ev->hold_timer);
- ev->hold_timer = NULL;
+ Grid_Item *gi = eina_matrixsparse_cell_data_get(cell);
+ if (_grid_item_in_viewport(gi))
+ evas_object_image_smooth_scale_set(gi->img, EINA_TRUE);
}
+ eina_iterator_free(it);
}
- destroy_event_object(data, ev);
}
-static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
-
static Eina_Bool
-_hold_timer_cb(void *data)
+_zoom_timeout(void *data)
{
- Event *ev0 = data;
-
- ev0->hold_timer = NULL;
- return ECORE_CALLBACK_CANCEL;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
+ Widget_Data *wd = data;
+ _smooth_update(wd);
+ wd->zoom_timer = NULL;
+ evas_object_smart_callback_call(wd->obj, SIG_ZOOM_STOP, NULL);
+ return ECORE_CALLBACK_CANCEL;
}
static void
-_rect_resize_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+zoom_do(Widget_Data *wd, double zoom)
{
- Widget_Data *wd = elm_widget_data_get(data);
- int x, y, w, h;
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ if (zoom > wd->zoom_max) zoom = wd->zoom_max;
+ else if (zoom < wd->zoom_min) zoom = wd->zoom_min;
+
+ Evas_Coord vx, vy, vw, vh;
+ Evas_Coord ow, oh;
+
+ wd->zoom = ROUND(zoom);
+ wd->zoom_detail = zoom;
+ ow = wd->size.w;
+ oh = wd->size.h;
+ wd->size.tile = pow(2.0, (zoom - wd->zoom)) * wd->tsize;
+ wd->size.w = pow(2.0, wd->zoom) * wd->size.tile;
+ wd->size.h = wd->size.w;;
+
+ // Fix to zooming with (viewport center vx, vy) as the center to prevent
+ // from zooming with (0,0) as the cetner. (scroller default behavior)
+ _viewport_coord_get(wd, &vx, &vy, &vw, &vh);
+ if ((vw > 0) && (vh > 0) && (ow > 0) && (oh > 0))
+ {
+ Evas_Coord x, y;
+ double sx, sy;
+ if (vw > ow) sx = 0.5;
+ else sx = (double)(vx + (double)(vw / 2)) / ow;
+ if (vh > oh) sy = 0.5;
+ else sy = (double)(vy + (double)(vh / 2)) / oh;
+
+ if (sx > 1.0) sx = 1.0;
+ if (sy > 1.0) sy = 1.0;
+
+ x = ceil((sx * wd->size.w) - (vw / 2));
+ y = ceil((sy * wd->size.h) - (vh / 2));
+ if (x < 0) x = 0;
+ else if (x > (wd->size.w - vw)) x = wd->size.w - vw;
+ if (y < 0) y = 0;
+ else if (y > (wd->size.h - vh)) y = wd->size.h - vh;
+ elm_smart_scroller_child_region_show(wd->scr, x, y, vw, vh);
+ }
+ if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
+ else evas_object_smart_callback_call(wd->obj, SIG_ZOOM_START, NULL);
+ wd->zoom_timer = ecore_timer_add(0.25, _zoom_timeout, wd);
+ evas_object_smart_callback_call(wd->obj, SIG_ZOOM_CHANGE, NULL);
- evas_object_geometry_get(wd->rect, &x, &y, &w, &h);
- evas_object_geometry_get(wd->pan_smart, &x, &y, &w, &h);
- evas_object_resize(wd->rect, w, h);
- evas_object_move(wd->rect, x, y);
+ evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
+ evas_object_smart_changed(wd->pan_smart);
}
-static void
-_del_hook(Evas_Object *obj)
+static Eina_Bool
+_zoom_anim(void *data)
{
- Elm_Map_Group_Class *group_clas;
- Elm_Map_Marker_Class *marker_clas;
- Widget_Data *wd = elm_widget_data_get(obj);
- Eina_List *l;
- Event *ev;
- Evas_Object *p;
- Route_Node *n;
- Route_Waypoint *w;
- Ecore_Event_Handler *h;
- Elm_Map_Route *r;
- Elm_Map_Name *na;
-
- if (!wd) return;
+ Widget_Data *wd = data;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, ECORE_CALLBACK_CANCEL);
- EINA_LIST_FREE(wd->groups_clas, group_clas)
+ if (wd->ani.cnt <= 0)
{
- if (group_clas->style)
- eina_stringshare_del(group_clas->style);
- free(group_clas);
+ wd->zoom_animator = NULL;
+ evas_object_smart_changed(wd->pan_smart);
+ return ECORE_CALLBACK_CANCEL;
}
-
- EINA_LIST_FREE(wd->markers_clas, marker_clas)
+ else
{
- if (marker_clas->style)
- eina_stringshare_del(marker_clas->style);
- free(marker_clas);
+ wd->ani.zoom += wd->ani.diff;
+ wd->ani.cnt--;
+ zoom_do(wd, wd->ani.zoom);
+ return ECORE_CALLBACK_RENEW;
}
+}
- EINA_LIST_FOREACH(wd->s_event_list, l, ev)
- {
- destroy_event_object(obj, ev);
- }
+static void
+zoom_with_animation(Widget_Data *wd, double zoom, int cnt)
+{
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ if (cnt == 0) return;
- EINA_LIST_FOREACH(wd->route, l, r)
- {
- EINA_LIST_FREE(r->path, p)
- {
- evas_object_del(p);
- }
+ wd->ani.cnt = cnt;
+ wd->ani.zoom = wd->zoom;
+ wd->ani.diff = (double)(zoom - wd->zoom) / cnt;
+ if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
+ wd->zoom_animator = ecore_animator_add(_zoom_anim, wd);
+}
- EINA_LIST_FREE(r->waypoint, w)
- {
- if (w->point) eina_stringshare_del(w->point);
- free(w);
- }
+static void
+_sizing_eval(Widget_Data *wd)
+{
+ EINA_SAFETY_ON_NULL_RETURN(wd);
- EINA_LIST_FREE(r->nodes, n)
- {
- if (n->pos.address) eina_stringshare_del(n->pos.address);
- free(n);
- }
+ Evas_Coord maxw = -1, maxh = -1;
- EINA_LIST_FREE(r->handlers, h)
- {
- ecore_event_handler_del(h);
- }
+ evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
+ evas_object_size_hint_max_set(wd->obj, maxw, maxh);
+}
- if (r->con_url) ecore_con_url_free(r->con_url);
- if (r->info.nodes) eina_stringshare_del(r->info.nodes);
- if (r->info.waypoints) eina_stringshare_del(r->info.waypoints);
- }
+static void
+_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ _sizing_eval(data);
+}
- EINA_LIST_FREE(wd->names, na)
- {
- if (na->address) free(na->address);
- if (na->handler) ecore_event_handler_del(na->handler);
- if (na->ud.fname)
- {
- ecore_file_remove(na->ud.fname);
- free(na->ud.fname);
- na->ud.fname = NULL;
- }
- }
+static Eina_Bool
+_scr_timeout(void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
+ Widget_Data *wd = data;
+ _smooth_update(wd);
+ wd->scr_timer = NULL;
+ evas_object_smart_callback_call(wd->obj, SIG_SCROLL_DRAG_STOP, NULL);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Widget_Data *wd = data;
- if (wd->calc_job) ecore_job_del(wd->calc_job);
if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
- if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
- if (wd->long_timer) ecore_timer_del(wd->long_timer);
- if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj);
- if (wd->user_agent) eina_stringshare_del(wd->user_agent);
- if (wd->ua) eina_hash_free(wd->ua);
+ else evas_object_smart_callback_call(wd->obj, SIG_SCROLL_DRAG_START, NULL);
+ wd->scr_timer = ecore_timer_add(0.25, _scr_timeout, wd);
+ evas_object_smart_callback_call(wd->obj, SIG_SCROLL, NULL);
+}
- free(wd);
+static void
+_scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Widget_Data *wd = data;
+ evas_object_smart_callback_call(wd->obj, SIG_SCROLL_ANIM_START, NULL);
}
static void
-_del_pre_hook(Evas_Object *obj)
+_scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- Marker_Group *group;
- Elm_Map_Marker *marker;
- int i;
- Eina_Bool free_marker = EINA_TRUE;
- Eina_List *l;
- Widget_Data *wd = elm_widget_data_get(obj);
- grid_clearall(obj);
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Widget_Data *wd = data;
+ evas_object_smart_callback_call(wd->obj, SIG_SCROLL_ANIM_STOP, NULL);
+}
- if (!wd) return;
- for (i = 0; i < ZOOM_MAX + 1; i++)
- {
- if (!wd->markers[i]) continue;
- Eina_Iterator *it = eina_matrixsparse_iterator_new(wd->markers[i]);
- Eina_Matrixsparse_Cell *cell;
+static Eina_Bool
+_long_press(void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, ECORE_CALLBACK_CANCEL);
+ Widget_Data *wd = data;
- EINA_ITERATOR_FOREACH(it, cell)
- {
- l = eina_matrixsparse_cell_data_get(cell);
- EINA_LIST_FREE(l, group)
- {
- EINA_LIST_FREE(group->markers, marker)
- {
- evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
- _bubble_sc_hits_changed_cb, group);
- if (free_marker) free(marker);
- }
- free(group);
- }
- free_marker = EINA_FALSE;
- }
- eina_iterator_free(it);
- eina_matrixsparse_free(wd->markers[i]);
- }
+ wd->long_timer = NULL;
+ evas_object_smart_callback_call(wd->obj, SIG_LONGPRESSED, &wd->ev);
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Widget_Data *wd = data;
+ Evas_Event_Mouse_Down *ev = event_info;
+
+ if (ev->button != 1) return;
+
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
+ else wd->on_hold = EINA_FALSE;
+
+ if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
+ evas_object_smart_callback_call(wd->obj, SIG_CLICKED_DOUBLE, ev);
+ else evas_object_smart_callback_call(wd->obj, SIG_PRESS, ev);
- evas_object_del(wd->sep_maps_markers);
- evas_object_del(wd->pan_smart);
- wd->pan_smart = NULL;
+ if (wd->long_timer) ecore_timer_del(wd->long_timer);
+ wd->ev = *ev;
+ wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, wd);
}
static void
-_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
+_mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- if (elm_widget_focus_get(obj))
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Widget_Data *wd = data;
+
+ Evas_Event_Mouse_Up *ev = event_info;
+ EINA_SAFETY_ON_NULL_RETURN(ev);
+
+ if (ev->button != 1) return;
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
+ else wd->on_hold = EINA_FALSE;
+ if (wd->long_timer)
{
- edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
- evas_object_focus_set(wd->obj, EINA_TRUE);
+ ecore_timer_del(wd->long_timer);
+ wd->long_timer = NULL;
}
- else
+ if (!wd->on_hold) evas_object_smart_callback_call(wd->obj, SIG_CLICKED, ev);
+ wd->on_hold = EINA_FALSE;
+}
+
+static void
+_mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Widget_Data *wd = data;
+
+ if (!wd->paused)
{
- edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
- evas_object_focus_set(wd->obj, EINA_FALSE);
+ Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
+ zoom_do(wd, wd->zoom_detail - ((double)ev->z / 10));
+ }
+}
+
+static void
+_region_max_min_get(Eina_List *overlays, double *max_longitude, double *min_longitude, double *max_latitude, double *min_latitude)
+{
+ double max_lon = -180, min_lon = 180;
+ double max_lat = -90, min_lat = 90;
+ Elm_Map_Overlay *overlay;
+ EINA_LIST_FREE(overlays, overlay)
+ {
+ double lon, lat;
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ {
+ Overlay_Default *ovl = overlay->ovl;
+ lon = ovl->lon;
+ lat = ovl->lat;
+ }
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
+ {
+ // FIXME: class center coord is alright??
+ Overlay_Class *ovl = overlay->ovl;
+ double max_lo, min_lo, max_la, min_la;
+ _region_max_min_get(ovl->members, &max_lo, &min_lo, &max_la,
+ &min_la);
+ lon = (max_lo + min_lo) / 2;
+ lat = (max_la + min_la) / 2;
+ }
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
+ {
+ Overlay_Bubble *ovl = overlay->ovl;
+ lon = ovl->lon;
+ lat = ovl->lat;
+ }
+ else
+ {
+ WRN("Not supported overlay type: %d", overlay->type);
+ continue;
+ }
+ if (lon> max_lon) max_lon = lon;
+ if (lon< min_lon) min_lon = lon;
+ if (lat > max_lat) max_lat = lat;
+ if (lat < min_lat) min_lat = lat;
}
+ if (max_longitude) *max_longitude = max_lon;
+ if (min_longitude) *min_longitude = min_lon;
+ if (max_latitude) *max_latitude = max_lat;
+ if (min_latitude) *min_latitude = min_lat;
+}
+
+static Evas_Object *
+_icon_dup(const Evas_Object *icon, Evas_Object *parent)
+{
+ if (!icon || !parent) return NULL;
+ // Evas_Object do not support object duplication??
+ const char *file = NULL, *group = NULL;
+ Eina_Bool size_up, size_down;
+ Evas_Object *dupp;
+
+ dupp = elm_icon_add(parent);
+ elm_icon_file_get(icon, &file, &group);
+ elm_icon_file_set(dupp, file, group);
+ elm_icon_animated_set(dupp, elm_icon_animated_get(icon));
+ elm_icon_animated_play_set(dupp, elm_icon_animated_play_get(icon));
+ elm_icon_standard_set(dupp, elm_icon_standard_get(icon));
+ elm_icon_order_lookup_set(dupp, elm_icon_order_lookup_get(icon));
+ elm_icon_no_scale_set(dupp, elm_icon_no_scale_get(icon));
+ elm_icon_resizable_get(icon, &size_up, &size_down);
+ elm_icon_resizable_set(dupp, size_up, size_down);
+ elm_icon_fill_outside_set(dupp, elm_icon_fill_outside_get(icon));
+ elm_icon_prescale_set(dupp, elm_icon_prescale_get(icon));
+ elm_icon_aspect_fixed_set(dupp, elm_icon_aspect_fixed_get(icon));
+ return dupp;
}
static void
-_theme_hook(Evas_Object *obj)
+_overlay_clicked_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
- // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
- _sizing_eval(obj);
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Elm_Map_Overlay *overlay = data;
+
+ evas_object_smart_callback_call(overlay->wd->obj, SIG_OVERLAY_CLICKED,
+ overlay);
+ if (overlay->cb) overlay->cb(overlay->cb_data, overlay->wd->obj,
+ overlay);
}
static void
-_sizing_eval(Evas_Object *obj)
+_overlay_default_hide(Overlay_Default *ovl)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
- if (!wd) return;
- evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
- evas_object_size_hint_min_set(obj, minw, minh);
- evas_object_size_hint_max_set(obj, maxw, maxh);
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ if (ovl->content) evas_object_hide(ovl->content);
+ if (ovl->icon) evas_object_hide(ovl->icon);
+ if (ovl->clas_content) evas_object_hide(ovl->clas_content);
+ if (ovl->clas_icon) evas_object_hide(ovl->clas_icon);
+ if (ovl->layout) evas_object_hide(ovl->layout);
}
static void
-_calc_job(void *data)
+_overlay_default_show(Overlay_Default *ovl)
{
- Widget_Data *wd = data;
- Evas_Coord minw, minh;
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ Evas_Object *disp;
+ Evas_Coord x, y, w, h;
- minw = wd->size.w;
- minh = wd->size.h;
- if (wd->resized)
+ evas_object_hide(ovl->layout);
+ if (ovl->content)
{
- wd->resized = 0;
- if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
- {
- double tz = wd->zoom;
- wd->zoom = 0.0;
- elm_map_zoom_set(wd->obj, tz);
- }
+ disp = ovl->content;
+ evas_object_geometry_get(disp, NULL, NULL, &w, &h);
+ if (w <= 0 || h <= 0) evas_object_size_hint_min_get(disp, &w, &h);
}
- if ((minw != wd->minw) || (minh != wd->minh))
+ else if (!(ovl->icon) && ovl->clas_content)
{
- wd->minw = minw;
- wd->minh = minh;
- evas_object_smart_callback_call(wd->pan_smart, SIG_CHANGED, NULL);
- _sizing_eval(wd->obj);
+ disp = ovl->clas_content;
+
+ evas_object_geometry_get(disp, NULL, NULL, &w, &h);
+ if (w <= 0 || h <= 0) evas_object_size_hint_min_get(disp, &w, &h);
}
- wd->calc_job = NULL;
- evas_object_smart_changed(wd->pan_smart);
+ else
+ {
+ if (ovl->icon) evas_object_show(ovl->icon);
+ else if (ovl->clas_icon) evas_object_show(ovl->clas_icon);
+ disp = ovl->layout;
+ w = ovl->w;
+ h = ovl->h;
+ }
+ _coord_to_canvas(ovl->wd, ovl->x, ovl->y, &x, &y);
+ _obj_place(disp, x - (w / 2), y - (h / 2), w, h);
}
static void
-_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
+_overlay_default_coord_get(Overlay_Default *ovl, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
{
- Pan *sd = evas_object_smart_data_get(obj);
- if (!sd) return;
- if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
- sd->wd->pan_x = x;
- sd->wd->pan_y = y;
- evas_object_smart_changed(obj);
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ if (x) *x = ovl->x;
+ if (y) *y = ovl->y;
+ if (w) *w = ovl->w;
+ if (h) *h = ovl->h;
}
static void
-_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
+_overlay_default_coord_set(Overlay_Default *ovl, Evas_Coord x, Evas_Coord y)
{
- Pan *sd = evas_object_smart_data_get(obj);
- if (!sd) return;
- if (x) *x = sd->wd->pan_x;
- if (y) *y = sd->wd->pan_y;
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ ovl->x = x;
+ ovl->y = y;
}
static void
-_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
+_overlay_default_coord_update(Overlay_Default *ovl)
{
- Pan *sd = evas_object_smart_data_get(obj);
- Evas_Coord ow, oh;
- if (!sd) return;
- evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
- ow = sd->wd->minw - ow;
- if (ow < 0) ow = 0;
- oh = sd->wd->minh - oh;
- if (oh < 0) oh = 0;
- if (x) *x = ow;
- if (y) *y = oh;
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ _region_to_coord_convert(ovl->wd, ovl->lon, ovl->lat, ovl->wd->size.w,
+ &ovl->x, &ovl->y);
}
static void
-_pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
+_overlay_default_layout_text_update(Overlay_Default *ovl, const char *text)
{
- if (x) *x = 0;
- if (y) *y = 0;
+ if (!ovl->content && !ovl->icon && !ovl->clas_content && !ovl->clas_icon)
+ edje_object_part_text_set(elm_layout_edje_get(ovl->layout), "elm.text",
+ text);
}
static void
-_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
+_overlay_default_content_update(Overlay_Default *ovl, Evas_Object *content, Elm_Map_Overlay *overlay)
{
- Pan *sd = evas_object_smart_data_get(obj);
- if (!sd) return;
- if (w) *w = sd->wd->minw;
- if (h) *h = sd->wd->minh;
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ if (ovl->content == content) return;
+ if (ovl->content) evas_object_del(ovl->content);
+ ovl->content = content;
+
+ if (ovl->content)
+ evas_object_event_callback_add(ovl->content, EVAS_CALLBACK_MOUSE_DOWN,
+ _overlay_clicked_cb, overlay);
}
static void
-_pan_add(Evas_Object *obj)
+_overlay_default_clas_content_update(Overlay_Default *ovl, const Evas_Object *content __UNUSED__)
{
- Pan *sd;
- Evas_Object_Smart_Clipped_Data *cd;
- _pan_sc.add(obj);
- cd = evas_object_smart_data_get(obj);
- if (!cd) return;
- sd = calloc(1, sizeof(Pan));
- if (!sd) return;
- sd->__clipped_data = *cd;
- free(cd);
- evas_object_smart_data_set(obj, sd);
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ if (ovl->clas_content) evas_object_del(ovl->clas_content);
+ // Evas_Object can not be duplicated.
+ //ovl->clas_content = _content_dup(content);
}
static void
-_pan_del(Evas_Object *obj)
+_overlay_default_layout_update(Overlay_Default *ovl)
{
- Pan *sd = evas_object_smart_data_get(obj);
- if (!sd) return;
- _pan_sc.del(obj);
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ if (ovl->icon)
+ {
+ evas_object_color_set(ovl->layout, 255, 255, 255, 255);
+ elm_layout_theme_set(ovl->layout, "map/marker", "empty",
+ elm_widget_style_get(ovl->wd->obj));
+ elm_object_part_content_set(ovl->layout, "elm.icon", ovl->icon);
+ }
+ else if (!ovl->icon && ovl->clas_icon)
+ {
+ evas_object_color_set(ovl->layout, 255, 255, 255, 255);
+ elm_layout_theme_set(ovl->layout, "map/marker", "empty",
+ elm_widget_style_get(ovl->wd->obj));
+ elm_object_part_content_set(ovl->layout, "elm.icon", ovl->clas_icon);
+ }
+ else
+ {
+ evas_object_color_set(ovl->layout, ovl->c.r, ovl->c.g, ovl->c.b, ovl->c.a);
+ elm_layout_theme_set(ovl->layout, "map/marker", "radio",
+ elm_widget_style_get(ovl->wd->obj));
+ }
}
static void
-_pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
+_overlay_default_icon_update(Overlay_Default *ovl, Evas_Object *icon)
{
- Pan *sd = evas_object_smart_data_get(obj);
- Evas_Coord ow, oh;
- if (!sd) return;
- evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
- if ((ow == w) && (oh == h)) return;
- sd->wd->resized = 1;
- if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
- sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ if (ovl->icon == icon) return;
+ if (ovl->icon) evas_object_del(ovl->icon);
+ ovl->icon = icon;
+ _overlay_default_layout_update(ovl);
}
static void
-_pan_calculate(Evas_Object *obj)
+_overlay_default_clas_icon_update(Overlay_Default *ovl, const Evas_Object *icon)
{
- Pan *sd = evas_object_smart_data_get(obj);
- Evas_Coord ox, oy, ow, oh;
- Eina_List *l;
- Grid *g;
- if (!sd) return;
- evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
- rect_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
- EINA_LIST_FOREACH(sd->wd->grids, l, g)
- {
- if (sd->wd->pinch.level == 1.0) grid_load(sd->wd->obj, g);
- grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
- marker_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
- if (!sd->wd->zoom_animator) route_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
- }
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ if (ovl->clas_icon) evas_object_del(ovl->clas_icon);
+ ovl->clas_icon = _icon_dup(icon, ovl->layout);
+ _overlay_default_layout_update(ovl);
}
static void
-_pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
+_overlay_default_color_update(Overlay_Default *ovl, Color c)
{
- Pan *sd = evas_object_smart_data_get(obj);
- if (!sd) return;
- if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
- sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ ovl->c = c;
+ _overlay_default_layout_update(ovl);
}
static void
-_hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- elm_smart_scroller_hold_set(wd->scr, 1);
+_overlay_default_free(Overlay_Default *ovl)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ if (ovl->content) evas_object_del(ovl->content);
+ if (ovl->icon) evas_object_del(ovl->icon);
+ if (ovl->clas_content) evas_object_del(ovl->clas_content);
+ if (ovl->clas_icon) evas_object_del(ovl->clas_icon);
+ if (ovl->layout) evas_object_del(ovl->layout);
+ free(ovl);
+}
+
+static Overlay_Default *
+_overlay_default_new(Elm_Map_Overlay *overlay, double lon, double lat, Color c, double scale)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
+
+ Overlay_Default *ovl = ELM_NEW(Overlay_Default);
+ ovl->wd = overlay->wd;
+ _edj_marker_size_get(ovl->wd, &(ovl->w), &(ovl->h));
+ ovl->w *= scale;
+ ovl->h *= scale;
+ ovl->layout = elm_layout_add(ovl->wd->obj);
+ evas_object_smart_member_add(ovl->layout, ovl->wd->pan_smart);
+ evas_object_stack_above(ovl->layout, ovl->wd->sep_maps_markers);
+ elm_layout_theme_set(ovl->layout, "map/marker", "radio",
+ elm_widget_style_get(ovl->wd->obj));
+ evas_object_event_callback_add(ovl->layout, EVAS_CALLBACK_MOUSE_DOWN,
+ _overlay_clicked_cb, overlay);
+ ovl->lon = lon;
+ ovl->lat = lat;
+ _overlay_default_color_update(ovl, c);
+ return ovl;
}
static void
-_hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+_overlay_group_hide(Overlay_Group *grp)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- elm_smart_scroller_hold_set(wd->scr, 0);
+ EINA_SAFETY_ON_NULL_RETURN(grp);
+ if (grp->ovl) _overlay_default_hide(grp->ovl);
}
static void
-_freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+_overlay_group_show(Overlay_Group *grp)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- elm_smart_scroller_freeze_set(wd->scr, 1);
+ EINA_SAFETY_ON_NULL_RETURN(grp);
+ if (grp->ovl) _overlay_default_show(grp->ovl);
}
static void
-_freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
+_overlay_group_coord_member_update(Overlay_Group *grp, Evas_Coord x, Evas_Coord y, Eina_List *members)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- elm_smart_scroller_freeze_set(wd->scr, 0);
+ EINA_SAFETY_ON_NULL_RETURN(grp);
+ if (!grp->ovl) return;
+ char text[32];
+
+ _overlay_default_coord_set(grp->ovl, x, y);
+ if (grp->members) eina_list_free(grp->members);
+ grp->members = members;
+ snprintf(text, sizeof(text), "%d", eina_list_count(members));
+ _overlay_default_layout_text_update(grp->ovl, text);
}
static void
-_scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+_overlay_group_region_get(Overlay_Group *grp, double *lon, double *lat)
{
- evas_object_smart_callback_call(data, "scroll,anim,start", NULL);
+ EINA_SAFETY_ON_NULL_RETURN(grp);
+ Evas_Coord xx, yy;
+ _overlay_default_coord_get(grp->ovl, &xx, &yy, NULL, NULL);
+ _coord_to_canvas(grp->wd, xx, yy, &xx, &yy);
+ elm_map_canvas_to_region_convert(grp->wd->obj, xx, yy, lon, lat);
}
static void
-_scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+_overlay_group_icon_update(Overlay_Group *grp, const Evas_Object *icon)
{
- evas_object_smart_callback_call(data, "scroll,anim,stop", NULL);
+ EINA_SAFETY_ON_NULL_RETURN(grp);
+ if (grp->ovl) _overlay_default_icon_update(grp->ovl,
+ _icon_dup(icon, grp->wd->obj));
}
static void
-_scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+_overlay_group_content_update(Overlay_Group *grp __UNUSED__, const Evas_Object *content __UNUSED__)
{
- Widget_Data *wd = elm_widget_data_get(data);
- wd->center_on.enabled = EINA_FALSE;
- evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
+ EINA_SAFETY_ON_NULL_RETURN(grp);
+ // Evas_Object can not be duplicated.
+ //_overlay_default_content_update(grp->ovl, _content_dup(content));
+ return;
}
static void
-_scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+_overlay_group_color_update(Overlay_Group *grp, Color c)
{
- evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
+ EINA_SAFETY_ON_NULL_RETURN(grp);
+ _overlay_default_color_update(grp->ovl, c);
}
static void
-_scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+_overlay_group_cb_set(Overlay_Group *grp, Elm_Map_Overlay_Get_Cb cb, void *data)
{
- evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
+ EINA_SAFETY_ON_NULL_RETURN(grp);
+ grp->overlay->cb = cb;
+ grp->overlay->data = data;
}
-
static void
-_group_object_create(Marker_Group *group)
+_overlay_group_free(Overlay_Group *grp)
{
- const char *style = "radio";
- Evas_Object *icon = NULL;
-
- if (group->obj) return;
- if ((!group->clas->priv.objs_notused) || (eina_list_count(group->markers) == 1))
- {
- //set icon and style
- if (eina_list_count(group->markers) == 1)
- {
- Elm_Map_Marker *m = eina_list_data_get(group->markers);
- if (m->clas->style)
- style = m->clas->style;
+ EINA_SAFETY_ON_NULL_RETURN(grp);
+ if (grp->overlay) free(grp->overlay);
+ if (grp->ovl) _overlay_default_free(grp->ovl);
+ if (grp->members) eina_list_free(grp->members);
+ free(grp);
+}
- if (m->clas->func.icon_get)
- icon = m->clas->func.icon_get(group->wd->obj, m, m->data);
+static Overlay_Group *
+_overlay_group_new(Widget_Data *wd)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
- group->delete_object = EINA_TRUE;
- }
- else
- {
- if (group->clas->style)
- style = group->clas->style;
+ Overlay_Group *grp = ELM_NEW(Overlay_Group);
+ grp->wd = wd;
+ grp->overlay = ELM_NEW(Elm_Map_Overlay); // this is a virtual overlay
+ grp->overlay->wd = wd;
+ grp->overlay->type = ELM_MAP_OVERLAY_TYPE_GROUP;
+ grp->overlay->ovl = grp;
+ Color c = {0x90, 0xee, 0x90, 0xff};
+ grp->ovl = _overlay_default_new(grp->overlay, -1, -1, c, 2);
+ return grp;
+}
- if (group->clas->func.icon_get)
- icon = group->clas->func.icon_get(group->wd->obj, group->clas->data);
+static void
+_overlay_class_cb_set(Overlay_Class *ovl, Elm_Map_Overlay_Get_Cb cb, void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
- group->delete_object = EINA_FALSE;
- }
+ Eina_List *l;
+ Elm_Map_Overlay *overlay;
- group->obj = elm_layout_add(group->wd->obj);
- elm_layout_theme_set(group->obj, "map/marker", style, elm_widget_style_get(group->wd->obj));
+ // Update class members' callbacks
+ EINA_LIST_FOREACH(ovl->members, l, overlay)
+ _overlay_group_cb_set(overlay->grp, cb, data);
+}
- if (icon) elm_layout_content_set(group->obj, "elm.icon", icon);
+static void
+_overlay_class_icon_update(Overlay_Class *ovl, Evas_Object *icon)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
- evas_object_smart_member_add(group->obj, group->wd->pan_smart);
- elm_widget_sub_object_add(group->wd->obj, group->obj);
- evas_object_stack_above(group->obj, group->wd->sep_maps_markers);
+ Eina_List *l;
+ Elm_Map_Overlay *overlay;
+ if (ovl->icon == icon) return;
+ if (ovl->icon) evas_object_del(ovl->icon);
+ ovl->icon = icon;
- if (!group->delete_object)
- group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
- }
- else
+ // Update class members' class icons
+ EINA_LIST_FOREACH(ovl->members, l, overlay)
{
- group->delete_object = EINA_FALSE;
-
- group->obj = eina_list_data_get(group->clas->priv.objs_notused);
- group->clas->priv.objs_used = eina_list_append(group->clas->priv.objs_used, group->obj);
- group->clas->priv.objs_notused = eina_list_remove(group->clas->priv.objs_notused, group->obj);
- evas_object_show(group->obj);
- }
-
- edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb, group);
- edje_object_signal_callback_add(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb, group);
+ _overlay_group_icon_update(overlay->grp, icon);
- group->update_nbelems = EINA_TRUE;
- group->update_resize = EINA_TRUE;
- group->update_raise = EINA_TRUE;
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ _overlay_default_clas_icon_update(overlay->ovl, icon);
- if (group->open) _group_bubble_create(group);
+ }
}
static void
-_group_object_free(Marker_Group *group)
+_overlay_class_content_update(Overlay_Class *ovl, Evas_Object *content)
{
- if (!group->obj) return;
- if (!group->delete_object)
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+
+ Eina_List *l;
+ Elm_Map_Overlay *overlay;
+ if (ovl->content == content) return;
+ if (ovl->content) evas_object_del(ovl->content);
+ ovl->content = content;
+
+ // Update class members' class contents
+ EINA_LIST_FOREACH(ovl->members, l, overlay)
{
- group->clas->priv.objs_notused = eina_list_append(group->clas->priv.objs_notused, group->obj);
- group->clas->priv.objs_used = eina_list_remove(group->clas->priv.objs_used, group->obj);
- evas_object_hide(group->obj);
+ _overlay_group_content_update(overlay->grp, content);
- edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "open", "elm", _group_open_cb);
- edje_object_signal_callback_del(elm_layout_edje_get(group->obj), "bringin", "elm", _group_bringin_cb);
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ _overlay_default_clas_content_update(overlay->ovl, content);
}
- else
- evas_object_del(group->obj);
-
- group->obj = NULL;
- _group_bubble_free(group);
}
static void
-_group_bubble_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+_overlay_class_color_update(Overlay_Class *ovl, Color c)
{
- Marker_Group *group = data;
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+
+ Eina_List *l;
+ Elm_Map_Overlay *overlay;
- if (!evas_object_above_get(group->rect)) return;
- evas_object_raise(group->bubble);
- evas_object_raise(group->sc);
- evas_object_raise(group->rect);
+ // Update class members' class contents
+ EINA_LIST_FOREACH(ovl->members, l, overlay)
+ _overlay_group_color_update(overlay->grp, c);
}
static void
-_group_bubble_create(Marker_Group *group)
+_overlay_class_free(Overlay_Class *clas)
{
- if (group->bubble) return;
+ EINA_SAFETY_ON_NULL_RETURN(clas);
- group->wd->opened_bubbles = eina_list_append(group->wd->opened_bubbles, group);
- group->bubble = edje_object_add(evas_object_evas_get(group->obj));
- _elm_theme_object_set(group->wd->obj, group->bubble, "map", "marker_bubble",
- elm_widget_style_get(group->wd->obj));
- evas_object_smart_member_add(group->bubble,
- group->wd->obj);
- elm_widget_sub_object_add(group->wd->obj, group->bubble);
+ Eina_List *l;
+ Elm_Map_Overlay *overlay;
- _group_bubble_content_free(group);
- if (!_group_bubble_content_update(group))
+ // Update class members' class contents
+ EINA_LIST_FOREACH(clas->members, l, overlay)
{
- //no content, we can delete the bubble
- _group_bubble_free(group);
- return;
- }
-
- group->rect = evas_object_rectangle_add(evas_object_evas_get(group->obj));
- evas_object_color_set(group->rect, 0, 0, 0, 0);
- evas_object_repeat_events_set(group->rect, EINA_TRUE);
- evas_object_smart_member_add(group->rect, group->wd->obj);
- elm_widget_sub_object_add(group->wd->obj, group->rect);
+ overlay->grp->clas = NULL;
+ _overlay_group_content_update(overlay->grp, NULL);
+ _overlay_group_icon_update(overlay->grp, NULL);
- evas_object_event_callback_add(group->rect, EVAS_CALLBACK_MOUSE_UP, _group_bubble_mouse_up_cb, group);
-
- _group_bubble_place(group);
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ {
+ _overlay_default_clas_content_update(overlay->ovl, NULL);
+ _overlay_default_clas_icon_update(overlay->ovl, NULL);
+ }
+ }
+ if (clas->icon) evas_object_del(clas->icon);
+ if (clas->members) eina_list_free(clas->members);
+ free(clas);
}
-static void _bubble_sc_hits_changed_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+static Overlay_Class *
+_overlay_class_new(Widget_Data *wd)
{
- _group_bubble_place(data);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+ Overlay_Class *ovl = ELM_NEW(Overlay_Class);
+ ovl->wd = wd;
+ ovl->icon = NULL;
+ ovl->zoom_max = OVERLAY_CLASS_ZOOM_MAX;
+ return ovl;
}
-static int
-_group_bubble_content_update(Marker_Group *group)
+static void
+_overlay_bubble_hide(Overlay_Bubble *bubble)
{
- Eina_List *l;
- Elm_Map_Marker *marker;
- int i = 0;
-
- if (!group->bubble) return 1;
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ if (bubble->obj) evas_object_hide(bubble->obj);
+}
- if (!group->sc)
+static void
+_overlay_bubble_coord_update(Overlay_Bubble *bubble)
+{
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ if (!(bubble->pobj))
{
- group->sc = elm_scroller_add(group->bubble);
- elm_widget_style_set(group->sc, "map_bubble");
- elm_scroller_content_min_limit(group->sc, EINA_FALSE, EINA_TRUE);
- elm_scroller_policy_set(group->sc, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
- elm_scroller_bounce_set(group->sc, _elm_config->thumbscroll_bounce_enable, EINA_FALSE);
- edje_object_part_swallow(group->bubble, "elm.swallow.content", group->sc);
- evas_object_show(group->sc);
- evas_object_smart_member_add(group->sc,
- group->wd->obj);
- elm_widget_sub_object_add(group->wd->obj, group->sc);
-
- group->bx = elm_box_add(group->bubble);
- evas_object_size_hint_align_set(group->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_size_hint_weight_set(group->bx, 0.5, 0.5);
- elm_box_horizontal_set(group->bx, EINA_TRUE);
- evas_object_show(group->bx);
-
- elm_scroller_content_set(group->sc, group->bx);
-
- evas_object_event_callback_add(group->sc, EVAS_CALLBACK_RESIZE,
- _bubble_sc_hits_changed_cb, group);
+ _region_to_coord_convert(bubble->wd, bubble->lon, bubble->lat,
+ bubble->wd->size.w, &bubble->x, &bubble->y);
}
+}
- EINA_LIST_FOREACH(group->markers, l, marker)
+static void
+_overlay_bubble_coord_get(Overlay_Bubble *bubble, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
+{
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ if (!(bubble->pobj))
{
- if (i >= group->wd->markers_max_num) break;
- if ((!marker->content) && (marker->clas->func.get))
- marker->content = marker->clas->func.get(group->wd->obj, marker, marker->data);
- else if (marker->content)
- elm_box_unpack(group->bx, marker->content);
- if (marker->content)
- {
- elm_box_pack_end(group->bx, marker->content);
- i++;
- }
+ if (x) *x = bubble->x;
+ if (y) *y = bubble->y;
+ if (w) *w = bubble->w;
+ if (h) *h = bubble->h;
+ }
+ else
+ {
+ if (x) *x = 0;
+ if (y) *y = 0;
+ if (w) *w = 0;
+ if (h) *h = 0;
}
- return i;
}
static void
-_group_bubble_content_free(Marker_Group *group)
+_overlay_bubble_show(Overlay_Bubble *bubble)
{
- Eina_List *l;
- Elm_Map_Marker *marker;
-
- if (!group->sc) return;
- EINA_LIST_FOREACH(group->markers, l, marker)
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ if (!(bubble->pobj))
{
- if ((marker->content) && (marker->clas->func.del))
- marker->clas->func.del(group->wd->obj, marker, marker->data, marker->content);
- else if (marker->content)
- evas_object_del(marker->content);
- marker->content = NULL;
+ _coord_to_canvas(bubble->wd, bubble->x, bubble->y,
+ &(bubble->x), &(bubble->y));
+ _obj_place(bubble->obj, bubble->x - (bubble->w /2),
+ bubble->y - (bubble->h /2), bubble->w, bubble->h);
}
- evas_object_del(group->sc);
- group->sc = NULL;
}
static void
-_group_bubble_free(Marker_Group *group)
+_overlay_bubble_chase(Overlay_Bubble *bubble)
+{
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ EINA_SAFETY_ON_NULL_RETURN(bubble->pobj);
+
+ Evas_Coord x, y, w;
+ evas_object_geometry_get(bubble->pobj, &x, &y, &w, NULL);
+ x = x + (w / 2) - (bubble->w / 2);
+ y = y - bubble->h;
+ _obj_place(bubble->obj, x, y, bubble->w, bubble->h);
+ evas_object_raise(bubble->obj);
+}
+
+static void
+_overlay_bubble_hide_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- if (!group->bubble) return;
- group->wd->opened_bubbles = eina_list_remove(group->wd->opened_bubbles, group);
- evas_object_event_callback_del_full(group->sc, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
- _bubble_sc_hits_changed_cb, group);
- evas_object_del(group->bubble);
- evas_object_del(group->rect);
- group->bubble = NULL;
- _group_bubble_content_free(group);
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ _overlay_bubble_hide(data);
}
static void
-_group_bubble_place(Marker_Group *group)
+_overlay_bubble_chase_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- Evas_Coord x, y, w;
- Evas_Coord xx, yy, ww, hh;
- const char *s;
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ _overlay_bubble_chase(data);
+}
- if ((!group->bubble) || (!group->obj)) return;
+static void
+_overlay_bubble_free(Overlay_Bubble* bubble)
+{
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
- evas_object_geometry_get(group->obj, &x, &y, &w, NULL);
- edje_object_size_min_calc(group->bubble, NULL, &hh);
+ evas_object_del(bubble->bx);
+ evas_object_del(bubble->sc);
+ evas_object_del(bubble->obj);
+ if (bubble->pobj)
+ {
+ evas_object_event_callback_del_full(bubble->pobj, EVAS_CALLBACK_HIDE,
+ _overlay_bubble_hide_cb, bubble);
+ evas_object_event_callback_del_full(bubble->pobj, EVAS_CALLBACK_SHOW,
+ _overlay_bubble_chase_cb, bubble);
+ evas_object_event_callback_del_full(bubble->pobj, EVAS_CALLBACK_MOVE,
+ _overlay_bubble_chase_cb, bubble);
+ }
+ free(bubble);
+}
- s = edje_object_data_get(group->bubble, "size_w");
- if (s) ww = atoi(s);
- else ww = 0;
- xx = x + w / 2 - ww / 2;
- yy = y-hh;
+static Overlay_Bubble*
+_overlay_bubble_new(Elm_Map_Overlay *overlay)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
- evas_object_move(group->bubble, xx, yy);
- evas_object_resize(group->bubble, ww, hh);
- obj_rotate_zoom(group->wd, group->bubble);
- evas_object_show(group->bubble);
+ Evas_Coord h;
+ const char *s;
+ Overlay_Bubble *bubble = ELM_NEW(Overlay_Bubble);
+ bubble->wd = overlay->wd;
+
+ bubble->obj = edje_object_add(evas_object_evas_get(overlay->wd->obj));
+ _elm_theme_object_set(overlay->wd->obj, bubble->obj , "map", "marker_bubble",
+ elm_widget_style_get(overlay->wd->obj));
+ evas_object_event_callback_add(bubble->obj, EVAS_CALLBACK_MOUSE_UP,
+ _overlay_bubble_chase_cb, bubble);
+ evas_object_event_callback_add(bubble->obj, EVAS_CALLBACK_MOUSE_DOWN,
+ _overlay_clicked_cb, overlay);
+
+ bubble->sc = elm_scroller_add(bubble->obj);
+ elm_widget_style_set(bubble->sc, "map_bubble");
+ elm_scroller_content_min_limit(bubble->sc, EINA_FALSE, EINA_TRUE);
+ elm_scroller_policy_set(bubble->sc, ELM_SCROLLER_POLICY_AUTO,
+ ELM_SCROLLER_POLICY_OFF);
+ elm_scroller_bounce_set(bubble->sc, _elm_config->thumbscroll_bounce_enable,
+ EINA_FALSE);
+ edje_object_part_swallow(bubble->obj, "elm.swallow.content", bubble->sc);
+
+ bubble->bx = elm_box_add(bubble->sc);
+ evas_object_size_hint_align_set(bubble->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(bubble->bx, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_box_horizontal_set(bubble->bx, EINA_TRUE);
+ elm_object_content_set(bubble->sc, bubble->bx);
+
+ s = edje_object_data_get(bubble->obj, "size_w");
+ if (s) bubble->w = atoi(s);
+ else bubble->w = 0;
+
+ edje_object_size_min_calc(bubble->obj, NULL, &(bubble->h));
+ s = edje_object_data_get(bubble->obj, "size_h");
+ if (s) h = atoi(s);
+ else h = 0;
+ if (bubble->h < h) bubble->h = h;
+
+ bubble->lon = -1;
+ bubble->lat = -1;
+ bubble->x = -1;
+ bubble->y = -1;
+ return bubble;
+}
- evas_object_move(group->rect, xx, yy);
- evas_object_resize(group->rect, ww, hh);
- obj_rotate_zoom(group->wd, group->rect);
- evas_object_show(group->rect);
+static void
+_overlay_route_color_update(Overlay_Route *ovl, Color c)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
}
static void
-_group_bringin_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
+_overlay_route_hide(Overlay_Route *ovl)
{
- Marker_Group *group = data;
- Elm_Map_Marker *marker = eina_list_data_get(group->markers);
- if (!marker) return;
- group->bringin = EINA_TRUE;
- elm_map_geo_region_bring_in(group->wd->obj, marker->longitude, marker->latitude);
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ evas_object_hide(ovl->obj);
}
static void
-_group_open_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *soure __UNUSED__)
+_overlay_route_show(Overlay_Route *r)
{
- Marker_Group *group = data;
+ EINA_SAFETY_ON_NULL_RETURN(r);
+ EINA_SAFETY_ON_NULL_RETURN(r->wd);
+
+ Eina_List *l;
+ Path *p;
+ Path_Node *n;
- if (group->bringin)
+ evas_object_polygon_points_clear(r->obj);
+ EINA_LIST_FOREACH(r->nodes, l, n)
{
- group->bringin = EINA_FALSE;
- return;
+ p = eina_list_nth(r->paths, n->idx);
+ if (!p) continue;
+ _region_to_coord_convert(r->wd, n->pos.lon, n->pos.lat, r->wd->size.w,
+ &p->x, &p->y);
+ _coord_to_canvas(r->wd, p->x, p->y, &p->x, &p->y);
}
+ EINA_LIST_FOREACH(r->paths, l, p)
+ evas_object_polygon_point_add(r->obj, p->x - 3, p->y - 3);
- if (group->bubble)
+ EINA_LIST_REVERSE_FOREACH(r->paths, l, p)
+ evas_object_polygon_point_add(r->obj, p->x + 3, p->y + 3);
+ evas_object_show(r->obj);
+}
+
+static void
+_overlay_route_free(Overlay_Route* route)
+{
+ EINA_SAFETY_ON_NULL_RETURN(route);
+ Path *p;
+ Path_Node *n;
+
+ evas_object_del(route->obj);
+ EINA_LIST_FREE(route->paths, p) free(p);
+ EINA_LIST_FREE(route->nodes, n)
{
- group->open = EINA_FALSE;
- _group_bubble_free(group);
- return;
+ if (n->pos.address) eina_stringshare_del(n->pos.address);
+ free(n);
}
- group->open = EINA_TRUE;
- _group_bubble_create(group);
+ free(route);
}
-static Eina_Bool
-_event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
+static Overlay_Route *
+_overlay_route_new(Widget_Data *wd, const Elm_Map_Route *route, Color c)
{
- double zoom;
- Evas_Coord x = 0;
- Evas_Coord y = 0;
- Evas_Coord step_x = 0;
- Evas_Coord step_y = 0;
- Evas_Coord v_w = 0;
- Evas_Coord v_h = 0;
- Evas_Coord page_x = 0;
- Evas_Coord page_y = 0;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
- if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
- Evas_Event_Key_Down *ev = event_info;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return EINA_FALSE;
- if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
+ Eina_List *l;
+ Path_Node *n;
- elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
- elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
- elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
- elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
+ Overlay_Route *ovl = ELM_NEW(Overlay_Route);
+ ovl->wd = wd;
+ ovl->obj = evas_object_polygon_add(evas_object_evas_get(wd->obj));
+ evas_object_smart_member_add(ovl->obj, wd->pan_smart);
+ _overlay_route_color_update(ovl, c);
- if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
+ EINA_LIST_FOREACH(route->nodes, l, n)
{
- x -= step_x;
- }
- else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
- {
- x += step_x;
- }
- else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
- {
- y -= step_y;
- }
- else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
- {
- y += step_y;
- }
- else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
- {
- if (page_y < 0)
- y -= -(page_y * v_h) / 100;
- else
- y -= page_y;
- }
- else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
- {
- if (page_y < 0)
- y += -(page_y * v_h) / 100;
- else
- y += page_y;
- }
- else if (!strcmp(ev->keyname, "KP_Add"))
- {
- zoom = elm_map_zoom_get(obj);
- zoom += 1;
- elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
- elm_map_zoom_set(obj, zoom);
- return EINA_TRUE;
- }
- else if (!strcmp(ev->keyname, "KP_Subtract"))
- {
- zoom = elm_map_zoom_get(obj);
- zoom -= 1;
- elm_map_zoom_mode_set(obj, ELM_MAP_ZOOM_MODE_MANUAL);
- elm_map_zoom_set(obj, zoom);
- return EINA_TRUE;
+ Path *path;
+ Path_Node *node;
+
+ node = ELM_NEW(Path_Node);
+ node->idx = n->idx;
+ node->pos.lon = n->pos.lon;
+ node->pos.lat = n->pos.lat;
+ if (n->pos.address) node->pos.address = strdup(n->pos.address);
+ ovl->nodes = eina_list_append(ovl->nodes, node);
+
+ path = ELM_NEW(Path);
+ ovl->paths = eina_list_append(ovl->paths, path);
}
- else return EINA_FALSE;
+ return ovl;
+}
- ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
- elm_smart_scroller_child_pos_set(wd->scr, x, y);
+static void
+_overlay_line_color_update(Overlay_Line *ovl, Color c)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
+}
- return EINA_TRUE;
+static void
+_overlay_line_hide(Overlay_Line *ovl)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ if (ovl->obj) evas_object_hide(ovl->obj);
}
-static Eina_Bool
-cb_dump_name_attrs(void *data, const char *key, const char *value)
+static void
+_overlay_line_show(Overlay_Line *ovl)
{
- Name_Dump *dump = (Name_Dump*)data;
- if (!dump) return EINA_FALSE;
+ Evas_Coord fx, fy, tx, ty;
+ Widget_Data *wd = ovl->wd;
- if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value);
- else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value);
+ _region_to_coord_convert(wd, ovl->flon, ovl->flat, wd->size.w, &fx, &fy);
+ _region_to_coord_convert(wd, ovl->tlon, ovl->tlat, wd->size.w, &tx, &ty);
+ _coord_to_canvas(wd, fx, fy, &fx, &fy);
+ _coord_to_canvas(wd, tx, ty, &tx, &ty);
+ evas_object_line_xy_set(ovl->obj, fx, fy, tx, ty);
+ evas_object_show(ovl->obj);
+}
- return EINA_TRUE;
+static void
+_overlay_line_free(Overlay_Line *ovl)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ evas_object_del(ovl->obj);
+ free(ovl);
}
+static Overlay_Line *
+_overlay_line_new(Widget_Data *wd, double flon, double flat, double tlon, double tlat, Color c)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
-static Eina_Bool
-cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
+ Overlay_Line *ovl = ELM_NEW(Overlay_Line);
+ ovl->wd = wd;
+ ovl->flon = flon;
+ ovl->flat = flat;
+ ovl->tlon = tlon;
+ ovl->tlat = tlat;
+ ovl->obj = evas_object_line_add(evas_object_evas_get(wd->obj));
+ evas_object_smart_member_add(ovl->obj, wd->pan_smart);
+ _overlay_line_color_update(ovl, c);
+ return ovl;
+}
+
+static void
+_overlay_polygon_color_update(Overlay_Polygon *ovl, Color c)
{
- Route_Dump *dump = data;
- if (!dump) return EINA_FALSE;
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
+}
- switch (type)
- {
- case EINA_SIMPLE_XML_OPEN:
- case EINA_SIMPLE_XML_OPEN_EMPTY:
- {
- const char *attrs;
+static void
+_overlay_polygon_hide(Overlay_Polygon *ovl)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ if (ovl->obj) evas_object_hide(ovl->obj);
+}
- attrs = eina_simple_xml_tag_attributes_find(value, length);
- if (!attrs)
- {
- if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
- else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
- else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
- else dump->id = ROUTE_XML_NONE;
- }
- }
- break;
- case EINA_SIMPLE_XML_DATA:
- {
- char *buf = malloc(length);
- if (!buf) return EINA_FALSE;
- snprintf(buf, length, "%s", value);
- if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf);
- else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
- else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
- free(buf);
- }
- break;
- default:
- break;
+static void
+_overlay_polygon_show(Overlay_Polygon *ovl)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ Eina_List *l;
+ Region *r;
+ Widget_Data *wd = ovl->wd;
+
+ evas_object_polygon_points_clear(ovl->obj);
+ EINA_LIST_FOREACH(ovl->regions, l, r)
+ {
+ Evas_Coord x, y;
+ _region_to_coord_convert(wd, r->lon, r->lat, wd->size.w, &x, &y);
+ _coord_to_canvas(wd, x, y, &x, &y);
+ evas_object_polygon_point_add(ovl->obj, x, y);
}
+ evas_object_show(ovl->obj);
+}
- return EINA_TRUE;
+static void
+_overlay_polygon_free(Overlay_Polygon *ovl)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ Region *r;
+ evas_object_del(ovl->obj);
+ EINA_LIST_FREE(ovl->regions, r) free(r);
+ free(ovl);
}
-static Eina_Bool
-cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
+static Overlay_Polygon *
+_overlay_polygon_new(Widget_Data *wd, Color c)
{
- Name_Dump *dump = data;
- if (!dump) return EINA_FALSE;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
- switch (type)
- {
- case EINA_SIMPLE_XML_OPEN:
- case EINA_SIMPLE_XML_OPEN_EMPTY:
- {
- const char *attrs;
- attrs = eina_simple_xml_tag_attributes_find(value, length);
- if (attrs)
- {
- if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT)-1)) dump->id = NAME_XML_NAME;
- else dump->id = NAME_XML_NONE;
+ Overlay_Polygon *ovl = ELM_NEW(Overlay_Polygon);
+ ovl->wd = wd;
+ ovl->obj = evas_object_polygon_add(evas_object_evas_get(wd->obj));
+ evas_object_smart_member_add(ovl->obj, wd->pan_smart);
+ _overlay_polygon_color_update(ovl, c);
+ return ovl;
+}
- eina_simple_xml_attributes_parse
- (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
- }
- }
- break;
- case EINA_SIMPLE_XML_DATA:
- {
- char *buf = malloc(length + 1);
- if (!buf) return EINA_FALSE;
- snprintf(buf, length + 1, "%s", value);
- if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
- free(buf);
- }
- break;
- default:
- break;
- }
+static void
+_overlay_circle_color_update(Overlay_Circle *ovl, Color c)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ Evas_Object *obj = elm_layout_edje_get(ovl->obj);
+ evas_object_color_set(obj, c.r, c.g, c.b, c.a);
+}
- return EINA_TRUE;
+static void
+_overlay_circle_hide(Overlay_Circle *ovl)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ if (ovl->obj) evas_object_hide(ovl->obj);
+}
+
+static void
+_overlay_circle_show(Overlay_Circle *ovl)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ double r;
+ Evas_Coord x, y;
+ Widget_Data *wd = ovl->wd;
+
+ r = (ovl->ratio) * wd->size.w;
+ _region_to_coord_convert(wd, ovl->lon, ovl->lat, wd->size.w, &x, &y);
+ _coord_to_canvas(wd, x, y, &x, &y);
+ _obj_place(ovl->obj, x - r, y - r, r * 2, r * 2);
}
static void
-_parse_kml(void *data)
+_overlay_circle_free(Overlay_Circle *ovl)
{
- Elm_Map_Route *r = (Elm_Map_Route*)data;
- if (!r && !r->ud.fname) return;
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ evas_object_del(ovl->obj);
+ free(ovl);
+}
- FILE *f;
- char **str;
- unsigned int ele, idx;
- double lon, lat;
- Evas_Object *path;
+static Overlay_Circle *
+_overlay_circle_new(Widget_Data *wd, double lon, double lat, double radius, Color c)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
- Route_Dump dump = {0, r->ud.fname, 0.0, NULL, NULL};
+ Overlay_Circle *ovl = ELM_NEW(Overlay_Circle);
+ ovl->wd = wd;
+ ovl->lon = lon;
+ ovl->lat = lat;
+ ovl->radius = radius;
+ ovl->ratio = radius / wd->size.w;
- f = fopen(r->ud.fname, "rb");
- if (f)
+ ovl->obj = elm_layout_add(wd->obj);
+ evas_object_smart_member_add(ovl->obj, wd->pan_smart);
+ evas_object_stack_above(ovl->obj, wd->sep_maps_markers);
+ elm_layout_theme_set(ovl->obj, "map/circle", "base",
+ elm_widget_style_get(wd->obj));
+ _overlay_circle_color_update(ovl, c);
+ return ovl;
+}
+
+static void
+_overlay_scale_color_update(Overlay_Scale *ovl, Color c)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ evas_object_color_set(ovl->obj, c.r, c.g, c.b, c.a);
+}
+
+static void
+_overlay_scale_hide(Overlay_Scale *ovl)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ if (ovl->obj) evas_object_hide(ovl->obj);
+}
+
+ static void
+_overlay_scale_show(Overlay_Scale *ovl)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ Evas_Coord w;
+ double lon, lat;
+ double text;
+ char buf[32];
+ double meter;
+ Widget_Data *wd = ovl->wd;
+
+ if ((int)sizeof(_scale_tb) <= wd->zoom)
{
- long sz;
+ ERR("Zoom level is too high");
+ return;
+ }
- fseek(f, 0, SEEK_END);
- sz = ftell(f);
- if (sz > 0)
- {
- char *buf;
+ elm_map_region_get(wd->obj, &lon, &lat);
+ meter = wd->src_tile->scale_cb(wd->obj, lon, lat, wd->zoom);
- fseek(f, 0, SEEK_SET);
- buf = malloc(sz);
- if (buf)
- {
- if (fread(buf, 1, sz, f))
- {
- eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump, &dump);
- free(buf);
- }
- }
- }
- fclose(f);
+ w = (_scale_tb[wd->zoom] / meter) * (wd->zoom_detail - wd->zoom + 1);
- if (dump.distance) r->info.distance = dump.distance;
- if (dump.description)
- {
- eina_stringshare_replace(&r->info.waypoints, dump.description);
+ text = _scale_tb[wd->zoom]/1000;
+ if (text < 1) snprintf(buf, sizeof(buf), "%d m", (int)(text * 1000));
+ else snprintf(buf, sizeof(buf), "%d km", (int)text);
+
+ edje_object_part_text_set(elm_layout_edje_get(ovl->obj), "elm.text", buf);
+ _obj_place(ovl->obj, ovl->x, ovl->y, w, ovl->h);
+}
+
+ static void
+_overlay_scale_free(Overlay_Scale *ovl)
+{
+ EINA_SAFETY_ON_NULL_RETURN(ovl);
+ evas_object_del(ovl->obj);
+ free(ovl);
+}
+
+static Overlay_Scale *
+_overlay_scale_new(Widget_Data *wd, Evas_Coord x, Evas_Coord y, Color c)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+ const char *s;
+
+ Overlay_Scale *ovl = ELM_NEW(Overlay_Scale);
+ ovl->wd = wd;
+ ovl->x = x;
+ ovl->y = y;
+
+ ovl->obj = elm_layout_add(wd->obj);
+ evas_object_smart_member_add(ovl->obj, wd->pan_smart);
+ evas_object_stack_above(ovl->obj, wd->sep_maps_markers);
+ elm_layout_theme_set(ovl->obj, "map/scale", "base",
+ elm_widget_style_get(wd->obj));
+ s = edje_object_data_get(elm_layout_edje_get(ovl->obj), "size_w");
+ if (s) ovl->w = atoi(s);
+ else ovl->w = 100;
+ s = edje_object_data_get(elm_layout_edje_get(ovl->obj), "size_h");
+ if (s) ovl->h = atoi(s);
+ else ovl->h = 60;
+ _overlay_scale_color_update(ovl, c);
+ return ovl;
+}
+
+static void
+_overlay_grouping(Eina_List *clas_membs, Elm_Map_Overlay *boss)
+{
+ EINA_SAFETY_ON_NULL_RETURN(clas_membs);
+ EINA_SAFETY_ON_NULL_RETURN(boss);
+
+ Eina_List *l;
+ Eina_List *grp_membs = NULL;
+ Elm_Map_Overlay *memb;
+
+ int sum_x = 0, sum_y = 0, cnt = 0;
+ Evas_Coord bx = 0, by = 0, bw = 0, bh = 0;
+
+ if (boss->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ _overlay_default_coord_get(boss->ovl, &bx, &by, &bw, &bh);
+ else if (boss->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
+ _overlay_bubble_coord_get(boss->ovl, &bx, &by, &bw, &bh);
+
+ EINA_LIST_FOREACH(clas_membs, l, memb)
+ {
+ Evas_Coord x = 0, y = 0, w = 0, h = 0;
+
+ if (boss == memb || memb->grp->in) continue;
+ if ((memb->hide) || (memb->zoom_min > memb->wd->zoom)) continue;
+
+ if (memb->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ _overlay_default_coord_get(memb->ovl, &x, &y, &w, &h);
+ else if (memb->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
+ _overlay_bubble_coord_get(memb->ovl, &x, &y, &w, &h);
+
+ if (bw <= 0 || bh <= 0 || w <= 0 || h <= 0) continue;
+ if (ELM_RECTS_INTERSECT(x, y, w, h, bx, by,
+ bw * OVERLAY_GROUPING_SCALE,
+ bh * OVERLAY_GROUPING_SCALE))
+ {
+ // Join group.
+ memb->grp->boss = EINA_FALSE;
+ memb->grp->in = EINA_TRUE;
+ sum_x += x;
+ sum_y += y;
+ cnt++;
+ grp_membs = eina_list_append(grp_membs, memb);
+ }
+ }
+
+ if (cnt >= 1)
+ {
+ // Mark as boss
+ boss->grp->boss = EINA_TRUE;
+ boss->grp->in = EINA_TRUE;
+ sum_x = (sum_x + bx) / (cnt + 1);
+ sum_y = (sum_y + by) / (cnt + 1);
+ grp_membs = eina_list_append(grp_membs, boss);
+ _overlay_group_coord_member_update(boss->grp, sum_x, sum_y, grp_membs);
+ }
+}
+
+static void
+_overlay_show(Elm_Map_Overlay *overlay)
+{
+ Widget_Data *wd = overlay->wd;
+ Eina_Bool hide = EINA_FALSE;
+
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) return;
+
+ if (overlay->paused) return;
+ if ((overlay->grp->clas) && (overlay->grp->clas->paused)) return;
+
+ if (((overlay->grp->in) || (overlay->hide) ||
+ (overlay->zoom_min > wd->zoom)))
+ hide = EINA_TRUE;
+ if ((overlay->grp->clas) && ((overlay->grp->clas->hide) ||
+ (overlay->grp->clas->zoom_min > wd->zoom)))
+ hide = EINA_TRUE;
+
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ {
+ if (hide) _overlay_default_hide(overlay->ovl);
+ else _overlay_default_show(overlay->ovl);
+ }
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
+ {
+ if (hide) _overlay_bubble_hide(overlay->ovl);
+ else _overlay_bubble_show(overlay->ovl);
+ }
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
+ {
+ if (hide) _overlay_route_hide(overlay->ovl);
+ else _overlay_route_show(overlay->ovl);
+ }
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_LINE)
+ {
+ if (hide) _overlay_line_hide(overlay->ovl);
+ else _overlay_line_show(overlay->ovl);
+ }
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON)
+ {
+ if (hide) _overlay_polygon_hide(overlay->ovl);
+ else _overlay_polygon_show(overlay->ovl);
+ }
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CIRCLE)
+ {
+ if (hide) _overlay_circle_hide(overlay->ovl);
+ else _overlay_circle_show(overlay->ovl);
+ }
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_SCALE)
+ {
+ if (hide) _overlay_scale_hide(overlay->ovl);
+ else _overlay_scale_show(overlay->ovl);
+ }
+}
+
+static void
+_overlay_place(Widget_Data *wd)
+{
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ Eina_List *l, *ll;
+ Elm_Map_Overlay *overlay;
+
+ // Reset group & Update overlays coord
+ EINA_LIST_FOREACH(wd->overlays, l, overlay)
+ {
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) continue;
+ overlay->grp->in = EINA_FALSE;
+ overlay->grp->boss = EINA_FALSE;
+
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ _overlay_default_coord_update(overlay->ovl);
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
+ _overlay_bubble_coord_update(overlay->ovl);
+ }
+
+ // Classify into group boss or follwer
+ EINA_LIST_FOREACH(wd->overlays, l, overlay)
+ {
+ Elm_Map_Overlay *boss;
+ Overlay_Class *clas;
+
+ if (overlay->type != ELM_MAP_OVERLAY_TYPE_CLASS) continue;
+ if (overlay->hide || (overlay->zoom_min > wd->zoom)) continue;
+
+ clas = overlay->ovl;
+ if (clas->zoom_max < wd->zoom) continue;
+ EINA_LIST_FOREACH(clas->members, ll, boss)
+ {
+ if (boss->type == ELM_MAP_OVERLAY_TYPE_CLASS) continue;
+ if (boss->hide || (boss->zoom_min > wd->zoom)) continue;
+ if (boss->grp->in) continue;
+ _overlay_grouping(clas->members, boss);
+ }
+ }
+
+ // Place overlays
+ EINA_LIST_FOREACH(wd->overlays, l, overlay) _overlay_show(overlay);
+
+ // Place group overlays on top of overlays
+ EINA_LIST_FOREACH(wd->overlays, l, overlay)
+ {
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS) continue;
+ if (overlay->grp->boss) _overlay_group_show(overlay->grp);
+ else _overlay_group_hide(overlay->grp);
+ }
+}
+
+static Evas_Object *
+_overlay_obj_get(const Elm_Map_Overlay *overlay)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_GROUP)
+ {
+ Overlay_Group *ovl = overlay->ovl;
+ Overlay_Default *df = ovl->ovl;
+ return df->layout;
+ }
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ {
+ Overlay_Default *ovl = overlay->ovl;
+ return ovl->layout;
+ }
+ else
+ {
+ ERR("Not supported overlay type: %d", overlay->type);
+ return NULL;
+ }
+}
+
+static void
+_overlays_show(void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Delayed_Data *dd = data;
+
+ int zoom;
+ double max_lon, min_lon, max_lat, min_lat;
+ Evas_Coord vw, vh;
+
+ _region_max_min_get(dd->overlays, &max_lon, &min_lon, &max_lat, &min_lat);
+ dd->lon = (max_lon + min_lon) / 2;
+ dd->lat = (max_lat + min_lat) / 2;
+
+ zoom = dd->wd->src_tile->zoom_min;
+ _viewport_coord_get(dd->wd, NULL, NULL, &vw, &vh);
+ while (zoom <= dd->wd->src_tile->zoom_max)
+ {
+ Evas_Coord size, max_x, max_y, min_x, min_y;
+ size = pow(2.0, zoom) * dd->wd->tsize;
+ _region_to_coord_convert(dd->wd, min_lon, max_lat, size, &min_x, &max_y);
+ _region_to_coord_convert(dd->wd, max_lon, min_lat, size, &max_x, &min_y);
+ if ((max_x - min_x) > vw || (max_y - min_y) > vh) break;
+ zoom++;
+ }
+ zoom--;
+
+ zoom_do(dd->wd, zoom);
+ _region_show(dd);
+ evas_object_smart_changed(dd->wd->pan_smart);
+}
+
+static void
+_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
+{
+ Pan *sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(sd);
+ if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
+
+ sd->wd->pan_x = x;
+ sd->wd->pan_y = y;
+ evas_object_smart_changed(obj);
+}
+
+static void
+_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
+{
+ Pan *sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(sd);
+ if (x) *x = sd->wd->pan_x;
+ if (y) *y = sd->wd->pan_y;
+}
+
+static void
+_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
+{
+ Pan *sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(sd);
+ Evas_Coord ow, oh;
+ evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
+ ow = sd->wd->size.w - ow;
+ oh = sd->wd->size.h - oh;
+ if (ow < 0) ow = 0;
+ if (oh < 0) oh = 0;
+ if (x) *x = ow;
+ if (y) *y = oh;
+}
+
+static void
+_pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
+{
+ if (x) *x = 0;
+ if (y) *y = 0;
+}
+
+static void
+_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
+{
+ Pan *sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(sd);
+ if (w) *w = sd->wd->size.w;
+ if (h) *h = sd->wd->size.h;
+}
+
+static void
+_pan_add(Evas_Object *obj)
+{
+ Pan *sd;
+ Evas_Object_Smart_Clipped_Data *cd;
+ parent_sc.add(obj);
+ cd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(cd);
+ sd = ELM_NEW(Pan);
+ sd->__clipped_data = *cd;
+ free(cd);
+ evas_object_smart_data_set(obj, sd);
+}
+
+static void
+_pan_resize(Evas_Object *obj, Evas_Coord w __UNUSED__, Evas_Coord h __UNUSED__)
+{
+ Pan *sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(sd);
+
+ _sizing_eval(sd->wd);
+ elm_map_zoom_mode_set(sd->wd->obj, sd->wd->mode);
+ evas_object_smart_changed(obj);
+}
+
+static void
+_pan_calculate(Evas_Object *obj)
+{
+ Pan *sd = evas_object_smart_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(sd);
+
+ Evas_Coord w, h;
+ evas_object_geometry_get(obj, NULL, NULL, &w, &h);
+ if (w <= 0 || h <= 0) return;
+
+ _grid_place(sd->wd);
+ _marker_place(sd->wd);
+ _overlay_place(sd->wd);
+ _track_place(sd->wd);
+ _delayed_do(sd->wd);
+}
+
+static void
+_pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
+{
+ EINA_SAFETY_ON_NULL_RETURN(obj);
+ evas_object_smart_changed(obj);
+}
+
+static void
+_hold_on(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Widget_Data *wd = data;
+ elm_smart_scroller_hold_set(wd->scr, 1);
+}
+
+static void
+_hold_off(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Widget_Data *wd = data;
+ elm_smart_scroller_hold_set(wd->scr, 0);
+}
+
+static void
+_freeze_on(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Widget_Data *wd = data;
+ elm_smart_scroller_freeze_set(wd->scr, 1);
+}
+
+static void
+_freeze_off(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Widget_Data *wd = data;
+ elm_smart_scroller_freeze_set(wd->scr, 0);
+}
+
+static void
+_elm_map_marker_remove(Elm_Map_Marker *marker)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(marker);
+ Widget_Data *wd = marker->wd;
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ if ((marker->content) && (marker->clas->func.del))
+ marker->clas->func.del(wd->obj, marker, marker->data, marker->content);
+
+ if (marker->bubble) _bubble_free(marker->bubble);
+ if (marker->group) _marker_group_free(marker->group);
+
+ if (marker->group_clas)
+ marker->group_clas->markers = eina_list_remove(marker->group_clas->markers, marker);
+ wd->markers = eina_list_remove(wd->markers, marker);
+
+ evas_object_del(marker->obj);
+ free(marker);
+
+ evas_object_smart_changed(wd->pan_smart);
+#else
+ (void) marker;
+#endif
+}
+
+static Eina_Bool
+cb_dump_name_attrs(void *data, const char *key, const char *value)
+{
+ Name_Dump *dump = (Name_Dump*)data;
+ if (!dump) return EINA_FALSE;
+
+ if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value);
+ else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value);
+
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
+{
+ Route_Dump *dump = data;
+ if (!dump) return EINA_FALSE;
+
+ switch (type)
+ {
+ case EINA_SIMPLE_XML_OPEN:
+ case EINA_SIMPLE_XML_OPEN_EMPTY:
+ {
+ const char *attrs;
+
+ attrs = eina_simple_xml_tag_attributes_find(value, length);
+ if (!attrs)
+ {
+ if (!strncmp(value, YOURS_DISTANCE, length)) dump->id = ROUTE_XML_DISTANCE;
+ else if (!strncmp(value, YOURS_DESCRIPTION, length)) dump->id = ROUTE_XML_DESCRIPTION;
+ else if (!strncmp(value, YOURS_COORDINATES, length)) dump->id = ROUTE_XML_COORDINATES;
+ else dump->id = ROUTE_XML_NONE;
+ }
+ }
+ break;
+ case EINA_SIMPLE_XML_DATA:
+ {
+ char *buf = malloc(length);
+ if (!buf) return EINA_FALSE;
+ snprintf(buf, length, "%s", value);
+ if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf);
+ else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
+ else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
+ free(buf);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+cb_name_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned offset __UNUSED__, unsigned length)
+{
+ Name_Dump *dump = data;
+ if (!dump) return EINA_FALSE;
+
+ switch (type)
+ {
+ case EINA_SIMPLE_XML_OPEN:
+ case EINA_SIMPLE_XML_OPEN_EMPTY:
+ {
+ const char *attrs;
+ attrs = eina_simple_xml_tag_attributes_find(value, length);
+ if (attrs)
+ {
+ if (!strncmp(value, NOMINATIM_RESULT, sizeof(NOMINATIM_RESULT) - 1)) dump->id = NAME_XML_NAME;
+ else dump->id = NAME_XML_NONE;
+
+ eina_simple_xml_attributes_parse
+ (attrs, length - (attrs - value), cb_dump_name_attrs, dump);
+ }
+ }
+ break;
+ case EINA_SIMPLE_XML_DATA:
+ {
+ char *buf = malloc(length + 1);
+ if (!buf) return EINA_FALSE;
+ snprintf(buf, length + 1, "%s", value);
+ if (dump->id == NAME_XML_NAME) dump->address = strdup(buf);
+ free(buf);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return EINA_TRUE;
+}
+
+static void
+_kml_parse(Elm_Map_Route *r)
+{
+ EINA_SAFETY_ON_NULL_RETURN(r);
+ EINA_SAFETY_ON_NULL_RETURN(r->fname);
+
+ FILE *f;
+ char **str;
+ unsigned int ele, idx;
+ double lon, lat;
+
+ Route_Dump dump = {0, r->fname, 0.0, NULL, NULL};
+
+ f = fopen(r->fname, "rb");
+ if (f)
+ {
+ long sz;
+
+ fseek(f, 0, SEEK_END);
+ sz = ftell(f);
+ if (sz > 0)
+ {
+ char *buf;
+
+ fseek(f, 0, SEEK_SET);
+ buf = malloc(sz);
+ if (buf)
+ {
+ if (fread(buf, 1, sz, f))
+ {
+ eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_route_dump,
+ &dump);
+ free(buf);
+ }
+ }
+ }
+ fclose(f);
+
+ if (dump.distance) r->info.distance = dump.distance;
+ if (dump.description)
+ {
+ eina_stringshare_replace(&r->info.waypoints, dump.description);
str = eina_str_split_full(dump.description, "\n", 0, &ele);
r->info.waypoint_count = ele;
- for (idx = 0 ; idx < ele ; idx++)
+ for (idx = 0; idx < ele; idx++)
+ {
+ Path_Waypoint *wp = ELM_NEW(Path_Waypoint);
+ if (wp)
+ {
+ wp->wd = r->wd;
+ wp->point = eina_stringshare_add(str[idx]);
+ DBG("%s", str[idx]);
+ r->waypoint = eina_list_append(r->waypoint, wp);
+ }
+ }
+ if (str && str[0])
+ {
+ free(str[0]);
+ free(str);
+ }
+ }
+ else WRN("description is not found !");
+
+ if (dump.coordinates)
+ {
+ eina_stringshare_replace(&r->info.nodes, dump.coordinates);
+ str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
+ r->info.node_count = ele;
+ for (idx = 0; idx < ele; idx++)
+ {
+ sscanf(str[idx], "%lf,%lf", &lon, &lat);
+ Path_Node *n = ELM_NEW(Path_Node);
+ if (n)
+ {
+ n->wd = r->wd;
+ n->pos.lon = lon;
+ n->pos.lat = lat;
+ n->idx = idx;
+ DBG("%lf:%lf", lon, lat);
+ n->pos.address = NULL;
+ r->nodes = eina_list_append(r->nodes, n);
+ }
+ }
+ if (str && str[0])
+ {
+ free(str[0]);
+ free(str);
+ }
+ }
+ }
+}
+
+static void
+_name_parse(Elm_Map_Name *n)
+{
+ EINA_SAFETY_ON_NULL_RETURN(n);
+ EINA_SAFETY_ON_NULL_RETURN(n->fname);
+
+ FILE *f;
+
+ Name_Dump dump = {0, NULL, 0.0, 0.0};
+
+ f = fopen(n->fname, "rb");
+ if (f)
+ {
+ long sz;
+
+ fseek(f, 0, SEEK_END);
+ sz = ftell(f);
+ if (sz > 0)
+ {
+ char *buf;
+
+ fseek(f, 0, SEEK_SET);
+ buf = malloc(sz);
+ if (buf)
+ {
+ if (fread(buf, 1, sz, f))
+ {
+ eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
+ free(buf);
+ }
+ }
+ }
+ fclose(f);
+
+ if (dump.address)
+ {
+ INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
+ n->address = strdup(dump.address);
+ }
+ n->lon = dump.lon;
+ n->lat = dump.lat;
+ }
+}
+
+Grid *_get_current_grid(Widget_Data *wd)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+ Eina_List *l;
+ Grid *g = NULL, *ret = NULL;
+ EINA_LIST_FOREACH(wd->grids, l, g)
+ {
+ if (wd->zoom == g->zoom)
+ {
+ ret = g;
+ break;
+ }
+ }
+ return ret;
+}
+
+static void
+_route_cb(void *data, const char *file, int status)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ EINA_SAFETY_ON_NULL_RETURN(file);
+
+ Elm_Map_Route *route = data;
+ Widget_Data *wd = route->wd;
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ route->job = NULL;
+ if (status == 200)
+ {
+ _kml_parse(route);
+ INF("Route request success from (%lf, %lf) to (%lf, %lf)",
+ route->flon, route->flat, route->tlon, route->tlat);
+ if (route->cb) route->cb(route->data, wd->obj, route);
+ evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
+ }
+ else
+ {
+ ERR("Route request failed: %d", status);
+ if (route->cb) route->cb(route->data, wd->obj, NULL);
+ evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED_FAIL, NULL);
+ }
+
+ edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
+ "elm,state,busy,stop", "elm");
+}
+
+static void
+_name_cb(void *data, const char *file, int status)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ EINA_SAFETY_ON_NULL_RETURN(file);
+
+ Elm_Map_Name *name = data;
+ Widget_Data *wd = name->wd;
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ name->job = NULL;
+ if (status == 200)
+ {
+ _name_parse(name);
+ INF("Name request success address:%s, lon:%lf, lat:%lf",
+ name->address, name->lon, name->lat);
+ if (name->cb) name->cb(name->data, wd->obj, name);
+ evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
+ }
+ else
+ {
+ ERR("Name request failed: %d", status);
+ if (name->cb) name->cb(name->data, wd->obj, NULL);
+ evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED_FAIL, NULL);
+ }
+ edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
+ "elm,state,busy,stop", "elm");
+}
+
+
+
+static Elm_Map_Name *
+_name_request(const Evas_Object *obj, int method, const char *address, double lon, double lat, Elm_Map_Name_Cb name_cb, void *data)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_name, NULL);
+
+
+ char *url;
+ char fname[PATH_MAX];
+
+ if (!ecore_file_exists(CACHE_NAME_ROOT)) ecore_file_mkpath(CACHE_NAME_ROOT);
+
+ url = wd->src_name->url_cb(wd->obj, method, address, lon, lat);
+ if (!url)
+ {
+ ERR("Name URL is NULL");
+ return NULL;
+ }
+
+ Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
+ name->wd = wd;
+ snprintf(fname, sizeof(fname), CACHE_NAME_ROOT"/%d", rand());
+ name->fname = strdup(fname);
+ name->method = method;
+ if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
+ else if (method == ELM_MAP_NAME_METHOD_REVERSE)
+ {
+ name->lon = lon;
+ name->lat = lat;
+ }
+ name->cb = name_cb;
+ name->data = data;
+
+ if (!ecore_file_download_full(url, name->fname, _name_cb, NULL, name,
+ &(name->job), wd->ua) || !(name->job))
+ {
+ ERR("Can't request Name from %s to %s", url, name->fname);
+ if (name->address) free(name->address);
+ free(name->fname);
+ free(name);
+ return NULL;
+ }
+ INF("Name requested from %s to %s", url, name->fname);
+ free(url);
+
+ wd->names = eina_list_append(wd->names, name);
+ evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, name);
+ edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
+ "elm,state,busy,start", "elm");
+ return name;
+}
+
+static Evas_Event_Flags
+_pinch_zoom_start_cb(void *data, void *event_info __UNUSED__)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EVAS_EVENT_FLAG_NONE);
+ Widget_Data *wd = data;
+
+ wd->pinch_zoom = wd->zoom_detail;
+ return EVAS_EVENT_FLAG_NONE;
+}
+
+static Evas_Event_Flags
+_pinch_zoom_cb(void *data, void *event_info)
+{
+ Widget_Data *wd = data;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
+
+ if (!wd->paused)
+ {
+ Elm_Gesture_Zoom_Info *ei = event_info;
+ zoom_do(wd, wd->pinch_zoom + ei->zoom - 1);
+ }
+ return EVAS_EVENT_FLAG_NONE;
+}
+
+static Evas_Event_Flags
+_pinch_rotate_cb(void *data, void *event_info)
+{
+ Widget_Data *wd = data;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
+
+ if (!wd->paused)
+ {
+ int x, y, w, h;
+ Elm_Gesture_Rotate_Info *ei = event_info;
+ evas_object_geometry_get(wd->obj, &x, &y, &w, &h);
+
+ wd->rotate.d = wd->rotate.a + ei->angle - ei->base_angle;
+ wd->rotate.cx = x + ((double)w * 0.5);
+ wd->rotate.cy = y + ((double)h * 0.5);
+
+ evas_object_smart_changed(wd->pan_smart);
+ }
+ return EVAS_EVENT_FLAG_NONE;
+}
+
+static Evas_Event_Flags
+_pinch_rotate_end_cb(void *data, void *event_info __UNUSED__)
+{
+ Widget_Data *wd = data;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EVAS_EVENT_FLAG_NONE);
+
+ wd->rotate.a = wd->rotate.d;
+
+ return EVAS_EVENT_FLAG_NONE;
+}
+
+static Eina_Bool
+_source_tile_mod_cb(Eina_Module *m, void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+
+ Widget_Data *wd = data;
+ Source_Tile *s;
+ Elm_Map_Module_Source_Name_Func name_cb;
+ Elm_Map_Module_Tile_Zoom_Min_Func zoom_min;
+ Elm_Map_Module_Tile_Zoom_Max_Func zoom_max;
+ Elm_Map_Module_Tile_Url_Func url_cb;
+ Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord;
+ Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo;
+ Elm_Map_Module_Tile_Scale_Func scale_cb;
+ const char *file;
+
+ file = eina_module_file_get(m);
+ if (!eina_module_load(m))
+ {
+ ERR("Could not load module \"%s\": %s", file,
+ eina_error_msg_get(eina_error_get()));
+ return EINA_FALSE;
+ }
+
+ name_cb = eina_module_symbol_get(m, "map_module_source_name_get");
+ zoom_min = eina_module_symbol_get(m, "map_module_tile_zoom_min_get");
+ zoom_max = eina_module_symbol_get(m, "map_module_tile_zoom_max_get");
+ url_cb = eina_module_symbol_get(m, "map_module_tile_url_get");
+ geo_to_coord = eina_module_symbol_get(m, "map_module_tile_geo_to_coord");
+ coord_to_geo = eina_module_symbol_get(m, "map_module_tile_coord_to_geo");
+ scale_cb = eina_module_symbol_get(m, "map_module_tile_scale_get");
+ if ((!name_cb) || (!zoom_min) || (!zoom_max) || (!url_cb) ||
+ (!geo_to_coord) || (!coord_to_geo) || (!scale_cb))
+ {
+ WRN("Could not find map module functions from module \"%s\": %s",
+ file, eina_error_msg_get(eina_error_get()));
+ eina_module_unload(m);
+ return EINA_FALSE;
+ }
+ s = ELM_NEW(Source_Tile);
+ s->name = name_cb();
+ s->zoom_min = zoom_min();
+ s->zoom_max = zoom_max();
+ s->url_cb = url_cb;
+ s->geo_to_coord = geo_to_coord;
+ s->coord_to_geo = coord_to_geo;
+ s->scale_cb = scale_cb;
+ wd->src_tiles = eina_list_append(wd->src_tiles, s);
+
+ return EINA_TRUE;
+}
+
+static void
+_source_tile_load(Widget_Data *wd)
+{
+ unsigned int idx;
+ Eina_List *l;
+ Source_Tile *s;
+
+ // Load from hard coded data
+ for (idx = 0; idx < (sizeof(src_tiles) / sizeof(Source_Tile)); idx++)
+ {
+ s= ELM_NEW(Source_Tile);
+ s->name = src_tiles[idx].name;
+ s->zoom_min = src_tiles[idx].zoom_min;
+ s->zoom_max = src_tiles[idx].zoom_max;
+ s->url_cb = src_tiles[idx].url_cb;
+ s->geo_to_coord = src_tiles[idx].geo_to_coord;
+ s->coord_to_geo = src_tiles[idx].coord_to_geo;
+ s->scale_cb = src_tiles[idx].scale_cb;
+ wd->src_tiles = eina_list_append(wd->src_tiles, s);
+ }
+
+ // Load from modules
+ wd->src_tile_mods = eina_module_list_get(wd->src_tile_mods, MODULES_PATH, 1,
+ &_source_tile_mod_cb, wd);
+
+ // Set default source
+ wd->src_tile = eina_list_nth(wd->src_tiles, 0);
+
+ // Make name strings
+ idx = 0;
+ wd->src_tile_names = calloc((eina_list_count(wd->src_tiles) + 1),
+ sizeof(char *));
+ EINA_LIST_FOREACH(wd->src_tiles, l, s)
+ {
+ eina_stringshare_replace(&wd->src_tile_names[idx], s->name);
+ INF("source : %s", wd->src_tile_names[idx]);
+ idx++;
+ }
+}
+
+static void
+_source_tile_unload(Widget_Data *wd)
+{
+ int idx = 0;
+ Source_Tile *s;
+
+ for (idx = 0; wd->src_tile_names[idx]; idx++)
+ eina_stringshare_del(wd->src_tile_names[idx]);
+ EINA_LIST_FREE(wd->src_tiles, s) free(s);
+ eina_module_list_free(wd->src_tile_mods);
+}
+
+static void
+_source_tile_set(Widget_Data *wd, const char *source_name)
+{
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ EINA_SAFETY_ON_NULL_RETURN(source_name);
+ Source_Tile *s;
+ Eina_List *l;
+
+ if (wd->src_tile && !strcmp(wd->src_tile->name, source_name)) return;
+
+ EINA_LIST_FOREACH(wd->src_tiles, l, s)
+ {
+ if (!strcmp(s->name, source_name))
+ {
+ wd->src_tile = s;
+ break;
+ }
+ }
+ if (!wd->src_tile)
+ {
+ ERR("source name (%s) is not found", source_name);
+ return;
+ }
+
+ if (wd->src_tile->zoom_max < wd->zoom)
+ wd->zoom = wd->src_tile->zoom_max;
+ else if (wd->src_tile->zoom_min > wd->zoom)
+ wd->zoom = wd->src_tile->zoom_min;
+
+ if (wd->src_tile->zoom_max < wd->zoom_max)
+ wd->zoom_max = wd->src_tile->zoom_max;
+ if (wd->src_tile->zoom_min > wd->zoom_min)
+ wd->zoom_min = wd->src_tile->zoom_min;
+
+ _grid_all_clear(wd);
+ _grid_all_create(wd);
+ zoom_do(wd, wd->zoom);
+}
+
+static Eina_Bool
+_source_route_mod_cb(Eina_Module *m, void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+
+ Widget_Data *wd = data;
+ Source_Route *s;
+ Elm_Map_Module_Source_Name_Func name_cb;
+ Elm_Map_Module_Route_Url_Func url_cb;
+ const char *file;
+
+ file = eina_module_file_get(m);
+ if (!eina_module_load(m))
+ {
+ ERR("Could not load module \"%s\": %s", file,
+ eina_error_msg_get(eina_error_get()));
+ return EINA_FALSE;
+ }
+
+ name_cb = eina_module_symbol_get(m, "map_module_source_name_get");
+ url_cb = eina_module_symbol_get(m, "map_module_route_url_get");
+
+ if ((!name_cb) || (!url_cb))
+ {
+ WRN("Could not find map module functions from module \"%s\": %s",
+ file, eina_error_msg_get(eina_error_get()));
+ eina_module_unload(m);
+ return EINA_FALSE;
+ }
+ s = ELM_NEW(Source_Tile);
+ s->name = name_cb();
+ s->url_cb = url_cb;
+ wd->src_routes = eina_list_append(wd->src_routes, s);
+
+ eina_module_unload(m);
+ return EINA_TRUE;
+}
+
+static void
+_source_route_load(Widget_Data *wd)
+{
+ unsigned int idx;
+ Eina_List *l;
+ Source_Route *s;
+
+ // Load from hard coded data
+ for (idx = 0; idx < (sizeof(src_routes) / sizeof(Source_Route)); idx++)
+ {
+ s= ELM_NEW(Source_Route);
+ s->name = src_routes[idx].name;
+ s->url_cb = src_routes[idx].url_cb;
+ wd->src_routes = eina_list_append(wd->src_routes, s);
+ }
+
+ // Load from modules
+ wd->src_route_mods = eina_module_list_get(wd->src_route_mods, MODULES_PATH,
+ 1, &_source_route_mod_cb, wd);
+
+ // Set default source
+ wd->src_route = eina_list_nth(wd->src_routes, 0);
+
+ // Make name strings
+ idx = 0;
+ wd->src_route_names = calloc((eina_list_count(wd->src_routes) + 1),
+ sizeof(char *));
+ EINA_LIST_FOREACH(wd->src_routes, l, s)
+ {
+ eina_stringshare_replace(&wd->src_route_names[idx], s->name);
+ INF("source : %s", wd->src_route_names[idx]);
+ idx++;
+ }
+}
+
+static void
+_source_route_unload(Widget_Data *wd)
+{
+ int idx = 0;
+ Source_Route *s;
+
+ for (idx = 0; wd->src_route_names[idx]; idx++)
+ eina_stringshare_del(wd->src_route_names[idx]);
+ EINA_LIST_FREE(wd->src_routes, s) free(s);
+ eina_module_list_free(wd->src_route_mods);
+}
+
+static void
+_source_route_set(Widget_Data *wd, const char *source_name)
+{
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ EINA_SAFETY_ON_NULL_RETURN(source_name);
+ Source_Route *s;
+ Eina_List *l;
+
+ if (wd->src_route && !strcmp(wd->src_route->name, source_name)) return;
+
+ EINA_LIST_FOREACH(wd->src_routes, l, s)
+ {
+ if (!strcmp(s->name, source_name))
+ {
+ wd->src_route = s;
+ break;
+ }
+ }
+ if (!wd->src_route)
+ {
+ ERR("source name (%s) is not found", source_name);
+ return;
+ }
+}
+
+static Eina_Bool
+_source_name_mod_cb(Eina_Module *m, void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
+
+ Widget_Data *wd = data;
+ Source_Name *s;
+ Elm_Map_Module_Source_Name_Func name_cb;
+ Elm_Map_Module_Name_Url_Func url_cb;
+ const char *file;
+
+ file = eina_module_file_get(m);
+ if (!eina_module_load(m))
+ {
+ ERR("Could not load module \"%s\": %s", file,
+ eina_error_msg_get(eina_error_get()));
+ return EINA_FALSE;
+ }
+
+ name_cb = eina_module_symbol_get(m, "map_module_source_name_get");
+ url_cb = eina_module_symbol_get(m, "map_module_name_url_get");
+
+ if ((!name_cb) || (!url_cb))
+ {
+ WRN("Could not find map module functions from module \"%s\": %s",
+ file, eina_error_msg_get(eina_error_get()));
+ eina_module_unload(m);
+ return EINA_FALSE;
+ }
+ s = ELM_NEW(Source_Tile);
+ s->name = name_cb();
+ s->url_cb = url_cb;
+ wd->src_names = eina_list_append(wd->src_names, s);
+
+ eina_module_unload(m);
+ return EINA_TRUE;
+}
+
+static void
+_source_name_load(Widget_Data *wd)
+{
+ unsigned int idx;
+ Eina_List *l;
+ Source_Name *s;
+
+ // Load from hard coded data
+ for (idx = 0; idx < (sizeof(src_names) / sizeof(Source_Name)); idx++)
+ {
+ s= ELM_NEW(Source_Name);
+ s->name = src_names[idx].name;
+ s->url_cb = src_names[idx].url_cb;
+ wd->src_names = eina_list_append(wd->src_names, s);
+ }
+
+ // Load from modules
+ wd->src_name_mods = eina_module_list_get(wd->src_name_mods, MODULES_PATH, 1,
+ &_source_name_mod_cb, wd);
+
+ // Set default source
+ wd->src_name = eina_list_nth(wd->src_names, 0);
+
+ // Make name strings
+ idx = 0;
+ wd->src_name_names = calloc((eina_list_count(wd->src_names) + 1),
+ sizeof(char *));
+ EINA_LIST_FOREACH(wd->src_names, l, s)
+ {
+ eina_stringshare_replace(&wd->src_name_names[idx], s->name);
+ INF("source : %s", wd->src_name_names[idx]);
+ idx++;
+ }
+}
+
+static void
+_source_name_unload(Widget_Data *wd)
+{
+ int idx = 0;
+ Source_Name *s;
+
+ for (idx = 0; wd->src_name_names[idx]; idx++)
+ eina_stringshare_del(wd->src_name_names[idx]);
+ EINA_LIST_FREE(wd->src_names, s) free(s);
+ eina_module_list_free(wd->src_name_mods);
+}
+
+static void
+_source_name_set(Widget_Data *wd, const char *source_name)
+{
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ EINA_SAFETY_ON_NULL_RETURN(source_name);
+
+ Source_Name *s;
+ Eina_List *l;
+
+ if (wd->src_name && !strcmp(wd->src_name->name, source_name)) return;
+
+ EINA_LIST_FOREACH(wd->src_names, l, s)
+ {
+ if (!strcmp(s->name, source_name))
+ {
+ wd->src_name = s;
+ break;
+ }
+ }
+ if (!wd->src_name)
+ {
+ ERR("source name (%s) is not found", source_name);
+ return;
+ }
+}
+
+static void
+_source_all_load(Widget_Data *wd)
+{
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ _source_tile_load(wd);
+ _source_route_load(wd);
+ _source_name_load(wd);
+}
+
+static void
+_source_all_unload(Widget_Data *wd)
+{
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ _source_tile_unload(wd);
+ _source_route_unload(wd);
+ _source_name_unload(wd);
+}
+
+static void
+_zoom_mode_set(void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Delayed_Data *dd = data;
+
+ dd->wd->mode = dd->mode;
+ if (dd->mode != ELM_MAP_ZOOM_MODE_MANUAL)
+ {
+ Evas_Coord w, h;
+ Evas_Coord vw, vh;
+
+ double zoom;
+ double diff;
+
+ w = dd->wd->size.w;
+ h = dd->wd->size.h;
+ zoom = dd->wd->zoom_detail;
+ _viewport_coord_get(dd->wd, NULL, NULL, &vw, &vh);
+
+ if (dd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
+ {
+ if ((w < vw) && (h < vh))
{
- Route_Waypoint *wp = ELM_NEW(Route_Waypoint);
- if (wp)
- {
- wp->wd = r->wd;
- wp->point = eina_stringshare_add(str[idx]);
- DBG("%s", str[idx]);
- r->waypoint = eina_list_append(r->waypoint, wp);
- }
+ diff = 0.01;
+ while ((w < vw) && (h < vh))
+ {
+ zoom += diff;
+ w = pow(2.0, zoom) * dd->wd->tsize;
+ h = pow(2.0, zoom) * dd->wd->tsize;
+ }
}
- if (str && str[0])
+ else
{
- free(str[0]);
- free(str);
+ diff = -0.01;
+ while ((w > vw) || (h > vh))
+ {
+ zoom += diff;
+ w = pow(2.0, zoom) * dd->wd->tsize;
+ h = pow(2.0, zoom) * dd->wd->tsize;
+ }
}
- }
- else WRN("description is not found !");
- if (dump.coordinates)
+ }
+ else if (dd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
{
- eina_stringshare_replace(&r->info.nodes, dump.coordinates);
- str = eina_str_split_full(dump.coordinates, "\n", 0, &ele);
- r->info.node_count = ele;
- for (idx = 0 ; idx < ele ; idx++)
+ if ((w < vw) || (h < vh))
{
- sscanf(str[idx], "%lf,%lf", &lon, &lat);
- Route_Node *n = ELM_NEW(Route_Node);
- if (n)
- {
- n->wd = r->wd;
- n->pos.lon = lon;
- n->pos.lat = lat;
- n->idx = idx;
- DBG("%lf:%lf", lon, lat);
- n->pos.address = NULL;
- r->nodes = eina_list_append(r->nodes, n);
-
- path = evas_object_line_add(evas_object_evas_get(r->wd->obj));
- evas_object_smart_member_add(path, r->wd->pan_smart);
- r->path = eina_list_append(r->path, path);
- }
+ diff = 0.01;
+ while ((w < vw) || (h < vh))
+ {
+ zoom += diff;
+ w = pow(2.0, zoom) * dd->wd->tsize;
+ h = pow(2.0, zoom) * dd->wd->tsize;
+ }
}
- if (str && str[0])
+ else
{
- free(str[0]);
- free(str);
+ diff = -0.01;
+ while ((w > vw) && (h > vh))
+ {
+ zoom += diff;
+ w = pow(2.0, zoom) * dd->wd->tsize;
+ h = pow(2.0, zoom) * dd->wd->tsize;
+ }
}
}
+ zoom_with_animation(dd->wd, zoom, 10);
}
}
static void
-_parse_name(void *data)
+_zoom_set(void *data)
{
- Elm_Map_Name *n = (Elm_Map_Name*)data;
- if (!n && !n->ud.fname) return;
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Delayed_Data *dd = data;
- FILE *f;
+ if (dd->wd->paused) zoom_do(dd->wd, dd->zoom);
+ else zoom_with_animation(dd->wd, dd->zoom, 10);
+ evas_object_smart_changed(dd->wd->pan_smart);
+}
- Name_Dump dump = {0, NULL, 0.0, 0.0};
+static void
+_region_bring_in(void *data)
+{
+ EINA_SAFETY_ON_NULL_RETURN(data);
+ Delayed_Data *dd = data;
+ int x, y, w, h;
- f = fopen(n->ud.fname, "rb");
- if (f)
- {
- long sz;
+ _region_to_coord_convert(dd->wd, dd->lon, dd->lat, dd->wd->size.w, &x, &y);
+ _viewport_coord_get(dd->wd, NULL, NULL, &w, &h);
+ x = x - (w / 2);
+ y = y - (h / 2);
+ elm_smart_scroller_region_bring_in(dd->wd->scr, x, y, w, h);
+ evas_object_smart_changed(dd->wd->pan_smart);
+}
- fseek(f, 0, SEEK_END);
- sz = ftell(f);
- if (sz > 0)
- {
- char *buf;
+static char *
+_mapnik_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+{
+ char buf[PATH_MAX];
+ // ((x+y+zoom)%3)+'a' is requesting map images from distributed tile servers (eg., a, b, c)
+ snprintf(buf, sizeof(buf), "http://%c.tile.openstreetmap.org/%d/%d/%d.png",
+ ((x + y + zoom) % 3) + 'a', zoom, x, y);
+ return strdup(buf);
+}
- fseek(f, 0, SEEK_SET);
- buf = malloc(sz);
- if (buf)
- {
- if (fread(buf, 1, sz, f))
- {
- eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_name_dump, &dump);
- free(buf);
- }
- }
+static char *
+_osmarender_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+{
+ char buf[PATH_MAX];
+ snprintf(buf, sizeof(buf),
+ "http://%c.tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
+ ((x + y + zoom) % 3) + 'a', zoom, x, y);
+ return strdup(buf);
+}
+
+static char *
+_cyclemap_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+{
+ char buf[PATH_MAX];
+ snprintf(buf, sizeof(buf),
+ "http://%c.tile.opencyclemap.org/cycle/%d/%d/%d.png",
+ (( x + y + zoom) % 3) + 'a', zoom, x, y);
+ return strdup(buf);
+}
+
+static char *
+_mapquest_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+{
+ char buf[PATH_MAX];
+ snprintf(buf, sizeof(buf),
+ "http://otile%d.mqcdn.com/tiles/1.0.0/osm/%d/%d/%d.png",
+ ((x + y + zoom) % 4) + 1, zoom, x, y);
+ return strdup(buf);
+}
+
+static char *
+_mapquest_aerial_url_cb(const Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+{
+ char buf[PATH_MAX];
+ snprintf(buf, sizeof(buf), "http://oatile%d.mqcdn.com/naip/%d/%d/%d.png",
+ ((x + y + zoom) % 4) + 1, zoom, x, y);
+ return strdup(buf);
+}
+
+static char *_yours_url_cb(const Evas_Object *obj __UNUSED__, const char *type_name, int method, double flon, double flat, double tlon, double tlat)
+{
+ char buf[PATH_MAX];
+ snprintf(buf, sizeof(buf),
+ "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
+ ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
+
+ return strdup(buf);
+}
+
+// TODO: fix monav api
+/*
+static char *_monav_url_cb(const Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
+{
+ char buf[PATH_MAX];
+ snprintf(buf, sizeof(buf),
+ "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
+ ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
+
+ return strdup(buf);
+}
+*/
+
+// TODO: fix ors api
+/*
+static char *_ors_url_cb(const Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
+{
+ char buf[PATH_MAX];
+ snprintf(buf, sizeof(buf),
+ "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
+ ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
+
+ return strdup(buf);
+}
+*/
+
+static char *
+_nominatim_url_cb(const Evas_Object *obj, int method, const char *name, double lon, double lat)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) strdup("");
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, strdup(""));
+
+ char **str;
+ unsigned int ele, idx;
+ char search_url[PATH_MAX];
+ char buf[PATH_MAX];
+
+ if (method == ELM_MAP_NAME_METHOD_SEARCH)
+ {
+ search_url[0] = '\0';
+ str = eina_str_split_full(name, " ", 0, &ele);
+ for (idx = 0; idx < ele; idx++)
+ {
+ eina_strlcat(search_url, str[idx], sizeof(search_url));
+ if (!(idx == (ele-1)))
+ eina_strlcat(search_url, "+", sizeof(search_url));
}
- fclose(f);
+ snprintf(buf, sizeof(buf),
+ "%s/search?q=%s&format=xml&polygon=0&addressdetails=0",
+ NAME_NOMINATIM_URL, search_url);
- if (dump.address)
+ if (str && str[0])
{
- INF("[%lf : %lf] ADDRESS : %s", n->lon, n->lat, dump.address);
- n->address = strdup(dump.address);
+ free(str[0]);
+ free(str);
}
- n->lon = dump.lon;
- n->lat = dump.lat;
}
+ else if (method == ELM_MAP_NAME_METHOD_REVERSE)
+ snprintf(buf, sizeof(buf),
+ "%s/reverse?format=xml&lat=%lf&lon=%lf&zoom=%d&addressdetails=0",
+ NAME_NOMINATIM_URL, lat, lon, (int)wd->zoom);
+ else strcpy(buf, "");
+
+ return strdup(buf);
+}
+
+static double
+_scale_cb(const Evas_Object *obj __UNUSED__, double lon __UNUSED__, double lat, int zoom)
+{
+ if (zoom < 0 || zoom >= (int)sizeof(_osm_scale_meter)) return 0;
+ return _osm_scale_meter[zoom] / cos(lat * ELM_PI / 180.0);
+}
+
+static void
+_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ if (elm_widget_focus_get(obj))
+ {
+ edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
+ evas_object_focus_set(wd->obj, EINA_TRUE);
+ }
+ else
+ {
+ edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
+ evas_object_focus_set(wd->obj, EINA_FALSE);
+ }
+}
+
+static void
+_del_hook(Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ if (wd->map) evas_map_free(wd->map);
+ free(wd);
+}
+
+static void
+_del_pre_hook(Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ Eina_List *l, *ll;
+ Elm_Map_Route *r;
+ Elm_Map_Name *na;
+ Evas_Object *track;
+ Elm_Map_Marker *marker;
+ Elm_Map_Group_Class *group_clas;
+ Elm_Map_Marker_Class *clas;
+ Elm_Map_Overlay *overlay;
+ Delayed_Data *dd;
+
+ EINA_LIST_FOREACH_SAFE(wd->routes, l, ll, r) elm_map_route_del(r);
+ eina_list_free(wd->routes);
+
+ EINA_LIST_FOREACH_SAFE(wd->names, l, ll, na) elm_map_name_del(na);
+ eina_list_free(wd->names);
+
+ EINA_LIST_FOREACH_SAFE(wd->overlays, l, ll, overlay)
+ elm_map_overlay_del(overlay);
+ eina_list_free(wd->overlays);
+
+ EINA_LIST_FREE(wd->track, track) evas_object_del(track);
+
+ EINA_LIST_FOREACH_SAFE(wd->markers, l, ll, marker)
+ _elm_map_marker_remove(marker);
+ eina_list_free(wd->markers);
+
+ EINA_LIST_FREE(wd->group_classes, group_clas)
+ {
+ eina_list_free(group_clas->markers);
+ if (group_clas->style) eina_stringshare_del(group_clas->style);
+ free(group_clas);
+ }
+ EINA_LIST_FREE(wd->marker_classes, clas)
+ {
+ if (clas->style) eina_stringshare_del(clas->style);
+ free(clas);
+ }
+
+ if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
+ if (wd->long_timer) ecore_timer_del(wd->long_timer);
+
+ if (wd->delayed_jobs) EINA_LIST_FREE(wd->delayed_jobs, dd) free(dd);
+
+ if (wd->user_agent) eina_stringshare_del(wd->user_agent);
+ if (wd->ua) eina_hash_free(wd->ua);
+
+ if (wd->zoom_timer) ecore_timer_del(wd->zoom_timer);
+ if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
+
+ _grid_all_clear(wd);
+ // Removal of download list should be after grid clear.
+ if (wd->download_idler) ecore_idler_del(wd->download_idler);
+ eina_list_free(wd->download_list);
+
+ _source_all_unload(wd);
+
+ if (!ecore_file_recursive_rm(CACHE_ROOT))
+ ERR("Deletion of %s failed", CACHE_ROOT);
+}
+
+static void
+_theme_hook(Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", elm_widget_style_get(obj));
+ _sizing_eval(wd);
}
static Eina_Bool
-_route_complete_cb(void *data, int ev_type __UNUSED__, void *event)
+_event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
{
- Ecore_Con_Event_Url_Complete *ev = event;
- Elm_Map_Route *r = (Elm_Map_Route*)data;
- Widget_Data *wd = r->wd;
+ ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
+
+ Evas_Coord x, y;
+ Evas_Coord vh;
+ Evas_Coord step_x, step_y, page_x, page_y;
- if ((!r) || (!ev)) return EINA_TRUE;
- Elm_Map_Route *rr = ecore_con_url_data_get(r->con_url);
- ecore_con_url_data_set(r->con_url, NULL);
- if (r!=rr) return EINA_TRUE;
+ if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
+ Evas_Event_Key_Down *ev = event_info;
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
- if (r->ud.fd) fclose(r->ud.fd);
- _parse_kml(r);
+ elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
+ elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
+ elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
+ elm_smart_scroller_child_viewport_size_get(wd->scr, NULL, &vh);
- if (wd->grids)
+ if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
+ {
+ x -= step_x;
+ }
+ else if ((!strcmp(ev->keyname, "Right")) || (!strcmp(ev->keyname, "KP_Right")))
+ {
+ x += step_x;
+ }
+ else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
+ {
+ y -= step_y;
+ }
+ else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
+ {
+ y += step_y;
+ }
+ else if ((!strcmp(ev->keyname, "Prior")) || (!strcmp(ev->keyname, "KP_Prior")))
+ {
+ if (page_y < 0)
+ y -= -(page_y * vh) / 100;
+ else
+ y -= page_y;
+ }
+ else if ((!strcmp(ev->keyname, "Next")) || (!strcmp(ev->keyname, "KP_Next")))
{
- Evas_Coord ox, oy, ow, oh;
- evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
- route_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
+ if (page_y < 0)
+ y += -(page_y * vh) / 100;
+ else
+ y += page_y;
}
- edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
- "elm,state,busy,stop", "elm");
- evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOADED, NULL);
- return EINA_TRUE;
-}
-
-static Eina_Bool
-_name_complete_cb(void *data, int ev_type __UNUSED__, void *event)
-{
- Ecore_Con_Event_Url_Complete *ev = event;
- Elm_Map_Name *n = (Elm_Map_Name*)data;
- Widget_Data *wd = n->wd;
-
- if ((!n) || (!ev)) return EINA_TRUE;
- Elm_Map_Name *nn = ecore_con_url_data_get(n->con_url);
- ecore_con_url_data_set(n->con_url, NULL);
- if (n!=nn) return EINA_TRUE;
-
- if (n->ud.fd) fclose(n->ud.fd);
- _parse_name(n);
-
- edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
- "elm,state,busy,stop", "elm");
- evas_object_smart_callback_call(wd->obj, SIG_NAME_LOADED, NULL);
- return EINA_TRUE;
-}
-
-static Elm_Map_Name *
-_utils_convert_name(const Evas_Object *obj, int method, char *address, double lon, double lat)
-{
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
-
- char buf[PATH_MAX];
- char *source;
- int fd;
- Elm_Map_Name *name = ELM_NEW(Elm_Map_Name);
- if (!name) return NULL;
-
- snprintf(buf, sizeof(buf), DEST_NAME_XML_FILE);
- fd = mkstemp(buf);
- if (fd < 0)
+ else if (!strcmp(ev->keyname, "KP_Add"))
{
- free(name);
- return NULL;
+ zoom_with_animation(wd, wd->zoom + 1, 10);
+ return EINA_TRUE;
}
-
- name->con_url = ecore_con_url_new(NULL);
- name->ud.fname = strdup(buf);
- INF("xml file : %s", name->ud.fname);
-
- name->ud.fd = fdopen(fd, "w+");
- if ((!name->con_url) || (!name->ud.fd))
+ else if (!strcmp(ev->keyname, "KP_Subtract"))
{
- ecore_con_url_free(name->con_url);
- free(name);
- return NULL;
+ zoom_with_animation(wd, wd->zoom - 1, 10);
+ return EINA_TRUE;
}
+ else return EINA_FALSE;
- name->wd = wd;
- name->handler = ecore_event_handler_add (ECORE_CON_EVENT_URL_COMPLETE, _name_complete_cb, name);
- name->method = method;
- if (method == ELM_MAP_NAME_METHOD_SEARCH) name->address = strdup(address);
- else if (method == ELM_MAP_NAME_METHOD_REVERSE) name->address = NULL;
- name->lon = lon;
- name->lat = lat;
-
- source = map_sources_tab[wd->source].name_url_cb(wd->obj, method, address, lon, lat);
- INF("name url = %s", source);
-
- wd->names = eina_list_append(wd->names, name);
- ecore_con_url_url_set(name->con_url, source);
- ecore_con_url_fd_set(name->con_url, fileno(name->ud.fd));
- ecore_con_url_data_set(name->con_url, name);
-
- edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
- "elm,state,busy,start", "elm");
- evas_object_smart_callback_call(wd->obj, SIG_NAME_LOAD, NULL);
- ecore_con_url_get(name->con_url);
- if (source) free(source);
-
- return name;
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ elm_smart_scroller_child_pos_set(wd->scr, x, y);
+ return EINA_TRUE;
}
+#endif
-static int idnum = 1;
-
-/**
- * Add a new Map object
- *
- * @param parent The parent object
- * @return The new object or NULL if it cannot be created
- *
- * @ingroup Map
- */
EAPI Evas_Object *
elm_map_add(Evas_Object *parent)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
Evas *e;
Widget_Data *wd;
- Evas_Coord minw, minh;
Evas_Object *obj;
- static Evas_Smart *smart = NULL;
- Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
+ Evas_Coord minw, minh;
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
-
ELM_SET_WIDTYPE(widtype, "map");
elm_widget_type_set(obj, "map");
elm_widget_sub_object_add(parent, obj);
- elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_data_set(obj, wd);
+ elm_widget_can_focus_set(obj, EINA_TRUE);
+ elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
- elm_widget_can_focus_set(obj, EINA_TRUE);
elm_widget_event_hook_set(obj, _event_hook);
+ evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, wd);
+ evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, wd);
+ evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, wd);
+ evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, wd);
+ evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
+ _mouse_down, wd);
+ evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
+ _mouse_up, wd);
+ evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL,
+ _mouse_wheel_cb,wd);
+ wd->obj = obj;
wd->scr = elm_smart_scroller_add(e);
+ elm_widget_sub_object_add(obj, wd->scr);
elm_smart_scroller_widget_set(wd->scr, obj);
elm_smart_scroller_object_theme_set(obj, wd->scr, "map", "base", "default");
- evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
- evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
elm_widget_resize_object_set(obj, wd->scr);
-
- evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
- evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
- evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
- evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
- evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
-
- elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
-
- wd->api = module(obj);
- if ((wd->api) && (wd->api->obj_hook)) wd->api->obj_hook(obj);
-
- wd->obj = obj;
-
- wd->markers_max_num = 30;
- wd->source = ELM_MAP_SOURCE_MAPNIK;
- wd->pinch.level = 1.0;
-
- evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
- evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
- evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
- evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
+ elm_smart_scroller_wheel_disabled_set(wd->scr, EINA_TRUE);
+ elm_smart_scroller_bounce_allow_set(wd->scr,
+ _elm_config->thumbscroll_bounce_enable,
+ _elm_config->thumbscroll_bounce_enable);
+ evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+ _changed_size_hints, wd);
+ evas_object_smart_callback_add(wd->scr, "scroll", _scr, wd);
+ evas_object_smart_callback_add(wd->scr, "drag", _scr, wd);
+ evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, wd);
+ evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, wd);
if (!smart)
{
- static Evas_Smart_Class sc;
-
- evas_object_smart_clipped_smart_set(&_pan_sc);
- sc = _pan_sc;
+ evas_object_smart_clipped_smart_set(&parent_sc);
+ sc = parent_sc;
sc.name = "elm_map_pan";
sc.version = EVAS_SMART_CLASS_VERSION;
sc.add = _pan_add;
- sc.del = _pan_del;
sc.resize = _pan_resize;
sc.move = _pan_move;
sc.calculate = _pan_calculate;
}
if (smart)
{
+ Pan *pan;
wd->pan_smart = evas_object_smart_add(e, smart);
- wd->pan = evas_object_smart_data_get(wd->pan_smart);
- wd->pan->wd = wd;
+ pan = evas_object_smart_data_get(wd->pan_smart);
+ pan->wd = wd;
}
+ elm_widget_sub_object_add(obj, wd->pan_smart);
elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
_pan_set, _pan_get, _pan_max_get,
_pan_min_get, _pan_child_size_get);
-
- wd->rect = evas_object_rectangle_add(e);
- evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_RESIZE,
- _rect_resize_cb, obj);
- evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_DOWN,
- _mouse_down, obj);
- evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_MOVE,
- _mouse_move, obj);
- evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MOUSE_UP,
- _mouse_up, obj);
- evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_DOWN,
- _mouse_multi_down, obj);
- evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_MOVE,
- _mouse_multi_move, obj);
- evas_object_event_callback_add(wd->rect, EVAS_CALLBACK_MULTI_UP,
- _mouse_multi_up, obj);
-
- evas_object_smart_member_add(wd->rect, wd->pan_smart);
- elm_widget_sub_object_add(obj, wd->rect);
- evas_object_show(wd->rect);
- evas_object_color_set(wd->rect, 0, 0, 0, 0);
-
- wd->zoom = -1;
- wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
- wd->id = ((int)getpid() << 16) | idnum;
- idnum++;
-
- wd->tsize = 256;
-
edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
&minw, &minh);
evas_object_size_hint_min_set(obj, minw, minh);
- wd->paused = EINA_TRUE;
- elm_map_zoom_set(obj, 0);
- wd->paused = EINA_FALSE;
-
- _sizing_eval(obj);
-
- wd->calc_job = ecore_job_add(_calc_job, wd);
+ wd->ges = elm_gesture_layer_add(obj);
+ if (!wd->ges) ERR("elm_gesture_layer_add() failed");
+ elm_gesture_layer_attach(wd->ges, obj);
+ elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_START,
+ _pinch_zoom_start_cb, wd);
+ elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_MOVE,
+ _pinch_zoom_cb, wd);
+ elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_MOVE,
+ _pinch_rotate_cb, wd);
+ elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_END,
+ _pinch_rotate_end_cb, wd);
+ elm_gesture_layer_cb_set(wd->ges, ELM_GESTURE_ROTATE, ELM_GESTURE_STATE_ABORT,
+ _pinch_rotate_end_cb, wd);
wd->sep_maps_markers = evas_object_rectangle_add(evas_object_evas_get(obj));
+ elm_widget_sub_object_add(obj, wd->sep_maps_markers);
evas_object_smart_member_add(wd->sep_maps_markers, wd->pan_smart);
+ wd->map = evas_map_new(EVAS_MAP_POINT);
+
+ _source_all_load(wd);
+ wd->zoom_min = wd->src_tile->zoom_min;
+ wd->zoom_max = wd->src_tile->zoom_max;
+ // FIXME: Tile Provider is better to provide tile size!
+ wd->tsize = DEFAULT_TILE_SIZE;
+
+ srand(time(NULL));
+
+ wd->id = ((int)getpid() << 16) | idnum;
+ idnum++;
+ _grid_all_create(wd);
+
+ zoom_do(wd, 0);
+
+ wd->mode = ELM_MAP_ZOOM_MODE_MANUAL;
+ wd->markers_max_num = MARER_MAX_NUMBER;
+
// TODO: convert Elementary to subclassing of Evas_Smart_Class
// TODO: and save some bytes, making descriptions per-class and not instance!
evas_object_smart_callbacks_descriptions_set(obj, _signals);
if (!ecore_file_download_protocol_available("http://"))
- {
- ERR("Ecore must be built with curl support for the map widget!");
- }
+ ERR("Ecore must be built with curl support for the map widget!");
+
return obj;
+#else
+ (void) parent;
+ return NULL;
+#endif
}
-/**
- * Set the zoom level of the map
- *
- * This sets the zoom level. 0 is the world map and 18 is the maximum zoom.
- *
- * @param obj The map object
- * @param zoom The zoom level to set
- *
- * @ingroup Map
- */
EAPI void
elm_map_zoom_set(Evas_Object *obj, int zoom)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- Eina_List *l, *lr;
- Grid *g, *g_zoom = NULL;
- Evas_Coord rx, ry, rw, rh;
- Evas_Object *p;
- Elm_Map_Route *r;
- int z;
- int zoom_changed = 0, started = 0;
-
- if ((!wd) || (wd->zoom_animator)) return;
- if (zoom < 0 ) zoom = 0;
- if (zoom > map_sources_tab[wd->source].zoom_max)
- zoom = map_sources_tab[wd->source].zoom_max;
- if (zoom < map_sources_tab[wd->source].zoom_min)
- zoom = map_sources_tab[wd->source].zoom_min;
-
- if ((wd->zoom - zoom) > 0) wd->zoom_method = ZOOM_METHOD_OUT;
- else if ((wd->zoom - zoom) < 0) wd->zoom_method = ZOOM_METHOD_IN;
- else wd->zoom_method = ZOOM_METHOD_NONE;
- wd->zoom = zoom;
- wd->size.ow = wd->size.w;
- wd->size.oh = wd->size.h;
- elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
- elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
-
- EINA_LIST_FOREACH(wd->route, lr, r)
- {
- if (r)
- {
- EINA_LIST_FOREACH(r->path, l, p)
- {
- evas_object_hide(p);
- }
- }
- }
-
- if (wd->mode == ELM_MAP_ZOOM_MODE_MANUAL)
- {
- wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
- wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
- }
- else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FIT)
- {
- int p2w, p2h;
- int cumulw, cumulh;
-
- cumulw = wd->tsize;
- p2w = 0;
- while (cumulw <= rw)
- {
- p2w++;
- cumulw *= 2;
- }
- p2w--;
-
- cumulh = wd->tsize;
- p2h = 0;
- while (cumulh <= rh)
- {
- p2h++;
- cumulh *= 2;
- }
- p2h--;
-
- if (p2w < p2h)
- z = p2w;
- else
- z = p2h;
-
- wd->zoom = z;
- wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
- wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
- }
- else if (wd->mode == ELM_MAP_ZOOM_MODE_AUTO_FILL)
- {
- int p2w, p2h;
- int cumulw, cumulh;
-
- cumulw = wd->tsize;
- p2w = 0;
- while (cumulw <= rw)
- {
- p2w++;
- cumulw *= 2;
- }
- p2w--;
-
- cumulh = wd->tsize;
- p2h = 0;
- while (cumulh <= rh)
- {
- p2h++;
- cumulh *= 2;
- }
- p2h--;
-
- if (p2w > p2h)
- z = p2w;
- else
- z = p2h;
-
- wd->zoom = z;
- wd->size.nw = pow(2.0, wd->zoom) * wd->tsize;
- wd->size.nh = pow(2.0, wd->zoom) * wd->tsize;
- }
-
- EINA_LIST_FOREACH(wd->grids, l, g)
- {
- if (g->zoom == wd->zoom)
- {
- _grid_raise(g);
- goto done;
- }
- }
- g = grid_create(obj);
- if (g)
- {
- if (eina_list_count(wd->grids) > 1)
- {
- g_zoom = eina_list_last(wd->grids)->data;
- wd->grids = eina_list_remove(wd->grids, g_zoom);
- grid_clear(obj, g_zoom);
- free(g_zoom);
- }
- wd->grids = eina_list_prepend(wd->grids, g);
- }
- else
- {
- EINA_LIST_FREE(wd->grids, g)
- {
- grid_clear(obj, g);
- free(g);
- }
- }
-done:
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ EINA_SAFETY_ON_NULL_RETURN(wd->src_tile);
+
+ if (wd->mode != ELM_MAP_ZOOM_MODE_MANUAL) return;
+ if (zoom < 0) zoom = 0;
+ if (wd->zoom == zoom) return;
+ if (zoom > wd->src_tile->zoom_max) zoom = wd->src_tile->zoom_max;
+ if (zoom < wd->src_tile->zoom_min) zoom = wd->src_tile->zoom_min;
+
+ Delayed_Data *data = ELM_NEW(Delayed_Data);
+ data->func = _zoom_set;
+ data->wd = wd;
+ data->zoom = zoom;
+ data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
+ evas_object_smart_changed(data->wd->pan_smart);
+#else
+ (void) obj;
+ (void) zoom;
+#endif
+}
- wd->t_start = ecore_loop_time_get();
- wd->t_end = wd->t_start + _elm_config->zoom_friction;
- if (wd->paused)
- {
- zoom_do(obj);
- }
- else
- {
- if (!wd->zoom_animator)
- {
- wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
- wd->nosmooth++;
- if (wd->nosmooth == 1) _smooth_update(obj);
- started = 1;
- }
- }
- if (wd->zoom_animator)
- {
- if (!_zoom_anim(obj))
- {
- ecore_animator_del(wd->zoom_animator);
- wd->zoom_animator = NULL;
- }
- }
- if (wd->calc_job) ecore_job_del(wd->calc_job);
- wd->calc_job = ecore_job_add(_calc_job, wd);
- if (!wd->paused)
- {
- if (started)
- evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
- if (!wd->zoom_animator)
- evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
- }
-
- if (zoom_changed)
- evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
-}
-
-/**
- * Get the zoom level of the map
- *
- * This returns the current zoom level of the map object. Note that if
- * you set the fill mode to other than ELM_MAP_ZOOM_MODE_MANUAL
- * (which is the default), the zoom level may be changed at any time by the
- * map object itself to account for map size and map viewpoer size
- *
- * @param obj The map object
- * @return The current zoom level
- *
- * @ingroup Map
- */
-EAPI double
+EAPI int
elm_map_zoom_get(const Evas_Object *obj)
{
- ELM_CHECK_WIDTYPE(obj, widtype) 1.0;
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) 0;
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return 1.0;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, 0);
return wd->zoom;
+#else
+ (void) obj;
+ return 0;
+#endif
}
-/**
- * Set the zoom mode
- *
- * This sets the zoom mode to manual or one of several automatic levels.
- * Manual (ELM_MAP_ZOOM_MODE_MANUAL) means that zoom is set manually by
- * elm_map_zoom_set() and will stay at that level until changed by code
- * or until zoom mode is changed. This is the default mode.
- * The Automatic modes will allow the map object to automatically
- * adjust zoom mode based on properties. ELM_MAP_ZOOM_MODE_AUTO_FIT) will
- * adjust zoom so the map fits inside the scroll frame with no pixels
- * outside this area. ELM_MAP_ZOOM_MODE_AUTO_FILL will be similar but
- * ensure no pixels within the frame are left unfilled. Do not forget that the valid sizes are 2^zoom, consequently the map may be smaller than the scroller view.
- *
- * @param obj The map object
- * @param mode The desired mode
- *
- * @ingroup Map
- */
EAPI void
elm_map_zoom_mode_set(Evas_Object *obj, Elm_Map_Zoom_Mode mode)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- if (wd->mode == mode) return;
- wd->mode = mode;
- {
- double tz = wd->zoom;
- wd->zoom = 0.0;
- elm_map_zoom_set(wd->obj, tz);
- }
-}
-
-/**
- * Get the zoom mode
- *
- * This gets the current zoom mode of the map object
- *
- * @param obj The map object
- * @return The current zoom mode
- *
- * @ingroup Map
- */
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ if ((mode == ELM_MAP_ZOOM_MODE_MANUAL) && (wd->mode == !!mode)) return;
+
+ Delayed_Data *data = ELM_NEW(Delayed_Data);
+ data->mode = mode;
+ data->func = _zoom_mode_set;
+ data->wd = wd;
+ data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
+ evas_object_smart_changed(data->wd->pan_smart);
+#else
+ (void) obj;
+ (void) mode;
+#endif
+}
+
EAPI Elm_Map_Zoom_Mode
elm_map_zoom_mode_get(const Evas_Object *obj)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ZOOM_MODE_MANUAL;
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return ELM_MAP_ZOOM_MODE_MANUAL;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, ELM_MAP_ZOOM_MODE_MANUAL);
+
return wd->mode;
+#else
+ (void) obj;
+ return ELM_MAP_ZOOM_MODE_MANUAL;
+#endif
}
-/**
- * Centers the map at @p lon @p lat using an animation to scroll.
- *
- * @param obj The map object
- * @param lon Longitude to center at
- * @param lon Latitude to center at
- *
- * @ingroup Map
- */
EAPI void
-elm_map_geo_region_bring_in(Evas_Object *obj, double lon, double lat)
+elm_map_zoom_max_set(Evas_Object *obj, int zoom)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- int rx, ry, rw, rh;
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ EINA_SAFETY_ON_NULL_RETURN(wd->src_tile);
- if (!wd) return;
- elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
- elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
+ if ((zoom > wd->src_tile->zoom_max) || (zoom < wd->src_tile->zoom_min))
+ return;
+ wd->zoom_max = zoom;
+#else
+ (void) obj;
+ (void) zoom;
+#endif
+}
+
+EAPI int
+elm_map_zoom_max_get(const Evas_Object *obj)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) 18;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, -1);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_tile, -1);
- rx = rx - rw / 2;
- ry = ry - rh / 2;
+ return wd->zoom_max;
+#else
+ (void) obj;
+ return 18;
+#endif
+}
- if (wd->zoom_animator)
- {
- wd->nosmooth--;
- if (!wd->nosmooth) _smooth_update(obj);
- ecore_animator_del(wd->zoom_animator);
- wd->zoom_animator = NULL;
- zoom_do(obj);
- evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
- }
- elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
-
- wd->center_on.enabled = EINA_TRUE;
- wd->center_on.lon = lon;
- wd->center_on.lat = lat;
-}
-
-/**
- * Move the map to the current coordinates.
- *
- * This move the map to the current coordinates. The map will be centered on these coordinates.
- *
- * @param obj The map object
- * @param lat The latitude.
- * @param lon The longitude.
- *
- * @ingroup Map
- */
EAPI void
-elm_map_geo_region_show(Evas_Object *obj, double lon, double lat)
+elm_map_zoom_min_set(Evas_Object *obj, int zoom)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- int rx, ry, rw, rh;
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ EINA_SAFETY_ON_NULL_RETURN(wd->src_tile);
+
+ if ((zoom > wd->src_tile->zoom_max) || (zoom < wd->src_tile->zoom_min))
+ return;
+ wd->zoom_min = zoom;
+#else
+ (void) obj;
+ (void) zoom;
+#endif
+}
+
+EAPI int
+elm_map_zoom_min_get(const Evas_Object *obj)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) 0;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, -1);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_tile, -1);
- if (!wd) return;
- elm_map_utils_convert_geo_into_coord(obj, lon, lat, wd->size.w, &rx, &ry);
- elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
+ return wd->zoom_min;
+#else
+ (void) obj;
+ return 0;
+#endif
+}
- rx = rx - rw / 2;
- ry = ry - rh / 2;
- if (wd->zoom_animator)
- {
- wd->nosmooth--;
- ecore_animator_del(wd->zoom_animator);
- wd->zoom_animator = NULL;
- zoom_do(obj);
- evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
- }
- elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
-
- wd->center_on.enabled = EINA_TRUE;
- wd->center_on.lon = lon;
- wd->center_on.lat = lat;
-}
-
-/**
- * Get the current coordinates of the map.
- *
- * This gets the current coordinates of the map object.
- *
- * @param obj The map object
- * @param lat The latitude.
- * @param lon The longitude.
- *
- * @ingroup Map
- */
EAPI void
-elm_map_geo_region_get(const Evas_Object *obj, double *lon, double *lat)
+elm_map_region_bring_in(Evas_Object *obj, double lon, double lat)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ Delayed_Data *data = ELM_NEW(Delayed_Data);
+ data->func = _region_bring_in;
+ data->wd = wd;
+ data->lon = lon;
+ data->lat = lat;
+ data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
+ evas_object_smart_changed(data->wd->pan_smart);
+#else
+ (void) obj;
+ (void) lon;
+ (void) lat;
+#endif
+}
+
+EAPI void
+elm_map_region_show(Evas_Object *obj, double lon, double lat)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+
+ Delayed_Data *data = ELM_NEW(Delayed_Data);
+ data->func = _region_show;
+ data->wd = wd;
+ data->lon = lon;
+ data->lat = lat;
+ data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
+ evas_object_smart_changed(data->wd->pan_smart);
+#else
+ (void) obj;
+ (void) lon;
+ (void) lat;
+#endif
+}
+
+EAPI void
+elm_map_region_get(const Evas_Object *obj, double *lon, double *lat)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- Evas_Coord sx, sy, sw, sh;
-
- if (!wd) return;
- elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
- elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
- sx += sw / 2;
- sy += sh / 2;
-
- elm_map_utils_convert_coord_into_geo(obj, sx, sy, wd->size.w, lon, lat);
-}
-
-/**
- * Set the paused state for map
- *
- * This sets the paused state to on (1) or off (0) for map. The default
- * is off. This will stop zooming using animation change zoom levels and
- * change instantly. This will stop any existing animations that are running.
- *
- * @param obj The map object
- * @param paused The pause state to set
- *
- * @ingroup Map
- */
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ double tlon, tlat;
+ Evas_Coord vx, vy, vw, vh;
+
+ _viewport_coord_get(wd, &vx, &vy, &vw, &vh);
+ _coord_to_region_convert(wd, vx + vw/2, vy + vh/2, wd->size.w, &tlon, &tlat);
+ if (lon) *lon = tlon;
+ if (lat) *lat = tlat;
+#else
+ (void) obj;
+ (void) lon;
+ (void) lat;
+#endif
+}
+
EAPI void
elm_map_paused_set(Evas_Object *obj, Eina_Bool paused)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
if (wd->paused == !!paused) return;
- wd->paused = paused;
+ wd->paused = !!paused;
if (wd->paused)
{
if (wd->zoom_animator)
{
- ecore_animator_del(wd->zoom_animator);
+ if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
wd->zoom_animator = NULL;
- zoom_do(obj);
- evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
+ zoom_do(wd, wd->zoom);
}
+ edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
+ "elm,state,busy,stop", "elm");
+ }
+ else
+ {
+ if (wd->download_num >= 1)
+ edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
+ "elm,state,busy,start", "elm");
}
+#else
+ (void) obj;
+ (void) paused;
+#endif
}
-/**
- * Set the paused state for the markers
- *
- * This sets the paused state to on (1) or off (0) for the markers. The default
- * is off. This will stop displaying the markers during change zoom levels. Set
- * to on if you have a large number of markers.
- *
- * @param obj The map object
- * @param paused The pause state to set
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_paused_markers_set(Evas_Object *obj, Eina_Bool paused)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- if (wd->paused_markers == !!paused) return;
- wd->paused_markers = paused;
-}
-
-/**
- * Get the paused state for map
- *
- * This gets the current paused state for the map object.
- *
- * @param obj The map object
- * @return The current paused state
- *
- * @ingroup Map
- */
EAPI Eina_Bool
elm_map_paused_get(const Evas_Object *obj)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return EINA_FALSE;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
+
return wd->paused;
+#else
+ (void) obj;
+ return EINA_FALSE;
+#endif
+}
+
+EAPI void
+elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ wd->rotate.d = degree;
+ wd->rotate.cx = cx;
+ wd->rotate.cy = cy;
+
+ evas_object_smart_changed(wd->pan_smart);
+#else
+ (void) obj;
+ (void) degree;
+ (void) cx;
+ (void) cy;
+#endif
+}
+
+EAPI void
+elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ if (degree) *degree = wd->rotate.d;
+ if (cx) *cx = wd->rotate.cx;
+ if (cy) *cy = wd->rotate.cy;
+#else
+ (void) obj;
+ (void) degree;
+ (void) cx;
+ (void) cy;
+#endif
+}
+
+EAPI void
+elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ if ((!wd->wheel_disabled) && (disabled))
+ evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
+ else if ((wd->wheel_disabled) && (!disabled))
+ evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_WHEEL, _mouse_wheel_cb, obj);
+ wd->wheel_disabled = !!disabled;
+#else
+ (void) obj;
+ (void) disabled;
+#endif
}
-/**
- * Get the paused state for the markers
- *
- * This gets the current paused state for the markers object.
- *
- * @param obj The map object
- * @return The current paused state
- *
- * @ingroup Map
- */
EAPI Eina_Bool
-elm_map_paused_markers_get(const Evas_Object *obj)
+elm_map_wheel_disabled_get(const Evas_Object *obj)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return EINA_FALSE;
- return wd->paused_markers;
-}
-
-/**
- * Get the information of downloading status
- *
- * This gets the current downloading status for the map object.
- *
- * @param obj The map object
- * @param try_num the number of download trying map
- * @param finish_num the number of downloaded map
- *
- * @ingroup Map
- */
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
+
+ return wd->wheel_disabled;
+#else
+ (void) obj;
+ return EINA_FALSE;
+#endif
+}
+
+EAPI void
+elm_map_tile_load_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+
+ if (try_num) *try_num = wd->try_num;
+ if (finish_num) *finish_num = wd->finish_num;
+#else
+ (void) obj;
+ (void) try_num;
+ (void) finish_num;
+#endif
+}
+
+EAPI void
+elm_map_canvas_to_region_convert(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, double *lon, double *lat)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ EINA_SAFETY_ON_NULL_RETURN(lon);
+ EINA_SAFETY_ON_NULL_RETURN(lat);
+
+ _canvas_to_coord(wd, x, y, &x, &y);
+ _coord_to_region_convert(wd, x, y, wd->size.w, lon, lat);
+#else
+ (void) obj;
+ (void) x;
+ (void) y;
+ (void) lon;
+ (void) lat;
+#endif
+}
EAPI void
-elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int *finish_num)
+elm_map_region_to_canvas_convert(const Evas_Object *obj, double lon, double lat, Evas_Coord *x, Evas_Coord *y)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
-
- if (try_num)
- {
- *try_num = wd->try_num;
- }
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ EINA_SAFETY_ON_NULL_RETURN(x);
+ EINA_SAFETY_ON_NULL_RETURN(y);
- if (finish_num)
- {
- *finish_num = wd->finish_num;
- }
+ _region_to_coord_convert(wd, lon, lat, wd->size.w, x, y);
+ _coord_to_canvas(wd, *x, *y, x, y);
+#else
+ (void) obj;
+ (void) lon;
+ (void) lat;
+ (void) x;
+ (void) y;
+#endif
}
-/**
- * Convert a pixel coordinate (x,y) into a geographic coordinate (longitude, latitude).
- *
- * @param obj The map object
- * @param x the coordinate
- * @param y the coordinate
- * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
- * @param lon the longitude correspond to x
- * @param lat the latitude correspond to y
- *
- * @ingroup Map
- */
+
EAPI void
-elm_map_utils_convert_coord_into_geo(const Evas_Object *obj, int x, int y, int size, double *lon, double *lat)
+elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- int zoom = floor(log(size/256) / log(2));
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ EINA_SAFETY_ON_NULL_RETURN(user_agent);
- if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE)
- if ((wd->api) && (wd->api->obj_convert_coord_into_geo))
- if (wd->api->obj_convert_coord_into_geo(obj, zoom, x, y, size, lon, lat)) return;
+ eina_stringshare_replace(&wd->user_agent, user_agent);
- if (lon)
- {
- *lon = x / (double)size * 360.0 - 180;
- }
- if (lat)
- {
- double n = ELM_PI - 2.0 * ELM_PI * y / size;
- *lat = 180.0 / ELM_PI * atan(0.5 * (exp(n) - exp(-n)));
- }
+ if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
+ eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
+#else
+ (void) obj;
+ (void) user_agent;
+#endif
}
-/**
- * Convert a geographic coordinate (longitude, latitude) into a pixel coordinate (x, y).
- *
- * @param obj The map object
- * @param lon the longitude
- * @param lat the latitude
- * @param size the size in pixels of the map. The map is a square and generally his size is : pow(2.0, zoom)*256.
- * @param x the coordinate correspond to the longitude
- * @param y the coordinate correspond to the latitude
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_utils_convert_geo_into_coord(const Evas_Object *obj, double lon, double lat, int size, int *x, int *y)
+EAPI const char *
+elm_map_user_agent_get(const Evas_Object *obj)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
- int zoom = floor(log(size/256) / log(2));
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
- if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE)
- if ((wd->api) && (wd->api->obj_convert_geo_into_coord))
- if (wd->api->obj_convert_geo_into_coord(obj, zoom, lon, lat, size, x, y)) return;
+ return wd->user_agent;
+#else
+ (void) obj;
+ return NULL;
+#endif
+}
- if (x)
- *x = floor((lon + 180.0) / 360.0 * size);
- if (y)
- *y = floor((1.0 - log( tan(lat * ELM_PI/180.0) + 1.0 / cos(lat * ELM_PI/180.0)) / ELM_PI) / 2.0 * size);
-}
-
-/**
- * Convert a geographic coordinate (longitude, latitude) into a name (address).
- *
- * @param obj The map object
- * @param lon the longitude
- * @param lat the latitude
- *
- * @return name the address
- *
- * @ingroup Map
- */
-EAPI Elm_Map_Name *
-elm_map_utils_convert_coord_into_name(const Evas_Object *obj, double lon, double lat)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat);
-}
-
-/**
- * Convert a name (address) into a geographic coordinate (longitude, latitude).
- *
- * @param obj The map object
- * @param name the address
- * @param lat the latitude correspond to y
- *
- * @return name the address
- *
- * @ingroup Map
- */
-EAPI Elm_Map_Name *
-elm_map_utils_convert_name_into_coord(const Evas_Object *obj, char *address)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- if (!address) return NULL;
- return _utils_convert_name(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0.0, 0.0);
-}
-
-/**
- * Convert a pixel coordinate into a roated pixcel coordinate.
- *
- * @param obj The map object
- * @param x x to rotate.
- * @param y y to rotate.
- * @param cx rotation's center horizontal position.
- * @param cy rotation's center vertical position.
- * @param degree amount of degrees from 0.0 to 360.0 to rotate arount Z axis.
- * @param xx rotated x.
- * @param yy rotated y.
- *
- * @ingroup Map
- */
EAPI void
-elm_map_utils_rotate_coord(const Evas_Object *obj __UNUSED__, const Evas_Coord x, const Evas_Coord y, const Evas_Coord cx, const Evas_Coord cy, const double degree, Evas_Coord *xx, Evas_Coord *yy)
+elm_map_source_set(Evas_Object *obj, Elm_Map_Source_Type type, const char *source_name)
{
- if ((!xx) || (!yy)) return;
-
- double r = (degree * M_PI) / 180.0;
- double tx, ty, ttx, tty;
-
- tx = x - cx;
- ty = y - cy;
-
- ttx = tx * cos(r);
- tty = tx * sin(r);
- tx = ttx + (ty * cos(r + M_PI_2));
- ty = tty + (ty * sin(r + M_PI_2));
-
- *xx = tx + cx;
- *yy = ty + cy;
-}
-
-/**
- * Add a marker on the map
- *
- * @param obj The map object
- * @param lon the longitude
- * @param lat the latitude
- * @param clas the class to use
- * @param clas_group the class group
- * @param data the data passed to the callbacks
- *
- * @return The marker object
- *
- * @ingroup Map
- */
-EAPI Elm_Map_Marker *
-elm_map_marker_add(Evas_Object *obj, double lon, double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void *data)
-{
- int i, j;
- Eina_List *l;
- Marker_Group *group;
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
- int mpi, mpj;
- int tabi[9];
- int tabj[9];
- const char *s;
- const char *style;
- Evas_Object *o;
-
- if (!wd) return NULL;
- EINA_SAFETY_ON_NULL_RETURN_VAL(clas_group, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(clas, NULL);
+ EINA_SAFETY_ON_NULL_RETURN(wd);
+ EINA_SAFETY_ON_NULL_RETURN(source_name);
- Elm_Map_Marker *marker = ELM_NEW(Elm_Map_Marker);
+ if (type == ELM_MAP_SOURCE_TYPE_TILE) _source_tile_set(wd, source_name);
+ else if (type == ELM_MAP_SOURCE_TYPE_ROUTE)
+ _source_route_set(wd, source_name);
+ else if (type == ELM_MAP_SOURCE_TYPE_NAME) _source_name_set(wd, source_name);
+ else ERR("Not supported map source type: %d", type);
- marker->wd = wd;
- marker->clas = clas;
- marker->clas_group = clas_group;
- marker->longitude = lon;
- marker->latitude = lat;
- marker->data = data;
-
- tabi[1] = tabi[4] = tabi[6] = -1;
- tabi[2] = tabi[0] = tabi[7] = 0;
- tabi[3] = tabi[5] = tabi[8] = 1;
+#else
+ (void) obj;
+ (void) source_name;
+#endif
+}
- tabj[1] = tabj[2] = tabj[3] = -1;
- tabj[4] = tabj[0] = tabj[5] = 0;
- tabj[6] = tabj[7] = tabj[8] = 1;
+EAPI const char *
+elm_map_source_get(const Evas_Object *obj, Elm_Map_Source_Type type)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_tile, NULL);
- if (!clas_group->priv.set)
- {
- style = "radio";
- if (marker->clas_group && marker->clas_group->style)
- style = marker->clas_group->style;
+ if (type == ELM_MAP_SOURCE_TYPE_TILE) return wd->src_tile->name;
+ else if (type == ELM_MAP_SOURCE_TYPE_ROUTE) return wd->src_route->name;
+ else if (type == ELM_MAP_SOURCE_TYPE_NAME) return wd->src_name->name;
+ else ERR("Not supported map source type: %d", type);
+ return NULL;
+#else
+ (void) obj;
+ return NULL;
+#endif
+}
- o = edje_object_add(evas_object_evas_get(obj));
- _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
- s = edje_object_data_get(o, "size_w");
- if (s) clas_group->priv.edje_w = atoi(s);
- else clas_group->priv.edje_w = 0;
- s = edje_object_data_get(o, "size_h");
- if (s) clas_group->priv.edje_h = atoi(s);
- else clas_group->priv.edje_h = 0;
- s = edje_object_data_get(o, "size_max_w");
- if (s) clas_group->priv.edje_max_w = atoi(s);
- else clas_group->priv.edje_max_w = 0;
- s = edje_object_data_get(o, "size_max_h");
- if (s) clas_group->priv.edje_max_h = atoi(s);
- else clas_group->priv.edje_max_h = 0;
- evas_object_del(o);
+EAPI const char **
+elm_map_sources_get(const Evas_Object *obj, Elm_Map_Source_Type type)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
- clas_group->priv.set = EINA_TRUE;
- }
+ if (type == ELM_MAP_SOURCE_TYPE_TILE) return wd->src_tile_names;
+ else if (type == ELM_MAP_SOURCE_TYPE_ROUTE) return wd->src_route_names;
+ else if (type == ELM_MAP_SOURCE_TYPE_NAME) return wd->src_name_names;
+ else ERR("Not supported map source type: %d", type);
+ return NULL;
+#else
+ (void) obj;
+ return NULL;
+#endif
+}
- if (!clas->priv.set)
+EAPI Elm_Map_Route *
+elm_map_route_add(Evas_Object *obj, Elm_Map_Route_Type type, Elm_Map_Route_Method method, double flon, double flat, double tlon, double tlat, Elm_Map_Route_Cb route_cb, void *data)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd->src_route, NULL);
+
+ char *type_name;
+ char *url;
+ char fname[PATH_MAX];
+
+ if (!ecore_file_exists(CACHE_ROUTE_ROOT))
+ ecore_file_mkpath(CACHE_ROUTE_ROOT);
+
+ if (type == ELM_MAP_ROUTE_TYPE_MOTOCAR)
+ type_name = strdup(ROUTE_TYPE_MOTORCAR);
+ else if (type == ELM_MAP_ROUTE_TYPE_BICYCLE)
+ type_name = strdup(ROUTE_TYPE_BICYCLE);
+ else if (type == ELM_MAP_ROUTE_TYPE_FOOT)
+ type_name = strdup(ROUTE_TYPE_FOOT);
+ else type_name = NULL;
+
+ url = wd->src_route->url_cb(obj, type_name, method, flon, flat, tlon, tlat);
+ if (!url)
{
- style = "radio";
- if (marker->clas && marker->clas->style)
- style = marker->clas->style;
-
- o = edje_object_add(evas_object_evas_get(obj));
- _elm_theme_object_set(obj, o, "map/marker", style, elm_widget_style_get(obj));
- s = edje_object_data_get(o, "size_w");
- if (s) clas->priv.edje_w = atoi(s);
- else clas->priv.edje_w = 0;
- s = edje_object_data_get(o, "size_h");
- if (s) clas->priv.edje_h = atoi(s);
- else clas->priv.edje_h = 0;
- evas_object_del(o);
-
- clas->priv.set = EINA_TRUE;
+ ERR("Route URL is NULL");
+ if (type_name) free(type_name);
+ return NULL;
}
+ if (type_name) free(type_name);
- for (i = clas_group->zoom_displayed; i <= ZOOM_MAX; i++)
- {
- elm_map_utils_convert_geo_into_coord(obj, lon, lat, pow(2.0, i)*wd->tsize,
- &(marker->x[i]), &(marker->y[i]));
-
- //search in the matrixsparse the region where the marker will be
- mpi = marker->x[i] / wd->tsize;
- mpj = marker->y[i] / wd->tsize;
-
- if (!wd->markers[i])
- {
- int size = pow(2.0, i);
- wd->markers[i] = eina_matrixsparse_new(size, size, NULL, NULL);
- }
-
- group = NULL;
- if (i <= clas_group->zoom_grouped)
- {
- for (j = 0, group = NULL; j < 9 && !group; j++)
- {
- EINA_LIST_FOREACH(eina_matrixsparse_data_idx_get(wd->markers[i], mpj + tabj[j], mpi + tabi[j]),
- l, group)
- {
- if (group->clas == marker->clas_group
- && ELM_RECTS_INTERSECT(marker->x[i]-clas->priv.edje_w/4,
- marker->y[i]-clas->priv.edje_h/4, clas->priv.edje_w, clas->priv.edje_h,
- group->x-group->w/4, group->y-group->h/4, group->w, group->h))
- {
- group->markers = eina_list_append(group->markers, marker);
- group->update_nbelems = EINA_TRUE;
- group->update_resize = EINA_TRUE;
-
- group->sum_x += marker->x[i];
- group->sum_y += marker->y[i];
- group->x = group->sum_x / eina_list_count(group->markers);
- group->y = group->sum_y / eina_list_count(group->markers);
-
- group->w = group->clas->priv.edje_w + group->clas->priv.edje_w/8.
- * eina_list_count(group->markers);
- group->h = group->clas->priv.edje_h + group->clas->priv.edje_h/8.
- * eina_list_count(group->markers);
- if (group->w > group->clas->priv.edje_max_w) group->w = group->clas->priv.edje_max_w;
- if (group->h > group->clas->priv.edje_max_h) group->h = group->clas->priv.edje_max_h;
-
- if (group->obj && eina_list_count(group->markers) == 2)
- {
- _group_object_free(group);
- _group_object_create(group);
- }
- if (group->bubble)
- _group_bubble_content_update(group);
-
- break;
- }
- }
- }
- }
- if (!group)
- {
- group = calloc(1, sizeof(Marker_Group));
- group->wd = wd;
- group->sum_x = marker->x[i];
- group->sum_y = marker->y[i];
- group->x = marker->x[i];
- group->y = marker->y[i];
- group->w = clas_group->priv.edje_w;
- group->h = clas_group->priv.edje_h;
- group->clas = clas_group;
-
- group->markers = eina_list_append(group->markers, marker);
- group->update_nbelems = EINA_TRUE;
- group->update_resize = EINA_TRUE;
-
- eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
-
- if (!group->cell)
- {
- l = eina_list_append(NULL, group);
- eina_matrixsparse_data_idx_set(wd->markers[i], mpj, mpi, l);
- eina_matrixsparse_cell_idx_get(wd->markers[i], mpj, mpi, &(group->cell));
- }
- else
- {
- l = eina_matrixsparse_cell_data_get(group->cell);
- l = eina_list_append(l, group);
- eina_matrixsparse_cell_data_set(group->cell, l);
- }
- }
- marker->groups[i] = group;
- }
+ Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
+ route->wd = wd;
+ snprintf(fname, sizeof(fname), CACHE_ROUTE_ROOT"/%d", rand());
+ route->fname = strdup(fname);
+ route->type = type;
+ route->method = method;
+ route->flon = flon;
+ route->flat = flat;
+ route->tlon = tlon;
+ route->tlat = tlat;
+ route->cb = route_cb;
+ route->data = data;
- if (wd->grids)
+ if (!ecore_file_download_full(url, route->fname, _route_cb, NULL, route,
+ &(route->job), wd->ua) || !(route->job))
{
- Evas_Coord ox, oy, ow, oh;
- evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
- marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
+ ERR("Can't request Route from %s to %s", url, route->fname);
+ free(route->fname);
+ free(route);
+ return NULL;
}
+ INF("Route requested from %s to %s", url, route->fname);
+ free(url);
- return marker;
+ wd->routes = eina_list_append(wd->routes, route);
+ evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, route);
+ edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
+ "elm,state,busy,start", "elm");
+ return route;
+#else
+ (void) obj;
+ (void) type;
+ (void) method;
+ (void) flon;
+ (void) flat;
+ (void) tlon;
+ (void) tlat;
+ (void) route_cb;
+ (void) data;
+ return NULL;
+#endif
}
-/**
- * Remove a marker from the map
- *
- * @param marker The marker to remove
- *
- * @ingroup Map
- */
+
EAPI void
-elm_map_marker_remove(Elm_Map_Marker *marker)
+elm_map_route_del(Elm_Map_Route *route)
{
- int i;
- Eina_List *groups;
- Widget_Data *wd;
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(route);
+ EINA_SAFETY_ON_NULL_RETURN(route->wd);
+ ELM_CHECK_WIDTYPE(route->wd->obj, widtype);
- EINA_SAFETY_ON_NULL_RETURN(marker);
- wd = marker->wd;
- if (!wd) return;
- for (i = marker->clas_group->zoom_displayed; i <= ZOOM_MAX; i++)
- {
- marker->groups[i]->markers = eina_list_remove(marker->groups[i]->markers, marker);
- if (!eina_list_count(marker->groups[i]->markers))
- {
- groups = eina_matrixsparse_cell_data_get(marker->groups[i]->cell);
- groups = eina_list_remove(groups, marker->groups[i]);
- eina_matrixsparse_cell_data_set(marker->groups[i]->cell, groups);
+ Path_Waypoint *w;
+ Path_Node *n;
- _group_object_free(marker->groups[i]);
- _group_bubble_free(marker->groups[i]);
- free(marker->groups[i]);
- }
- else
- {
- marker->groups[i]->sum_x -= marker->x[i];
- marker->groups[i]->sum_y -= marker->y[i];
-
- marker->groups[i]->x = marker->groups[i]->sum_x / eina_list_count(marker->groups[i]->markers);
- marker->groups[i]->y = marker->groups[i]->sum_y / eina_list_count(marker->groups[i]->markers);
-
- marker->groups[i]->w = marker->groups[i]->clas->priv.edje_w
- + marker->groups[i]->clas->priv.edje_w/8. * eina_list_count(marker->groups[i]->markers);
- marker->groups[i]->h = marker->groups[i]->clas->priv.edje_h
- + marker->groups[i]->clas->priv.edje_h/8. * eina_list_count(marker->groups[i]->markers);
- if (marker->groups[i]->w > marker->groups[i]->clas->priv.edje_max_w)
- marker->groups[i]->w = marker->groups[i]->clas->priv.edje_max_w;
- if (marker->groups[i]->h > marker->groups[i]->clas->priv.edje_max_h)
- marker->groups[i]->h = marker->groups[i]->clas->priv.edje_max_h;
-
- if ((marker->groups[i]->obj) && (eina_list_count(marker->groups[i]->markers) == 1))
- {
- _group_object_free(marker->groups[i]);
- _group_object_create(marker->groups[i]);
- }
- }
- }
+ if (route->job) ecore_file_download_abort(route->job);
- if ((marker->content) && (marker->clas->func.del))
- marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
- else if (marker->content)
- evas_object_del(marker->content);
+ EINA_LIST_FREE(route->waypoint, w)
+ {
+ if (w->point) eina_stringshare_del(w->point);
+ free(w);
+ }
- free(marker);
+ EINA_LIST_FREE(route->nodes, n)
+ {
+ if (n->pos.address) eina_stringshare_del(n->pos.address);
+ free(n);
+ }
- if (wd->grids)
+ if (route->fname)
{
- Evas_Coord ox, oy, ow, oh;
- evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
- marker_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
+ ecore_file_remove(route->fname);
+ free(route->fname);
}
+
+ route->wd->routes = eina_list_remove(route->wd->routes, route);
+ free(route);
+#else
+ (void) route;
+#endif
}
-/**
- * Get the current coordinates of the marker.
- *
- * @param marker marker.
- * @param lat The latitude.
- * @param lon The longitude.
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_marker_region_get(const Elm_Map_Marker *marker, double *lon, double *lat)
+EAPI double
+elm_map_route_distance_get(const Elm_Map_Route *route)
{
- EINA_SAFETY_ON_NULL_RETURN(marker);
- if (lon) *lon = marker->longitude;
- if (lat) *lat = marker->latitude;
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
+ return route->info.distance;
+#else
+ (void) route;
+ return 0.0;
+#endif
}
-/**
- * Move the map to the coordinate of the marker.
- *
- * @param marker The marker where the map will be center.
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_marker_bring_in(Elm_Map_Marker *marker)
+EAPI const char*
+elm_map_route_node_get(const Elm_Map_Route *route)
{
- EINA_SAFETY_ON_NULL_RETURN(marker);
- elm_map_geo_region_bring_in(marker->wd->obj, marker->longitude, marker->latitude);
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
+ return route->info.nodes;
+#else
+ (void) route;
+ return NULL;
+#endif
}
-/**
- * Move the map to the coordinate of the marker.
- *
- * @param marker The marker where the map will be center.
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_marker_show(Elm_Map_Marker *marker)
-{
- EINA_SAFETY_ON_NULL_RETURN(marker);
- elm_map_geo_region_show(marker->wd->obj, marker->longitude, marker->latitude);
-}
-
-/**
- * Move and zoom the map to display a list of markers.
- *
- * The map will be centered on the center point of the markers in the list. Then
- * the map will be zoomed in order to fit the markers using the maximum zoom which
- * allows display of all the markers.
- *
- * @param markers The list of markers (list of Elm_Map_Marker *)
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_markers_list_show(Eina_List *markers)
+EAPI const char*
+elm_map_route_waypoint_get(const Elm_Map_Route *route)
{
- int zoom;
- double lon, lat;
- Eina_List *l;
- Elm_Map_Marker *marker, *m_max_lon = NULL, *m_max_lat = NULL, *m_min_lon = NULL, *m_min_lat = NULL;
- Evas_Coord rw, rh, xc, yc;
- Widget_Data *wd;
-
- EINA_SAFETY_ON_NULL_RETURN(markers);
-
- EINA_LIST_FOREACH(markers, l, marker)
- {
- wd = marker->wd;
-
- if ((!m_min_lon) || (marker->longitude < m_min_lon->longitude))
- m_min_lon = marker;
-
- if ((!m_max_lon) || (marker->longitude > m_max_lon->longitude))
- m_max_lon = marker;
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
+ return route->info.waypoints;
+#else
+ (void) route;
+ return NULL;
+#endif
+}
- if ((!m_min_lat) || (marker->latitude > m_min_lat->latitude))
- m_min_lat = marker;
+EAPI Elm_Map_Name *
+elm_map_name_add(const Evas_Object *obj, const char *address, double lon, double lat, Elm_Map_Name_Cb name_cb, void *data)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- if ((!m_max_lat) || (marker->latitude < m_max_lat->latitude))
- m_max_lat = marker;
- }
+ if (address)
+ return _name_request(obj, ELM_MAP_NAME_METHOD_SEARCH, address, 0, 0,
+ name_cb, data);
+ else
+ return _name_request(obj, ELM_MAP_NAME_METHOD_REVERSE, NULL, lon, lat,
+ name_cb, data);
+#else
+ (void) obj;
+ (void) address;
+ (void) lon;
+ (void) lat;
+ (void) name_cb;
+ (void) data;
+ return NULL;
+#endif
+}
- lon = (m_max_lon->longitude - m_min_lon->longitude) / 2. + m_min_lon->longitude;
- lat = (m_max_lat->latitude - m_min_lat->latitude) / 2. + m_min_lat->latitude;
+EAPI void
+elm_map_name_del(Elm_Map_Name *name)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(name);
+ EINA_SAFETY_ON_NULL_RETURN(name->wd);
+ ELM_CHECK_WIDTYPE(name->wd->obj, widtype);
- elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
- for (zoom = map_sources_tab[wd->source].zoom_max; zoom>map_sources_tab[wd->source].zoom_min; zoom--)
+ if (name->job) ecore_file_download_abort(name->job);
+ if (name->address) free(name->address);
+ if (name->fname)
{
- Evas_Coord size = pow(2.0, zoom)*wd->tsize;
- elm_map_utils_convert_geo_into_coord(wd->obj, lon, lat, size, &xc, &yc);
-
- if ((m_min_lon->x[zoom] - wd->marker_max_w >= xc-rw/2)
- && (m_min_lat->y[zoom] - wd->marker_max_h >= yc-rh/2)
- && (m_max_lon->x[zoom] + wd->marker_max_w <= xc+rw/2)
- && (m_max_lat->y[zoom] + wd->marker_max_h <= yc+rh/2))
- break;
+ ecore_file_remove(name->fname);
+ free(name->fname);
}
- elm_map_geo_region_show(wd->obj, lon, lat);
- elm_map_zoom_set(wd->obj, zoom);
+ name->wd->names = eina_list_remove(name->wd->names, name);
+ free(name);
+#else
+ (void) name;
+#endif
}
-/**
- * Set the maximum numbers of markers display in a group.
- *
- * A group can have a long list of markers, consequently the creation of the content
- * of the bubble can be very slow. In order to avoid this, a maximum number of items
- * is displayed in a bubble. By default this number is 30.
- *
- * @param obj The map object.
- * @param max The maximum numbers of items displayed in a bubble.
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_max_marker_per_group_set(Evas_Object *obj, int max)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- wd->markers_max_num = max;
-}
-
-/**
- * Return the evas object getting from the ElmMapMarkerGetFunc callback
- *
- * @param marker The marker.
- * @return Return the evas object if it exists, else NULL.
- *
- * @ingroup Map
- */
-EAPI Evas_Object *
-elm_map_marker_object_get(const Elm_Map_Marker *marker)
+EAPI const char *
+elm_map_name_address_get(const Elm_Map_Name *name)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(marker, NULL);
- return marker->content;
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(name->wd, NULL);
+ ELM_CHECK_WIDTYPE(name->wd->obj, widtype) NULL;
+
+ return name->address;
+#else
+ (void) name;
+ return NULL;
+#endif
}
-/**
- * Update the marker
- *
- * @param marker The marker.
- *
- * @ingroup Map
- */
EAPI void
-elm_map_marker_update(Elm_Map_Marker *marker)
+elm_map_name_region_get(const Elm_Map_Name *name, double *lon, double *lat)
{
- EINA_SAFETY_ON_NULL_RETURN(marker);
- if (marker->content)
- {
- if (marker->clas->func.del)
- marker->clas->func.del(marker->wd->obj, marker, marker->data, marker->content);
- else
- evas_object_del(marker->content);
- marker->content = NULL;
- _group_bubble_content_update(marker->groups[marker->wd->zoom]);
- }
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(name);
+ EINA_SAFETY_ON_NULL_RETURN(name->wd);
+ ELM_CHECK_WIDTYPE(name->wd->obj, widtype);
+
+ if (lon) *lon = name->lon;
+ if (lat) *lat = name->lat;
+#else
+ (void) name;
+ (void) lon;
+ (void) lat;
+#endif
}
-/**
- * Close all opened bubbles
- *
- * @param obj The map object
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_bubbles_close(Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- Marker_Group *group;
- Eina_List *l, *l_next;
- if (!wd) return;
- EINA_LIST_FOREACH_SAFE(wd->opened_bubbles, l, l_next, group)
- _group_bubble_free(group);
-}
-
-
-/**
- * Create a group class.
- *
- * Each marker must be associated to a group class. Marker with the same group are grouped if they are close.
- * The group class defines the style of the marker when a marker is grouped to others markers.
- *
- * @param obj The map object
- * @return Returns the new group class
- *
- * @ingroup Map
- */
-EAPI Elm_Map_Group_Class *
-elm_map_group_class_new(Evas_Object *obj)
+EAPI Elm_Map_Overlay *
+elm_map_overlay_add(Evas_Object *obj, double lon, double lat)
{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- Elm_Map_Group_Class *clas = calloc(1, sizeof(Elm_Map_Group_Class));
- clas->zoom_grouped = ZOOM_MAX;
- wd->groups_clas = eina_list_append(wd->groups_clas, clas);
- return clas;
-}
-
-/**
- * Set the style of a group class (radio, radio2 or empty)
- *
- * @param clas the group class
- * @param style the new style
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_group_class_style_set(Elm_Map_Group_Class *clas, const char *style)
-{
- EINA_SAFETY_ON_NULL_RETURN(clas);
- eina_stringshare_replace(&clas->style, style);
-}
-
-/**
- * Set the icon callback of a group class.
- *
- * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
- *
- * @param clas the group class
- * @param icon_get the callback to create the icon
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_group_class_icon_cb_set(Elm_Map_Group_Class *clas, ElmMapGroupIconGetFunc icon_get)
-{
- EINA_SAFETY_ON_NULL_RETURN(clas);
- clas->func.icon_get = icon_get;
-}
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+
+ Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
+ overlay->wd = wd;
+ overlay->type = ELM_MAP_OVERLAY_TYPE_DEFAULT;
+ overlay->c.r = 0x87;
+ overlay->c.g = 0xce;
+ overlay->c.b = 0xeb;
+ overlay->c.a = 255;
+ overlay->ovl = _overlay_default_new(overlay, lon, lat, overlay->c, 1);
+ overlay->grp = _overlay_group_new(wd);
+ wd->overlays = eina_list_append(wd->overlays, overlay);
-/**
- * Set the data associated to the group class (radio, radio2 or empty)
- *
- * @param clas the group class
- * @param data the new user data
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_group_class_data_set(Elm_Map_Group_Class *clas, void *data)
-{
- EINA_SAFETY_ON_NULL_RETURN(clas);
- clas->data = data;
-}
-
-/**
- * Set the zoom from where the markers are displayed.
- *
- * Markers will not be displayed for a zoom less than @ref zoom
- *
- * @param clas the group class
- * @param zoom the zoom
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_group_class_zoom_displayed_set(Elm_Map_Group_Class *clas, int zoom)
-{
- EINA_SAFETY_ON_NULL_RETURN(clas);
- clas->zoom_displayed = zoom;
+ evas_object_smart_changed(wd->pan_smart);
+ return overlay;
+#else
+ (void) obj;
+ (void) lon;
+ (void) lat;
+ return NULL;
+#endif
}
-/**
- * Set the zoom from where the markers are no more grouped.
- *
- * @param clas the group class
- * @param zoom the zoom
- *
- * @ingroup Map
- */
EAPI void
-elm_map_group_class_zoom_grouped_set(Elm_Map_Group_Class *clas, int zoom)
+elm_map_overlay_del(Elm_Map_Overlay *overlay)
{
- EINA_SAFETY_ON_NULL_RETURN(clas);
- clas->zoom_grouped = zoom;
-}
-
-/**
- * Set if the markers associated to the group class @clas are hidden or not.
- * If @ref hide is true the markers will be hidden.
- *
- * @param clas the group class
- * @param hide if true the markers will be hidden, else they will be displayed.
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_group_class_hide_set(Evas_Object *obj, Elm_Map_Group_Class *clas, Eina_Bool hide)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- EINA_SAFETY_ON_NULL_RETURN(clas);
- if (clas->hide == hide) return;
- clas->hide = hide;
- if (wd->grids)
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
+
+ if (overlay->grp)
{
- Evas_Coord ox, oy, ow, oh;
- evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
- marker_place(obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
+ if (overlay->grp->clas)
+ elm_map_overlay_class_remove(overlay->grp->clas, overlay);
+ _overlay_group_free(overlay->grp);
}
-}
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ _overlay_default_free(overlay->ovl);
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
+ _overlay_bubble_free(overlay->ovl);
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
+ _overlay_class_free(overlay->ovl);
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
+ _overlay_route_free(overlay->ovl);
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_LINE)
+ _overlay_line_free(overlay->ovl);
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON)
+ _overlay_polygon_free(overlay->ovl);
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CIRCLE)
+ _overlay_circle_free(overlay->ovl);
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_SCALE)
+ _overlay_scale_free(overlay->ovl);
+ else ERR("Invalid overlay type: %d", overlay->type);
+
+ overlay->wd->overlays = eina_list_remove(overlay->wd->overlays, overlay);
+ evas_object_smart_changed(overlay->wd->pan_smart);
+
+ free(overlay);
+#else
+ (void) overlay;
+#endif
+}
+
+EAPI Elm_Map_Overlay_Type
+elm_map_overlay_type_get(const Elm_Map_Overlay *overlay)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, ELM_MAP_OVERLAY_TYPE_NONE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, ELM_MAP_OVERLAY_TYPE_NONE);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) ELM_MAP_OVERLAY_TYPE_NONE;
+
+ return overlay->type;
+#else
+ (void) overlay;
+ return ELM_MAP_OVERLAY_TYPE_NONE;
+#endif
+}
-/**
- * Create a marker class.
- *
- * Each marker must be associated to a class.
- * The class defines the style of the marker when a marker is displayed alone (not grouped).
- *
- * @param obj The map object
- * @return Returns the new class
- *
- * @ingroup Map
- */
-EAPI Elm_Map_Marker_Class *
-elm_map_marker_class_new(Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return NULL;
- Elm_Map_Marker_Class *clas = calloc(1, sizeof(Elm_Map_Marker_Class));
- wd->markers_clas = eina_list_append(wd->markers_clas, clas);
- return clas;
-}
-
-/**
- * Set the style of a class (radio, radio2 or empty)
- *
- * @param clas the group class
- * @param style the new style
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_marker_class_style_set(Elm_Map_Marker_Class *clas, const char *style)
-{
- EINA_SAFETY_ON_NULL_RETURN(clas);
- eina_stringshare_replace(&clas->style, style);
-}
-
-/**
- * Set the icon callback of a class.
- *
- * A custom icon can be displayed in a marker. The function @ref icon_get must return this icon.
- *
- * @param clas the group class
- * @param icon_get the callback to create the icon
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_marker_class_icon_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerIconGetFunc icon_get)
-{
- EINA_SAFETY_ON_NULL_RETURN(clas);
- clas->func.icon_get = icon_get;
-}
-
-/**
- *
- * Set the callback of the content of the bubble.
- *
- * When the user click on a marker, a bubble is displayed with a content.
- * The callback @ref get musst return this content. It can be NULL.
- *
- * @param clas the group class
- * @param get the callback to create the content
- *
- * @ingroup Map
- */
EAPI void
-elm_map_marker_class_get_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerGetFunc get)
+elm_map_overlay_data_set(Elm_Map_Overlay *overlay, void *data)
{
- EINA_SAFETY_ON_NULL_RETURN(clas);
- clas->func.get = get;
-}
-
-/**
- * Set the callback of the content of delete the object created by the callback "get".
- *
- * If this callback is defined the user will have to delete (or not) the object inside.
- * If the callback is not defined the object will be destroyed with evas_object_del()
- *
- * @param clas the group class
- * @param del the callback to delete the content
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_marker_class_del_cb_set(Elm_Map_Marker_Class *clas, ElmMapMarkerDelFunc del)
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
+
+ overlay->data = data;
+#else
+ (void) overlay;
+ (void) data;
+#endif
+}
+
+EAPI void *
+elm_map_overlay_data_get(const Elm_Map_Overlay *overlay)
{
- EINA_SAFETY_ON_NULL_RETURN(clas);
- clas->func.del = del;
-}
-
-/**
- * Set the source of the map.
- *
- * Elm_Map retrieves the image which composed the map from a web service. This web service can
- * be set with this method. A different service can return a different maps with different
- * information and it can use different zoom value.
- *
- * @param clas the group class
- * @param source the new source
- *
- * @ingroup Map
- */
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL;
+
+ return overlay->data;
+#else
+ (void) overlay;
+ return NULL;
+#endif
+}
+
EAPI void
-elm_map_source_set(Evas_Object *obj, Elm_Map_Sources source)
+elm_map_overlay_hide_set(Elm_Map_Overlay *overlay, Eina_Bool hide)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- Grid *grid;
- int zoom;
- if (!wd) return;
- if (wd->source == source ) return;
- if (!map_sources_tab[source].url_cb) return;
- _elm_config_sub_init();
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
- EINA_LIST_FREE(wd->grids, grid) grid_clear(obj, grid);
+ if (overlay->hide == !!hide) return;
+ overlay->hide = hide;
- wd->source = source;
- zoom = wd->zoom;
- wd->zoom = -1;
+ evas_object_smart_changed(overlay->wd->pan_smart);
+#else
+ (void) overlay;
+ (void) hide;
+#endif
+}
- if (map_sources_tab[wd->source].zoom_max < zoom)
- zoom = map_sources_tab[wd->source].zoom_max;
- if (map_sources_tab[wd->source].zoom_min > zoom)
- zoom = map_sources_tab[wd->source].zoom_min;
+EAPI Eina_Bool
+elm_map_overlay_hide_get(const Elm_Map_Overlay *overlay)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE;
- elm_map_zoom_set(obj, zoom);
+ return overlay->hide;
+#else
+ (void) overlay;
+ return EINA_FALSE;
+#endif
}
-/**
- * Set the source of the route.
- *
- * @param clas the group class
- * @param source the new source
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_route_source_set(Evas_Object *obj, Elm_Map_Route_Sources source)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- wd->source = source;
-}
-
-/**
- * Get the current source
- *
- * @param obj the map object
- * @return Returns the maximum zoom of the source
- *
- * @ingroup Map
- */
-EAPI Elm_Map_Sources
-elm_map_source_get(const Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_SOURCE_MAPNIK;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return ELM_MAP_SOURCE_MAPNIK;
- return wd->source;
-}
-
-/**
- * Get the current route source
- *
- * @param obj the map object
- * @return Returns the source of the route
- *
- * @ingroup Map
- */
-EAPI Elm_Map_Route_Sources
-elm_map_route_source_get(const Evas_Object *obj)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) ELM_MAP_ROUTE_SOURCE_YOURS;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return ELM_MAP_ROUTE_SOURCE_YOURS;
- return wd->route_source;
-}
-
-/**
- * Set the API of a custom source.
- *
- * A custom web service can be associated to the source ELM_MAP_SOURCE_CUSTOM_(1..7).
- *
- * @param source the source ID (ELM_MAP_SOURCE_CUSTOM_(1..7))
- * @param name the name of the source
- * @param zoom_min the minimum zoom of the source, must be >= 0
- * @param zoom_max the maximum zoom of the source, must be <= ZOOM_MAX
- * @param url_cb the callback used to create the url from where a tile (png or jpeg file) is downloaded.
- *
- * @ingroup Map
- */
EAPI void
-elm_map_source_custom_api_set(Elm_Map_Sources source, const char *name, int zoom_min, int zoom_max, ElmMapSourceURLFunc url_cb, ElmMapRouteSourceURLFunc route_url_cb, ElmMapNameSourceURLFunc name_url_cb)
-{
- EINA_SAFETY_ON_NULL_RETURN(name);
- EINA_SAFETY_ON_NULL_RETURN(url_cb);
- map_sources_tab[source].name = name;
- map_sources_tab[source].zoom_min = zoom_min;
- map_sources_tab[source].zoom_max = zoom_max;
- map_sources_tab[source].url_cb = url_cb;
- map_sources_tab[source].route_url_cb = route_url_cb;
- map_sources_tab[source].name_url_cb = name_url_cb;
-}
-
-/**
- * Get the maximum zoom of the source.
- *
- * @param source the source
- * @return Returns the maximum zoom of the source
- *
- * @ingroup Map
- */
-EAPI int
-elm_map_source_zoom_max_get(Elm_Map_Sources source)
+elm_map_overlay_displayed_zoom_min_set(Elm_Map_Overlay *overlay, int zoom)
{
- return map_sources_tab[source].zoom_max;
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
+
+ overlay->zoom_min = zoom;
+ evas_object_smart_changed(overlay->wd->pan_smart);
+#else
+ (void) overlay;
+ (void) zoom;
+#endif
}
-/**
- * Get the minimum zoom of the source.
- *
- * @param source the source
- * @return Returns the minimum zoom of the source
- *
- * @ingroup Map
- */
EAPI int
-elm_map_source_zoom_min_get(Elm_Map_Sources source)
+elm_map_overlay_displayed_zoom_min_get(const Elm_Map_Overlay *overlay)
{
- return map_sources_tab[source].zoom_min;
-}
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, 0);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, 0);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) 0;
-/**
- * Get the name of a source.
- *
- * @param source the source
- * @return Returns the name of the source
- *
- * @ingroup Map
- */
-EAPI const char *
-elm_map_source_name_get(Elm_Map_Sources source)
-{
- return map_sources_tab[source].name;
+ return overlay->zoom_min;
+#else
+ (void) overlay;
+ return 0;
+#endif
}
-/**
- * Set the user agent of the widget map.
- *
- * @param obj The map object
- * @param user_agent the user agent of the widget map
- *
- * @ingroup Map
- */
EAPI void
-elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
+elm_map_overlay_paused_set(Elm_Map_Overlay *overlay, Eina_Bool paused)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
- if (!wd) return;
- if (!wd->user_agent) wd->user_agent = eina_stringshare_add(user_agent);
- else eina_stringshare_replace(&wd->user_agent, user_agent);
+ if (overlay->paused == !!paused) return;
+ overlay->paused = paused;
- if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
- eina_hash_set(wd->ua, "User-Agent", wd->user_agent);
+ evas_object_smart_changed(overlay->wd->pan_smart);
+#else
+ (void) overlay;
+ (void) paused;
+#endif
}
-/**
- * Get the user agent of the widget map.
- *
- * @param obj The map object
- * @return The user agent of the widget map
- *
- * @ingroup Map
- */
-EAPI const char *
-elm_map_user_agent_get(Evas_Object *obj)
+EAPI Eina_Bool
+elm_map_overlay_paused_get(const Elm_Map_Overlay *overlay)
{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, EINA_FALSE);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) EINA_FALSE;
- if (!wd) return NULL;
- return wd->user_agent;
+ return overlay->paused;
+#else
+ (void) overlay;
+ return EINA_FALSE;
+#endif
}
-/**
- * Add a route on the map
- *
- * @param obj The map object
- * @param type the type if transport
- * @param method the routing method
- * @param flon the start longitude
- * @param flat the start latitude
- * @param tlon the destination longitude
- * @param tlat the destination latitude
- *
- * @return The Route object
- *
- * @ingroup Map
- */
-EAPI Elm_Map_Route *
-elm_map_route_add(Evas_Object *obj,
- Elm_Map_Route_Type type,
- Elm_Map_Route_Method method,
- double flon,
- double flat,
- double tlon,
- double tlat)
-{
- ELM_CHECK_WIDTYPE(obj, widtype) NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return EINA_FALSE;
- char buf[PATH_MAX];
- char *source;
- char *type_name = NULL;
- int fd;
- Elm_Map_Route *route = ELM_NEW(Elm_Map_Route);
- if (!route) return NULL;
+EAPI void
+elm_map_overlay_show(Elm_Map_Overlay *overlay)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
- snprintf(buf, sizeof(buf), DEST_ROUTE_XML_FILE);
- fd = mkstemp(buf);
- if (fd < 0)
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
{
- free(route);
- return NULL;
+ Overlay_Default *ovl = overlay->ovl;
+ elm_map_region_show(overlay->wd->obj, ovl->lon, ovl->lat);
}
-
- route->con_url = ecore_con_url_new(NULL);
- route->ud.fname = strdup(buf);
- INF("xml file : %s", route->ud.fname);
-
- route->ud.fd = fdopen(fd, "w+");
- if ((!route->con_url) || (!route->ud.fd))
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
{
- ecore_con_url_free(route->con_url);
- free(route);
- return NULL;
+ Overlay_Bubble *ovl = overlay->ovl;
+ elm_map_region_show(overlay->wd->obj, ovl->lon, ovl->lat);
}
-
- route->wd = wd;
- route->color.r = 255;
- route->color.g = 0;
- route->color.b = 0;
- route->color.a = 255;
- route->handlers = eina_list_append
- (route->handlers, (void *)ecore_event_handler_add
- (ECORE_CON_EVENT_URL_COMPLETE, _route_complete_cb, route));
-
- route->inbound = EINA_FALSE;
- route->type = type;
- route->method = method;
- route->flon = flon;
- route->flat = flat;
- route->tlon = tlon;
- route->tlat = tlat;
-
- switch (type)
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
{
- case ELM_MAP_ROUTE_TYPE_MOTOCAR:
- type_name = strdup(ROUTE_TYPE_MOTORCAR);
- break;
- case ELM_MAP_ROUTE_TYPE_BICYCLE:
- type_name = strdup(ROUTE_TYPE_BICYCLE);
- break;
- case ELM_MAP_ROUTE_TYPE_FOOT:
- type_name = strdup(ROUTE_TYPE_FOOT);
- break;
- default:
- break;
+ Overlay_Class *ovl = overlay->ovl;
+ double lon, lat, max_lo, min_lo, max_la, min_la;
+ _region_max_min_get(ovl->members, &max_lo, &min_lo, &max_la, &min_la);
+ lon = (max_lo + min_lo) / 2;
+ lat = (max_la + min_la) / 2;
+ elm_map_region_show(overlay->wd->obj, lon, lat);
}
+ else ERR("Not supported overlay type: %d", overlay->type);
- source = map_sources_tab[wd->source].route_url_cb(obj, type_name, method, flon, flat, tlon, tlat);
- INF("route url = %s", source);
+ evas_object_smart_changed(overlay->wd->pan_smart);
+#else
+ (void) overlay;
+#endif
+}
- wd->route = eina_list_append(wd->route, route);
+EAPI void
+elm_map_overlays_show(Eina_List *overlays)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlays);
+ EINA_SAFETY_ON_FALSE_RETURN(eina_list_count(overlays));
- ecore_con_url_url_set(route->con_url, source);
- ecore_con_url_fd_set(route->con_url, fileno(route->ud.fd));
- ecore_con_url_data_set(route->con_url, route);
- ecore_con_url_get(route->con_url);
- if (type_name) free(type_name);
- if (source) free(source);
+ Elm_Map_Overlay *overlay;
+ overlay = eina_list_data_get(overlays);
- edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
- "elm,state,busy,start", "elm");
- evas_object_smart_callback_call(wd->obj, SIG_ROUTE_LOAD, NULL);
- return route;
+ Delayed_Data *data = ELM_NEW(Delayed_Data);
+ data->func = _overlays_show;
+ data->wd = overlay->wd;
+ data->overlays = eina_list_clone(overlays);
+ data->wd->delayed_jobs = eina_list_append(data->wd->delayed_jobs, data);
+ evas_object_smart_changed(data->wd->pan_smart);
+#else
+ (void) overlays;
+#endif
}
-/**
- * Remove a route from the map
- *
- * @param route The route to remove
- *
- * @ingroup Map
- */
-
EAPI void
-elm_map_route_remove(Elm_Map_Route *route)
+elm_map_overlay_region_set(Elm_Map_Overlay *overlay, double lon, double lat)
{
- EINA_SAFETY_ON_NULL_RETURN(route);
-
- Route_Waypoint *w;
- Route_Node *n;
- Evas_Object *p;
- Ecore_Event_Handler *h;
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
- EINA_LIST_FREE(route->path, p)
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
{
- evas_object_del(p);
+ Overlay_Default *ovl = overlay->ovl;
+ ovl->lon = lon;
+ ovl->lat = lat;
}
-
- EINA_LIST_FREE(route->waypoint, w)
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
{
- if (w->point) eina_stringshare_del(w->point);
- free(w);
+ Overlay_Bubble *ovl = overlay->ovl;
+ ovl->lon = lon;
+ ovl->lat = lat;
}
+ else ERR("Not supported overlay type: %d", overlay->type);
- EINA_LIST_FREE(route->nodes, n)
+ evas_object_smart_changed(overlay->wd->pan_smart);
+#else
+ (void) overlay;
+ (void) lon;
+ (void) lat;
+#endif
+}
+
+EAPI void
+elm_map_overlay_region_get(const Elm_Map_Overlay *overlay, double *lon, double *lat)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
+
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_GROUP)
{
- if (n->pos.address) eina_stringshare_del(n->pos.address);
- free(n);
+ Overlay_Group *ovl = overlay->ovl;
+ _overlay_group_region_get(ovl, lon, lat);
}
-
- EINA_LIST_FREE(route->handlers, h)
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
{
- ecore_event_handler_del(h);
+ const Overlay_Default *ovl = overlay->ovl;
+ if (lon) *lon = ovl->lon;
+ if (lat) *lat = ovl->lat;
}
-
- if (route->ud.fname)
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_BUBBLE)
{
- ecore_file_remove(route->ud.fname);
- free(route->ud.fname);
- route->ud.fname = NULL;
+ const Overlay_Bubble *ovl = overlay->ovl;
+ if (lon) *lon = ovl->lon;
+ if (lat) *lat = ovl->lat;
}
+ else ERR("Not supported overlay type: %d", overlay->type);
+#else
+ (void) overlay;
+ (void) lon;
+ (void) lat;
+#endif
}
-/**
- * Set the option used for the background color
- *
- * @param route The route object
- * @param r
- * @param g
- * @param b
- * @param a
- *
- * This sets the color used for the route
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_route_color_set(Elm_Map_Route *route, int r, int g , int b, int a)
-{
- EINA_SAFETY_ON_NULL_RETURN(route);
- route->color.r = r;
- route->color.g = g;
- route->color.b = b;
- route->color.a = a;
-}
-
-/**
- * Get the option used for the background color
- *
- * @param route The route object
- * @param r
- * @param g
- * @param b
- * @param a
- *
- * @ingroup Map
- */
EAPI void
-elm_map_route_color_get(Elm_Map_Route *route, int *r, int *g , int *b, int *a)
-{
- EINA_SAFETY_ON_NULL_RETURN(route);
- if (r) *r = route->color.r;
- if (g) *g = route->color.g;
- if (b) *b = route->color.b;
- if (a) *a = route->color.a;
-}
-
-/**
- * Get the information of route distance
- *
- * @param route the route object
- * @return Returns the distance of route (unit : km)
- *
- * @ingroup Map
- */
-EAPI double
-elm_map_route_distance_get(Elm_Map_Route *route)
+elm_map_overlay_icon_set(Elm_Map_Overlay *overlay, Evas_Object *icon)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(route, 0.0);
- return route->info.distance;
-}
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(icon);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
-/**
- * Get the information of route nodes
- *
- * @param route the route object
- * @return Returns the nodes of route
- *
- * @ingroup Map
- */
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ _overlay_default_icon_update(overlay->ovl, icon);
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
+ _overlay_class_icon_update(overlay->ovl, icon);
+ else ERR("Not supported overlay type: %d", overlay->type);
-EAPI const char*
-elm_map_route_node_get(Elm_Map_Route *route)
-{
- EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
- return route->info.nodes;
+ evas_object_smart_changed(overlay->wd->pan_smart);
+#else
+ (void) overlay;
+ (void) icon;
+#endif
}
-/**
- * Get the information of route waypoint
- *
- * @param route the route object
- * @return Returns the waypoint of route
- *
- * @ingroup Map
- */
-
-EAPI const char*
-elm_map_route_waypoint_get(Elm_Map_Route *route)
+EAPI const Evas_Object *
+elm_map_overlay_icon_get(const Elm_Map_Overlay *overlay)
{
- EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
- return route->info.waypoints;
-}
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL;
-/**
- * Get the information of address
- *
- * @param name the name object
- * @return Returns the address of name
- *
- * @ingroup Map
- */
-EAPI const char *
-elm_map_name_address_get(Elm_Map_Name *name)
-{
- EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
- return name->address;
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ {
+ const Overlay_Default *ovl = overlay->ovl;
+ return ovl->icon;
+ }
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
+ {
+ const Overlay_Class *ovl = overlay->ovl;
+ return ovl->icon;
+ }
+ else
+ {
+ ERR("Not supported overlay type: %d", overlay->type);
+ return NULL;
+ }
+#else
+ (void) overlay;
+ return NULL;
+#endif
}
-/**
- * Get the current coordinates of the name.
- *
- * This gets the current coordinates of the name object.
- *
- * @param obj The name object
- * @param lat The latitude
- * @param lon The longitude
- *
- * @ingroup Map
- */
EAPI void
-elm_map_name_region_get(Elm_Map_Name *name, double *lon, double *lat)
+elm_map_overlay_content_set(Elm_Map_Overlay *overlay, Evas_Object *content)
{
- EINA_SAFETY_ON_NULL_RETURN(name);
- if (lon) *lon = name->lon;
- if (lat) *lat = name->lat;
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(content);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
+
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ _overlay_default_content_update(overlay->ovl, content, overlay);
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
+ _overlay_class_content_update(overlay->ovl, content);
+ else ERR("Not supported overlay type: %d", overlay->type);
+
+ evas_object_smart_changed(overlay->wd->pan_smart);
+#else
+ (void) overlay;
+ (void) obj;
+#endif
}
-/**
- * Remove a name from the map
- *
- * @param name The name to remove
- *
- * @ingroup Map
- */
-EAPI void
-elm_map_name_remove(Elm_Map_Name *name)
+EAPI const Evas_Object *
+elm_map_overlay_content_get(const Elm_Map_Overlay *overlay)
{
- EINA_SAFETY_ON_NULL_RETURN(name);
- if (name->address)
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(overlay->wd, NULL);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype) NULL;
+
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
{
- free(name->address);
- name->address = NULL;
+ const Overlay_Default *ovl = overlay->ovl;
+ return ovl->content;
}
- if (name->handler)
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
{
- ecore_event_handler_del(name->handler);
- name->handler = NULL;
+ const Overlay_Class *ovl = overlay->ovl;
+ return ovl->content;
}
- if (name->ud.fname)
+ else
{
- ecore_file_remove(name->ud.fname);
- free(name->ud.fname);
- name->ud.fname = NULL;
+ ERR("Not supported overlay type: %d", overlay->type);
+ return NULL;
}
+#else
+ (void) overlay;
+ return NULL;
+#endif
}
-/**
- * Set the rotate degree of the map
- *
- * @param obj The map object
- * @param angle amount of degrees from 0.0 to 360.0 to rotate arount Z axis
- * @param cx rotation's center horizontal position
- * @param cy rotation's center vertical position
- *
- * @ingroup Map
- */
EAPI void
-elm_map_rotate_set(Evas_Object *obj, double degree, Evas_Coord cx, Evas_Coord cy)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
+elm_map_overlay_color_set(Elm_Map_Overlay *overlay, int r, int g , int b, int a)
+{
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
+
+ overlay->c.r = r;
+ overlay->c.g = g;
+ overlay->c.b = b;
+ overlay->c.a = a;
+
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
+ _overlay_class_color_update(overlay->ovl, overlay->c);
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ _overlay_default_color_update(overlay->ovl, overlay->c);
+ else if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
+ _overlay_route_color_update(overlay->ovl, overlay->c);
+ else
+ {
+ ERR("Not supported overlay type: %d", overlay->type);
+ }
+
+#else
+ (void) overlay;
+ (void) r;
+ (void) g;
+ (void) b;
+ (void) a;
+#endif
+}
- wd->rotate.d = degree;
- wd->rotate.cx = cx;
- wd->rotate.cy = cy;
- wd->calc_job = ecore_job_add(_calc_job, wd);
-}
-
-/**
- * Get the rotate degree of the map
- *
- * @param obj The map object
- * @return amount of degrees from 0.0 to 360.0 to rotate arount Z axis
- * @param cx rotation's center horizontal position
- * @param cy rotation's center vertical position
- *
- * @ingroup Map
- */
EAPI void
-elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy)
+elm_map_overlay_color_get(const Elm_Map_Overlay *overlay, int *r, int *g , int *b, int *a)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
- Widget_Data *wd = elm_widget_data_get(obj);
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
- if (degree) *degree = wd->rotate.d;
- if (cx) *cx = wd->rotate.cx;
- if (cy) *cy = wd->rotate.cy;
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_ROUTE)
+ {
+ if (r) *r = overlay->c.r;
+ if (g) *g = overlay->c.g;
+ if (b) *b = overlay->c.b;
+ if (a) *a = overlay->c.a;
+ }
+ else ERR("Not supported overlay type: %d", overlay->type);
+#else
+ (void) overlay;
+ (void) r;
+ (void) g;
+ (void) b;
+ (void) a;
+#endif
}
-static char *
-_mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+EAPI void
+elm_map_overlay_get_cb_set(Elm_Map_Overlay *overlay, Elm_Map_Overlay_Get_Cb get_cb, void *data)
{
- char buf[PATH_MAX];
- snprintf(buf, sizeof(buf), "http://tile.openstreetmap.org/%d/%d/%d.png",
- zoom, x, y);
- return strdup(buf);
-}
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(overlay->wd);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
-static char *
-_osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
-{
- char buf[PATH_MAX];
- snprintf(buf, sizeof(buf),
- "http://tah.openstreetmap.org/Tiles/tile/%d/%d/%d.png",
- zoom, x, y);
- return strdup(buf);
-}
+ overlay->cb = get_cb;
+ overlay->cb_data = data;
-static char *
-_cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
-{
- char buf[PATH_MAX];
- snprintf(buf, sizeof(buf),
- "http://andy.sandbox.cloudmade.com/tiles/cycle/%d/%d/%d.png",
- zoom, x, y);
- return strdup(buf);
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_CLASS)
+ _overlay_class_cb_set(overlay->ovl, get_cb, data);
+#else
+ (void) overlay;
+ (void) get_cb;
+ (void) data;
+#endif
}
-static char *
-_maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+EAPI Elm_Map_Overlay *
+elm_map_overlay_class_add(Evas_Object *obj)
{
- char buf[PATH_MAX];
- snprintf(buf, sizeof(buf),
- "http://tah.openstreetmap.org/Tiles/maplint/%d/%d/%d.png",
- zoom, x, y);
- return strdup(buf);
-}
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+
+ Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
+ overlay->wd = wd;
+ overlay->type = ELM_MAP_OVERLAY_TYPE_CLASS;
+ overlay->ovl = _overlay_class_new(wd);
+ overlay->c.r = 0x90;
+ overlay->c.g = 0xee;
+ overlay->c.b = 0x90;
+ overlay->c.a = 0xff;
+ wd->overlays = eina_list_append(wd->overlays, overlay);
-static char *
-_custom1_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
-{
- return strdup("");
+ evas_object_smart_changed(wd->pan_smart);
+ return overlay;
+#else
+ (void) obj;
+ return NULL;
+#endif
}
-static char *
-_custom2_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
+EAPI void
+elm_map_overlay_class_append(Elm_Map_Overlay *clas, Elm_Map_Overlay *overlay)
{
- return strdup("");
-}
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(clas);
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(clas->wd);
+ ELM_CHECK_WIDTYPE(clas->wd->obj, widtype);
+ EINA_SAFETY_ON_FALSE_RETURN(clas->type == ELM_MAP_OVERLAY_TYPE_CLASS);
-static char *
-_custom3_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
-{
- return strdup("");
-}
+ Overlay_Class *clas_ovl = clas->ovl;
+ if (eina_list_data_find(clas_ovl->members, overlay))
+ {
+ ERR("Already added overlay into clas");
+ return;
+ }
+ clas_ovl->members = eina_list_append(clas_ovl->members, overlay);
+
+ // Update group by class
+ overlay->grp->clas = clas;
+ _overlay_group_icon_update(overlay->grp, clas_ovl->icon);
+ _overlay_group_content_update(overlay->grp, clas_ovl->content);
+ _overlay_group_color_update(overlay->grp, clas->c);
+ _overlay_group_cb_set(overlay->grp, clas->cb, clas->data);
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ {
+ _overlay_default_clas_icon_update(overlay->ovl, clas_ovl->icon);
+ _overlay_default_clas_content_update(overlay->ovl, clas_ovl->content);
+ }
-static char *
-_custom4_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
-{
- return strdup("");
+ evas_object_smart_changed(clas->wd->pan_smart);
+#else
+ (void) clas;
+ (void) overlay;
+#endif
}
-static char *
-_custom5_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
+EAPI void
+elm_map_overlay_class_remove(Elm_Map_Overlay *clas, Elm_Map_Overlay *overlay)
{
- return strdup("");
-}
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(clas);
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ EINA_SAFETY_ON_NULL_RETURN(clas->wd);
+ ELM_CHECK_WIDTYPE(clas->wd->obj, widtype);
+ EINA_SAFETY_ON_FALSE_RETURN(clas->type == ELM_MAP_OVERLAY_TYPE_CLASS);
+
+ Overlay_Class *ovl = clas->ovl;
+ ovl->members = eina_list_remove(ovl->members, overlay);
+
+ overlay->grp->clas = NULL;
+ _overlay_group_icon_update(overlay->grp, NULL);
+ _overlay_group_content_update(overlay->grp, NULL);
+ if (overlay->type == ELM_MAP_OVERLAY_TYPE_DEFAULT)
+ {
+ _overlay_default_clas_icon_update(overlay->ovl, NULL);
+ _overlay_default_clas_content_update(overlay->ovl, NULL);
+ }
-static char *
-_custom6_url_cb(Evas_Object *obj __UNUSED__, int x __UNUSED__, int y __UNUSED__, int zoom __UNUSED__)
-{
- return strdup("");
+ evas_object_smart_changed(clas->wd->pan_smart);
+#else
+ (void) clas;
+ (void) overlay;
+#endif
}
-static char *
-_module_url_cb(Evas_Object *obj, int x, int y, int zoom)
+EAPI void
+elm_map_overlay_class_zoom_max_set(Elm_Map_Overlay *clas, int zoom)
{
- char *buf = NULL;
- Widget_Data *wd = elm_widget_data_get(obj);
- if (elm_map_source_get(obj) == ELM_MAP_SOURCE_MODULE)
- if ((wd->api) && (wd->api->obj_url_request))
- buf = wd->api->obj_url_request(obj, x, y, zoom);
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(clas);
+ EINA_SAFETY_ON_NULL_RETURN(clas->wd);
+ ELM_CHECK_WIDTYPE(clas->wd->obj, widtype);
+ EINA_SAFETY_ON_FALSE_RETURN(clas->type == ELM_MAP_OVERLAY_TYPE_CLASS);
- if (!buf) buf = strdup("");
+ Overlay_Class *ovl = clas->ovl;
+ if (ovl->zoom_max == !!zoom) return;
+ ovl->zoom_max = zoom;
- return buf;
+ evas_object_smart_changed(clas->wd->pan_smart);
+#else
+ (void) clas;
+ (void) zoom;
+#endif
}
-static char *_yours_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
+EAPI int
+elm_map_overlay_class_zoom_max_get(const Elm_Map_Overlay *clas)
{
- char buf[PATH_MAX];
- snprintf(buf, sizeof(buf),
- "%s?flat=%lf&flon=%lf&tlat=%lf&tlon=%lf&v=%s&fast=%d&instructions=1",
- ROUTE_YOURS_URL, flat, flon, tlat, tlon, type_name, method);
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(clas, OVERLAY_CLASS_ZOOM_MAX);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(clas->wd, OVERLAY_CLASS_ZOOM_MAX);
+ ELM_CHECK_WIDTYPE(clas->wd->obj, widtype) OVERLAY_CLASS_ZOOM_MAX;
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(clas->type == ELM_MAP_OVERLAY_TYPE_CLASS, OVERLAY_CLASS_ZOOM_MAX);
- return strdup(buf);
+ const Overlay_Class *ovl = clas->ovl;
+ return ovl->zoom_max;
+#else
+ (void) clas;
+ return OVERLAY_CLASS_ZOOM_MAX;
+#endif
}
-// TODO: fix monav api
-/*
-static char *_monav_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
+EAPI Eina_List *
+elm_map_overlay_group_members_get(const Elm_Map_Overlay *grp)
{
- char buf[PATH_MAX];
- snprintf(buf, sizeof(buf),
- "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
- ROUTE_MONAV_URL, flat, flon, tlat, tlon, type_name, method);
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN_VAL(grp, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(grp->wd, NULL);
+ ELM_CHECK_WIDTYPE(grp->wd->obj, widtype) NULL;
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(grp->type == ELM_MAP_OVERLAY_TYPE_GROUP, NULL);
- return strdup(buf);
+ Overlay_Group *ovl = grp->ovl;
+ return ovl->members;
+#else
+ (void) clas;
+ return OVERLAY_CLASS_ZOOM_MAX;
+#endif
}
-*/
-// TODO: fix ors api
-/*
-static char *_ors_url_cb(Evas_Object *obj __UNUSED__, char *type_name, int method, double flon, double flat, double tlon, double tlat)
+EAPI Elm_Map_Overlay *
+elm_map_overlay_bubble_add(Evas_Object *obj)
{
- char buf[PATH_MAX];
- snprintf(buf, sizeof(buf),
- "%s?flat=%f&flon=%f&tlat=%f&tlon=%f&v=%s&fast=%d&instructions=1",
- ROUTE_ORS_URL, flat, flon, tlat, tlon, type_name, method);
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+
+ Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
+ overlay->wd = wd;
+ overlay->type = ELM_MAP_OVERLAY_TYPE_BUBBLE;
+ overlay->c.r = 255;
+ overlay->c.g = 255;
+ overlay->c.b = 255;
+ overlay->c.a = 255;
+ overlay->ovl = _overlay_bubble_new(overlay);
+ overlay->grp = _overlay_group_new(wd);
+ wd->overlays = eina_list_append(wd->overlays, overlay);
- return strdup(buf);
+ evas_object_smart_changed(wd->pan_smart);
+ return overlay;
+#else
+ (void) obj;
+ return NULL;
+#endif
}
-*/
-static char *_route_custom1_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
+EAPI void
+elm_map_overlay_bubble_follow(Elm_Map_Overlay *bubble, const Elm_Map_Overlay *parent)
{
- return strdup("");
-}
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ EINA_SAFETY_ON_NULL_RETURN(parent);
+ ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype);
+ EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
-static char *_route_custom2_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
-{
- return strdup("");
+ Overlay_Bubble *ovl = bubble->ovl;
+ Evas_Object *pobj = _overlay_obj_get(parent);
+ if (!pobj) return;
+
+ if (ovl->pobj)
+ {
+ evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_HIDE,
+ _overlay_bubble_hide_cb, ovl);
+ evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_SHOW,
+ _overlay_bubble_chase_cb, ovl);
+ evas_object_event_callback_del_full(ovl->pobj, EVAS_CALLBACK_MOVE,
+ _overlay_bubble_chase_cb, ovl);
+ }
+
+ ovl->pobj = pobj;
+ evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_HIDE,
+ _overlay_bubble_hide_cb, ovl);
+ evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_SHOW,
+ _overlay_bubble_chase_cb, ovl);
+ evas_object_event_callback_add(ovl->pobj, EVAS_CALLBACK_MOVE,
+ _overlay_bubble_chase_cb, ovl);
+
+ _overlay_bubble_chase(ovl);
+ evas_object_smart_changed(bubble->wd->pan_smart);
+#else
+ (void) bubble;
+ (void) parent;
+#endif
}
-static char *_route_custom3_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
+EAPI void
+elm_map_overlay_bubble_content_append(Elm_Map_Overlay *bubble, Evas_Object *content)
{
- return strdup("");
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ EINA_SAFETY_ON_NULL_RETURN(content);
+ ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype);
+ EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
+
+ Overlay_Bubble *bb = bubble->ovl;
+ elm_box_pack_end(bb->bx, content);
+
+ evas_object_smart_changed(bubble->wd->pan_smart);
+#else
+ (void) bubble;
+ (void) content;
+#endif
}
-static char *_route_custom4_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
+EAPI void
+elm_map_overlay_bubble_content_clear(Elm_Map_Overlay *bubble)
{
- return strdup("");
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(bubble);
+ ELM_CHECK_WIDTYPE(bubble->wd->obj, widtype);
+ EINA_SAFETY_ON_FALSE_RETURN(bubble->type == ELM_MAP_OVERLAY_TYPE_BUBBLE);
+
+ Overlay_Bubble *bb = bubble->ovl;
+ elm_box_clear(bb->bx);
+
+ evas_object_smart_changed(bubble->wd->pan_smart);
+#else
+ (void) bubble;
+#endif
}
-static char *_route_custom5_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
+EAPI Elm_Map_Overlay *
+elm_map_overlay_route_add(Evas_Object *obj, const Elm_Map_Route *route)
{
- return strdup("");
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(route, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(route->wd, NULL);
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(obj == route->wd->obj, NULL);
+
+ Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
+ overlay->wd = wd;
+ overlay->type = ELM_MAP_OVERLAY_TYPE_ROUTE;
+ overlay->c.r = 0xff;
+ overlay->c.g = 0x00;
+ overlay->c.b = 0x00;
+ overlay->c.a = 0xff;
+ overlay->ovl = _overlay_route_new(wd, route, overlay->c);
+ overlay->grp = _overlay_group_new(wd);
+ wd->overlays = eina_list_append(wd->overlays, overlay);
+
+ evas_object_smart_changed(wd->pan_smart);
+ return overlay;
+#else
+ (void) obj;
+ (void) route;
+ return NULL;
+#endif
}
-static char *_route_custom6_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
+EAPI Elm_Map_Overlay *
+elm_map_overlay_line_add(Evas_Object *obj, double flon, double flat, double tlon, double tlat)
{
- return strdup("");
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+
+ Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
+ overlay->wd = wd;
+ overlay->type = ELM_MAP_OVERLAY_TYPE_LINE;
+ overlay->c.r = 0xff;
+ overlay->c.g = 0x00;
+ overlay->c.b = 0x00;
+ overlay->c.a = 0xff;
+ overlay->ovl = _overlay_line_new(wd, flon, flat, tlon, tlat, overlay->c);
+ overlay->grp = _overlay_group_new(wd);
+ wd->overlays = eina_list_append(wd->overlays, overlay);
+
+ evas_object_smart_changed(wd->pan_smart);
+ return overlay;
+#else
+ (void) obj;
+ (void) flon;
+ (void) flat
+ (void) tlon;
+ (void) tlat;
+ return NULL;
+#endif
}
-/*
-static char *_route_module_url_cb(Evas_Object *obj __UNUSED__, char *type_name __UNUSED__, int method __UNUSED__, double flon __UNUSED__, double flat __UNUSED__, double tlon __UNUSED__, double tlat __UNUSED__)
+
+EAPI Elm_Map_Overlay *
+elm_map_overlay_polygon_add(Evas_Object *obj)
{
- // TODO: make example route module
- return strdup("");
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+
+ Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
+ overlay->wd = wd;
+ overlay->type = ELM_MAP_OVERLAY_TYPE_POLYGON;
+ overlay->c.r = 0xdc;
+ overlay->c.g = 0x14;
+ overlay->c.b = 0x3c;
+ overlay->c.a = 200;
+ overlay->ovl = _overlay_polygon_new(wd, overlay->c);
+ overlay->grp = _overlay_group_new(wd);
+ wd->overlays = eina_list_append(wd->overlays, overlay);
+ evas_object_smart_changed(wd->pan_smart);
+ return overlay;
+#else
+ (void) obj;
+ return NULL;
+#endif
}
-*/
-static char *
-_nominatim_url_cb(Evas_Object *obj, int method, char *name, double lon, double lat)
+EAPI void
+elm_map_overlay_polygon_region_add(Elm_Map_Overlay *overlay, double lon, double lat)
{
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return strdup("");
- char **str;
- unsigned int ele, idx;
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EINA_SAFETY_ON_NULL_RETURN(overlay);
+ ELM_CHECK_WIDTYPE(overlay->wd->obj, widtype);
+ EINA_SAFETY_ON_FALSE_RETURN(overlay->type == ELM_MAP_OVERLAY_TYPE_POLYGON);
- char search_url[PATH_MAX];
- char buf[PATH_MAX];
- if (method == ELM_MAP_NAME_METHOD_SEARCH)
- {
- search_url[0] = '\0';
- str = eina_str_split_full(name, " ", 0, &ele);
- for (idx = 0 ; idx < ele ; idx++)
- {
- eina_strlcat(search_url, str[idx], sizeof(search_url));
- if (!(idx == (ele-1))) eina_strlcat(search_url, "+", sizeof(search_url));
- }
- snprintf(buf, sizeof(buf), "%s/search?q=%s&format=xml&polygon=0&addressdetails=0", NAME_NOMINATIM_URL, search_url);
- }
- else if (method == ELM_MAP_NAME_METHOD_REVERSE) snprintf(buf, sizeof(buf), "%s/reverse?format=xml&lat=%lf&lon=%lf&zoom=%d&addressdetails=0", NAME_NOMINATIM_URL, lat, lon, wd->zoom);
- else strcpy(buf, "");
+ Overlay_Polygon *ovl = overlay->ovl;
+ Region *r = ELM_NEW(Region);
+ r->lon = lon;
+ r->lat = lat;
+ ovl->regions = eina_list_append(ovl->regions, r);
- return strdup(buf);
+ evas_object_smart_changed(ovl->wd->pan_smart);
+#else
+ (void) overlay;
+ (void) lon;
+ (void) lat
+ #endif
}
-static char *
-_name_custom1_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
+EAPI Elm_Map_Overlay *
+elm_map_overlay_circle_add(Evas_Object *obj, double lon, double lat, double radius)
{
- return strdup("");
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+
+ Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
+ overlay->wd = wd;
+ overlay->type = ELM_MAP_OVERLAY_TYPE_CIRCLE;
+ overlay->c.r = 0xdc;
+ overlay->c.g = 0x14;
+ overlay->c.b = 0x3c;
+ overlay->c.a = 200;
+ overlay->ovl = _overlay_circle_new(wd, lon, lat, radius, overlay->c);
+ overlay->grp = _overlay_group_new(wd);
+ wd->overlays = eina_list_append(wd->overlays, overlay);
+
+ evas_object_smart_changed(wd->pan_smart);
+ return overlay;
+#else
+ (void) obj;
+ return NULL;
+#endif
}
-static char *
-_name_custom2_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
+EAPI Elm_Map_Overlay *
+elm_map_overlay_scale_add(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
{
- return strdup("");
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, NULL);
+
+ Elm_Map_Overlay *overlay = ELM_NEW(Elm_Map_Overlay);
+ overlay->wd = wd;
+ overlay->type = ELM_MAP_OVERLAY_TYPE_SCALE;
+ overlay->c.r = 0;
+ overlay->c.g = 0;
+ overlay->c.b = 0;
+ overlay->c.a = 255;
+ overlay->ovl = _overlay_scale_new(wd, x, y, overlay->c);
+ overlay->grp = _overlay_group_new(wd);
+ wd->overlays = eina_list_append(wd->overlays, overlay);
+
+ evas_object_smart_changed(wd->pan_smart);
+ return overlay;
+#else
+ (void) obj;
+ return NULL;
+#endif
}
-static char *
-_name_custom3_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
+#ifdef ELM_EMAP
+EAPI Evas_Object *
+elm_map_track_add(Evas_Object *obj, void *emap)
{
- return strdup("");
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ EMap_Route *emapr = emap;
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(wd, EINA_FALSE);
+
+ Evas_Object *route = elm_route_add(obj);
+ elm_route_emap_set(route, emapr);
+ wd->track = eina_list_append(wd->track, route);
+
+ return route;
+#else
+ (void) obj;
+ (void) emap;
+ return NULL;
+#endif
}
-static char *
-_name_custom4_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
+EAPI void
+elm_map_track_remove(Evas_Object *obj, Evas_Object *route)
{
- return strdup("");
-}
+#ifdef HAVE_ELEMENTARY_ECORE_CON
+ ELM_CHECK_WIDTYPE(obj, widtype) ;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ EINA_SAFETY_ON_NULL_RETURN(wd);
-static char *
-_name_custom5_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
+ wd->track = eina_list_remove(wd->track, route);
+ evas_object_del(route);
+#else
+ (void) obj;
+ (void) route;
+#endif
+}
+#else
+EAPI Evas_Object *
+elm_map_track_add(Evas_Object *obj __UNUSED__, void *emap __UNUSED__)
{
- return strdup("");
+ return NULL;
}
-static char *
-_name_custom6_url_cb(Evas_Object *obj __UNUSED__, int method __UNUSED__, char *name __UNUSED__, double lon __UNUSED__, double lat __UNUSED__)
+EAPI void
+elm_map_track_remove(Evas_Object *obj __UNUSED__, Evas_Object *route __UNUSED__)
{
- return strdup("");
}
-
+#endif