Viktors
Viktors

Reputation: 935

Google map problem

I have google map javascript code

      $(document).ready(function() {

        var zoom = 16; // zoom level
        var latitude = $('#latitude').text(); //latitude
        var longitude = $('#longitude').text(); //longitude
        var map_description = $('#map_description').text();





          if (GBrowserIsCompatible()) { // if the browser is compatible with Google Map's
              var map = document.getElementById("myMap"); // Get div element
              var m = new GMap2(map); // new instance of the GMap2 class and pass in our div location.


              m.setCenter(new GLatLng(latitude, longitude), zoom);


              m.openInfoWindow(m.getCenter(), map_description); // displays the text
              m.setMapType(G_SATELLITE_MAP); // sets the default mode. G_NORMAL_MAP, G_HYBRID_MAP

              var c = new GMapTypeControl(); // switch map modes
              m.addControl(c);

              m.addControl(new GLargeMapControl()); // creates the zoom feature
          }
          else {
              alert("Upgrade your browser, man!");

          }
      });

and problem is that I can't out data "zoom" from javascript. I want to locate data in html file. I already make it with latitude, longitude, description

var zoom = $('#zoom').text(); //zoom

<div id='zoom'>16</div>

and this do not wark. Can somebody halp me to solve this problem?

Upvotes: 0

Views: 120

Answers (1)

kwicher
kwicher

Reputation: 2082

I think you need to parse zoom to Integer value e.g.:

var zoom=parseInt($('zoom').text());

Upvotes: 2

Related Questions