Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Cool Why do I have a JavaScript error when declaring this variable?

    I am using WaveMaker 6.5.3 and have adapted the following code from Google and have a map rendering successfully. But when I add the variables "geocoder" and "map", as shown in the google example, I get a red x error next to "var geocoder". The google example code is here: https://developers.google.com/maps/d...es/geocoding-s...

    It seems that there is a simple problem with my syntax within Wavemaker. Any thoughts on why this is not working? I do have the maps api referenced in my header. Thanks!

    [CODE]
    dojo.declare("Main", wm.Page, {
    start: function() {
    },
    "preferredDevice": "desktop",

    var geocoder; //Studiio shows a red x error here??
    var map;

    showMapButtonClick: function(inSender) {
    geocoder = new google.maps.Geocoder();
    var mapOptions = {
    zoom: 6,
    center: new google.maps.LatLng(49.265984,-123.127491),
    mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    var map = new google.maps.Map(document.getElementById('main_weatherHtml'),
    mapOptions);

    var weatherLayer = new google.maps.weather.WeatherLayer({
    temperatureUnits: google.maps.weather.TemperatureUnit.FAHRENHEIT
    });
    weatherLayer.setMap(map);

    var cloudLayer = new google.maps.weather.CloudLayer();
    cloudLayer.setMap(map);
    },

    codeAddressButtonClick: function(inSender) {
    //var address = document.getElementById('main_addressBox').value;
    //var address = this.addressBox.dataValue;
    geocoder.geocode( { 'address': address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
    map.setCenter(results[0].geometry.location);
    var marker = new google.maps.Marker({
    map: map,
    position: results[0].geometry.location
    });
    } else {
    alert('Geocode was not successful for the following reason: ' + status);
    }
    });
    },

    _end: 0
    });
    [CODE]

  • #2
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Code:
    dojo.declare("Main", wm.Page, {
    start: function() {
    },
    "preferredDevice": "desktop",
    
    var geocoder; //Studiio shows a red x error here??
    Your var statement is preceded by an incomplete object definition.

  • Users who have thanked Logic Ali for this post:

    creedifee (11-06-2013)

  • #3
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks Logic Ali!

    I have now found that in wavemaker it works of the variables are declared without "var" to make them globally available. I then omitted the global declarations that were the problem. Seems wavemaker handles things a little different.
    Last edited by creedifee; 11-06-2013 at 01:45 AM.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •