Hello, I'm writing a module where i must load map my AJAX. my code work fine, and map are loaded, but not themized into page. I see only Javascript is required to view this map..
This is some extract of my code:
function mymodule_menu($may_cache) {
$items = array();
if (!$may_cache) { //remove ! once debug is overn
$items[] = array(
'path' => 'mymodule/map',
'callback' => '_mymodule_map',
'type' => CALLBACK,
'access' => true, //give appropriate permissions
);
}
return $items;
}
function _mymodule_map() {
$map = array(
'id' => 'mymodule_1',
'maptype' => 'Map',
'width' => '400px',
'height' => '400px',
'latitude' => 12.345,
'longitude' => 12.345,
'zoom' => 4,
'align' => 'left',
'controltype' => 'Large',
'mtc' => 'standard',
'behavior' => array(
'locpick' => FALSE,
'nodrag' => FALSE,
'nokeyboard' => TRUE,
'overview' => TRUE,
'scale' => TRUE,
),
'markers' => array(),
);
$output .= theme('gmap', array('#settings' => $map));
print $output;
exit();
}
and into JS:
$(document).ready(function () {
$.get(
'/mymodule/map',
{},
function (data) {
$('#showMap').html(data);
}
)
});
into div with id showMap code appair correctly:
<div id="gmap-mymodule_1-gmap0" style="width: 400px; height: 400px;" class="0gmap gmap-map gmap-mymodule_1-gmap"
id="gmap-mymodule_1-gmap0">Javascript is required to view this map.</div><script type="text/javascript"
>
/* <![CDATA[ */
Drupal.extend({ settings: { "gmap": { "mymodule_1": { "width": "400px", "height": "400px", "zoom"
: 4, "maxzoom": "17", "controltype": "Large", "align": "left", "maptype": "Map", "mtc": "standard", "baselayers"
: { "maptype": "Map", "Map": 1 }, "styles": { "line_default": [ "0000ff", "5", "45", null, null ], "poly_default"
: [ "000000", "3", "25", "ff0000", "45" ] }, "line_colors": [ "#00cc00", "#ff0000", "#0000ff" ], "behavior"
: { "locpick": false, "nodrag": false, "nokeyboard": true, "overview": true, "scale": true }, "markermode"
: "0", "id": "location_cck_1", "latitude": 12.345, "longitude": 12.345, "markers": [ ] } } } });
/* ]]> */
</script>
but map don't appair. I thik is a problem about JS, gmap don't load map because code is loaded after gmap.js ready function, someone can help me and suggest what's the function i must call to show map?
tks
Mavimo
Comments
Comment #1
mavimo commentedPS. if I insert map into $form all work fine.
Comment #2
mavimo commentedI find the solution (IMHO not the best solution), I'm adding this into JS after code map inectjon:
Drupal.gmap.setup()bye
Mavimo
Comment #3
Will Igetit commentedHello,
I am facin the same problem and I jsut don't really get where the injection occurs could you please tell where more pointedly?
Thanks in advance,
Will
Comment #4
podarokrelease unsupported
feel free to open issue against latest 7.x dev