django项目中gogoleMap键的全局变量

时间:2017-02-08 11:15:38

标签: javascript django google-maps

我需要在几页中打开我的gmap:

cModule* parentmod = getParentModule();
int nodeVectorIndex = index;
if (!parentmod) error("Parent Module not found");

cModuleType* nodeType = cModuleType::get(type);
if (!nodeType) error("Module Type \"%s\" not found", type);

//TODO: this trashes the vectsize member of the cModule, although nobody seems to use it
cModule* mod = nodeType->create(name, parentmod, nodeVectorIndex, nodeVectorIndex);
mod->finalizeParameters();
mod->buildInside();
mod->scheduleStart(simTime());

if (setCoor)
{
    MobilityBase* mm = NULL;
    for (cModule::SubmoduleIterator iter(mod); !iter.end(); iter++) {
        cModule* submod = iter();
        mm = dynamic_cast<MobilityBase*>(submod);
        if (!mm)
            continue;
        mm->par("initialX").setDoubleValue(position.x);
        mm->par("initialY").setDoubleValue(position.y);
        mm->par("initialZ").setDoubleValue(position.z);
        break;
    }
    if (!mm)
        error("Mobility modele not found");
}
NodeInf info;
info.endLife = endLife;
info.module = mod;
nodeList[index] = info;
mod->callInitialize();

有时键过期。在我拥有的每个html文件中更改密钥真的很烦人。也许我可以制作一些全局变量并将密钥存储在那里?有什么建议吗?

1 个答案:

答案 0 :(得分:0)

把它放在你的settings.py

TEMPLATES[0]['OPTIONS']['context_processors'].append("API_KEY : YOUR_API_KEY")

然后在模板上使用{{API_KEY}}作为变量。了解更多信息: Django - How to make a variable available to all templates?