Download & Extend

Possible to specify different map size, zoom level, center in views?

Project:GMap Module
Version:5.x-1.x-dev
Component:User interface
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

At the moment views gives me the map size specified in gmap settings - small because I like the field small for my users when choosing locations on the map in content type forms. Otherwise it overwhelms the form.

Is it possible to alter the size of gmaps in views so that they are bigger than my defaut setting which I need for my content type forms?

Comments

#1

Put a gmap macro in the views argument handling code, something like:

<?php
$view
->gmap_macro = "[gmap |width=100% |height=300px]";
?>

(remember - don't include the php tags)

#2

Status:active» fixed

#3

That is great. Thanks! ...any way to assign color of the balloons by content type in that macro code?

#4

I've never found a way to change the color of the balloons. They're pretty much set by the Google Maps API. With CSS you can style what's inside the white bubble, but that's pretty much it. To have custom info-windows/bubbles you'd need to do a lot of custom coding. There's an example of how to do it at http://danmarvelo.us/older/2007/9/10/custom-info-window-for-google/ but it would take a good understanding of the GMap module to bring this into Drupal.

#5

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

#6

nice. then if we can put gmap macro in the views argument handling code, we also add zoom level as well. done.

Then, we could also specify a center for each term, and let the views put the center dynamically? or even zoom level dynamically depending on the term?

Gmap taxonomy support, only allow different marker for terms. not setting center, and zoom level. Maybe use taxonomy fields, and query directly from there?

Say for country zoom=3, state zoom zoom=8, I also need to specify the center too.

#7

Title:Possible to specify different map size in views?» Possible to specify different map size, zoom level, center in views?

#8

Does anyone know how to do this in views2?

It seems that the "argument handling code" field is gone and replaced with php validators per field.

I know that we can put gmap macro's for the entire view, but I would like to change the center point based on a views argument (more specifically a postal code -> lat/long lookup for my center point).

The end goal is to implement a postcode argument which is ONLY used to center the map - it will not be used as an argument to reduce the number of matching nodes. My plan was to return FALSE in the php validator and have it set to "display all values", but in the validator code I would reset the gmap macro. But nothing seems to happen - my gmap macro is ignored.

#9

As far as I know it is just the macro setting for the entire view.

Having the ability to have a dynamic macro setting would be a new feature request.
Best to open a new issue for that.

#10

Using the code from #1 set the width but not the height (Views 6.x-2.10, Gmap 6.x-1.x-dev) until I inserted an extra semi-colon. Don't understand why just thought I'd share:

<?php
$view
->gmap_macro = "[gmap |width=100% |height=300px;]";
?>

#11

Thank you very much for the example, it saved me after 3 days of hair pulling!

#12

See also #954384: How to alter gmap macro with php for a different approach, allowing php to alter the GMAP macro.

#13

Please, where exactly did you put this code?

Thank you.

#14

@mttjn, after you create a View (Type Node) you set the Style to GMap. Then click on the gear image to the right of the GMap style to adjust the settings and place the mentioned code into the Macro field.

FWIW, I precede the above code with [gmap] in the macro field.

#15

@kbk Thank you! :)

nobody click here