CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Usability Improvements (Moderator: Dave Greenberg) »
  • Change to gmap (custom markers)
Pages: [1]

Author Topic: Change to gmap (custom markers)  (Read 5473 times)

goran

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
Change to gmap (custom markers)
March 10, 2010, 08:00:03 am
Hello,

I was making some changes to the way google maps work for my own project and the results looked interesting to be included back in main. What I ended up doing is using custom markers for map icons (screenshots at http://picasaweb.google.com/goran.gugic/DropBox# )

While I am at it - completing the code and fixing the icons (need to add shadows and fix the individual icon which has some white pixels among the transparent ones) I will also change the default map type for multiple results.

When discussing this on irc people I was asked about changing the size of the map and default zoom level (makes sense only when mapping a single contact IMHO). Don't know exactly what is wrong with the size (height of 600px and width of 100% of available space works pretty well in most cases I've seen), but the default zoom level is something I could change.
I am _not_ thinking about adding a configuration options for this just simply changing the current zoom level to a 'more reasonable' one.

So if anyone has comments re proposed changes:
- using icons instead of gmap markers,
- fixing default individual icon (transpareny),
- creating shadow images for these,
- changing default map style to terrain when mapping a set of locations,
- changing default zoom level when mapping a single location to more zoomed out
do let me know

Resources used (if anyone is interested in google maps, it's a complete example, custom markes are towards the end):
http://code.google.com/apis/maps/articles/phpsqlajax.html

Created issue: CRM-5943
« Last Edit: March 10, 2010, 08:08:09 am by goran »

TallDavid

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 2
    • ATO Zeta Mu Alumni
  • CiviCRM version: 3.4.8
  • CMS version: Drupal 6.22
  • MySQL version: 5.1.52
  • PHP version: 5.2.13
Re: Change to gmap (custom markers)
March 10, 2010, 08:10:30 am
It sounds like these items are outside of the planned changes, but, I'd like to see the size, zoom level and terrain type be user configurable.  There are cases, such as displaying a map for a CiviEvent, where these items need to be customized in order to display a useful map view.

goran

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
Re: Change to gmap (custom markers)
March 10, 2010, 08:59:25 am
Maybe there is something that can be done within the scope of what I am doing

Can you describe the use case? (because if time permits I might check out adding configuration options - but it sounds that you are saying that the values would not be system wide, but would depend on the use - CiviEvent being different then the rest).

All things GIS tend to get complicated fairly quickly - for example default zoom level for a single location:
If it is in urban area you would probably be happier with a different zoom then in rural/remote. And that is not trivial.

As for practical solution right now the changes are simple - take a look at civicrm/templates/CRM/Contact/Form/Task/Map/Google.tpl

You can change width and height in lines 27 to 31 (it is straightforward, EDIT {if $showDirectly} is the one used for Events).

The line 91 sets the zoom... having it be nice for both a set of locations and for a single location you'd do something along
Code: [Select]
     {if count($locations) gt 1}  
 map.setZoom(map.getBoundsZoomLevel(bounds));
      {else}
 map.setZoom(15);
      {/if}

instead of
Code: [Select]
map.setZoom(map.getBoundsZoomLevel(bounds));
« Last Edit: March 10, 2010, 03:03:31 pm by goran »

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Change to gmap (custom markers)
March 10, 2010, 01:36:15 pm
Would it be easy to extend so we can set different icons per contact ?

eg:
- different for male or female
- dem/rep
- how much he has donated...

(haven't looked at the code, but if this is easily hookable, that'd come handy)
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

goran

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
Re: Change to gmap (custom markers)
March 10, 2010, 02:14:44 pm
Well I am thinking along those lines... (and a bit further, for example too leave the door open for civiReport integration). Both things out of the scope of this particular change, still here are the details:

The gmap is created in js in Google.tpl from varibale locations passed to it.
What I'll do is to extend the locations to include, apart from lat, log and other things, a property called marker_class.

Then I'll try to have another list passed called markers with values found in marker_class and for each value an icon and other info that gmap needs.

Currently what will come in the locations from getMapInfo is contact_type (Individual, Household, Organization or Event).
And currently what will come in the markers is the properties of markers for each of those types.

However, while satisfying requirement to support the upcoming custom contacts, by having a flexible markers structure at all, now it should not be hard to put some other value in marker_class passed to template and, of course, compose corresponding markers structure that would match the values in marker_class...

For the markers structure easy way would be to use generic icons
see: http://code.google.com/apis/maps/documentation/overlays.html#Markers
and example: http://code.google.com/apis/maps/documentation/examples/icon-custom.html

However I will not be doing that at the moment (integrating with searches and providing mechanisms to specify which field should be used to populate marker_class, or with reports, etc...).

Don't know if all that could be done with hooks, I am new to contributing/changing the way civicrm works and know very little about hooks (but if getMapInfo in CRM/Contact/BAO/Contact/Location.php and /CRM/Event/BAO/Event.php is 'easily hookable' then the answer is yes :) )

TravelingPharaoh

  • I post occasionally
  • **
  • Posts: 39
  • Karma: 3
    • Traveling journey of a developer
  • CiviCRM version: 4.1.2
  • CMS version: Drupal 7
Re: Change to gmap (custom markers)
March 24, 2010, 07:14:23 am
I would like to see an optional zoom property.  We have events that are outside the US, and normally our location doesn't have good street zoom level, but its ok at city level zoom or higher. 

Quote from: goran on March 10, 2010, 08:59:25 am
Maybe there is something that can be done within the scope of what I am doing

Can you describe the use case? (because if time permits I might check out adding configuration options - but it sounds that you are saying that the values would not be system wide, but would depend on the use - CiviEvent being different then the rest).

All things GIS tend to get complicated fairly quickly - for example default zoom level for a single location:
If it is in urban area you would probably be happier with a different zoom then in rural/remote. And that is not trivial.

As for practical solution right now the changes are simple - take a look at civicrm/templates/CRM/Contact/Form/Task/Map/Google.tpl

You can change width and height in lines 27 to 31 (it is straightforward, EDIT {if $showDirectly} is the one used for Events).

The line 91 sets the zoom... having it be nice for both a set of locations and for a single location you'd do something along
Code: [Select]
     {if count($locations) gt 1}  
 map.setZoom(map.getBoundsZoomLevel(bounds));
      {else}
 map.setZoom(15);
      {/if}

instead of
Code: [Select]
map.setZoom(map.getBoundsZoomLevel(bounds));

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Usability Improvements (Moderator: Dave Greenberg) »
  • Change to gmap (custom markers)

This forum was archived on 2017-11-26.