I've created an generic CCK based MapAPI for a personal project that allows you to configure and switch map rendering engines (google, yahoo implemented so far), and I would love to tie this in with Geo, but I'm finding this very difficult.

Considering all that I need is to store points in the database, is it possible to do something like this:

<?php

/**
* Implementation of hook_field_settings().
*/
function smap_field_settings($op, $field) {
  switch ($op) {
    case 'database columns':
       // get geo columns - only care about point currently
       return merge(geo, smap columns);
    case 'views data':
       // only geo fields would require views support
       return geo_field_field_settings($op, $field);
  }
}

/**
* Implementation of hook_field().
*/
function smap_field($op, &$node, $field, &$items, $teaser, $page) {
  switch ($op) {
    case 'presave':
      // ??
    case 'load:
     // ??
  }
}
?>

Thanks in advance

CommentFileSizeAuthor
#3 smap3.gif62.1 KBalan d.
#2 smap.gif24.62 KBalan d.
#2 smap2.gif16.76 KBalan d.

Comments

allie micka’s picture

I encourage you to use the existing Openlayers or Mapstraction modules rather than duplicating efforts with these.

That said, unless you're storing data in your field beyond what's in Geo, you probably want to implement a widget for Geo and not a field. That way you can just let Geo do its Geo thing and handle the input configuration on your own.

alan d.’s picture

StatusFileSize
new16.76 KB
new24.62 KB

K, here is some background. I'm already seeing the need to split it into two main parts, so the first part is not relevant to the request.

1) The main rendering engine:

The map functionality is abstracted out into into map / container / icons etc. Sort of like Mapstraction with configuration. More along the lines of the WYSIWYG project for maps. I think that there are about 20 settings implemented so far - show pan, show nav control settings, show scale, ..., nav control type, etc. This level of control is needed as I'm going to end up with about 7 map types in the idea system for the project that I'm running. Different providers have different coverage, particularly the sat images in remote areas.

The actual physical implementation of a provider is then a fairly trivial task, I think that the google part is about 200 lines of code to implement the settings (API key), map rendering with settings, custom icons and bounding box. Yahoo was about 225 lines.

With this abstraction, it was easy to implement an additional marker icons and assign these to whatever map that uses the custom icons.

2) The new field.

Right as explained above, this was just a simple lat/long/icon/zoom + additional data element (tooltip, info window details, jscript actions), with the exception of data field, this is completely implemented. I will abstract out the data field similar to the filefield module (in the filefield module, this serialized array is used for alt, title, description). The attachment shows this in action. the first three inputs lat/lng/zoom are hooked up to an input map.

This data is at the CCK field level.

The widget level defines the actual map configuration required when you use the default map formatter display. The second attachment shows this in action.

So back to the two questions:

Can I easily move the numeric lat / long db fields into a geo point database field? And if so can I integrate this easily into the views?

My gut feel is to do this myself and drop view support. Doing this would mean that it would never be shared back to the community.

alan d.’s picture

StatusFileSize
new62.1 KB

And a screen shot of it in action using random points / icons, using default Map display formatter.

alan d.’s picture

Status: Active » Closed (fixed)

Too custom now to think about releasing.