user1592211
user1592211

Reputation: 81

Pass variable from python to javascript

i have to variables xx = 38.929787 yy = 22.675781

how can i pass them from python to GLatLng(lat,long) inside the javascript an have lat = xx and long =yy

def pymapjs(self):
        """ Returns complete javacript for rendering map """

self.js = """\n<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;key=%s\" type="text/javascript"></script>
        <script type="text/javascript">

        //<![CDATA[
        function load() {
            if (GBrowserIsCompatible()) {


            function Point(lat,long,html,icon) {
                  this.gpoint = new GMarker(new GLatLng(lat,long),icon);
                  this.html = html;

               }  

Upvotes: 0

Views: 198

Answers (1)

Josip Grggurica
Josip Grggurica

Reputation: 421

Do this:

self.js = """\n<script src=\"http://maps.google.com/maps?file=api&amp;v=2&amp;key=%s\" type="text/javascript"></script>
    <script type="text/javascript">

    //<![CDATA[
    function load() {
        if (GBrowserIsCompatible()) {


        function Point(lat,long,html,icon) {
              this.gpoint = new GMarker(new GLatLng(%f,%f),icon);
              this.html = html;

           }""" % (xx, yy)

Upvotes: 1

Related Questions