jbdemonte / gmap3

jQuery plugin to create Google maps
http://gmap3.net
668 stars 198 forks source link

Instance of google map seems to be lost #131

Closed Drachenfels closed 7 years ago

Drachenfels commented 7 years ago
$('.map')
.gmap3({
    center: {lat: 50, lng: 0},
    zoom: 13,
    mapTypeId : google.maps.MapTypeId.ROADMAP
})
.then(function(gMap) {
    console.log(gMap.getZoom())
})
.marker({
    position: {lat: 51, lng: 0},
    icon: 'http://maps.google.com/mapfiles/marker_green.png'
})
.then(function(gMap) {
    console.log(gMap.getZoom())
})

Expected outcome is:

13
13

Actally what we got is:

13
Uncaught TypeError: gMap.getZoom is not a function

Working example on this page:

https://drachenfels.github.io/gmap3-issue/

Open console to see error.

Drachenfels commented 7 years ago

Yet another bug (probably source is the same):

var map = $('.map')
.gmap3({
    center: {lat: 50, lng: 0},
    zoom: 13,
    mapTypeId : google.maps.MapTypeId.ROADMAP
})

map.on('tilesloaded', function(obj) {
    console.log('aaa')
})

map.marker({
    position: {lat: 51, lng: 0},
    icon: 'http://maps.google.com/mapfiles/marker_green.png'
})

map.on('tilesloaded', function(obj) {
    console.log('bbb')
})

Expected output:

 > aaa
 > bbb

Actual output:

 > aaa
jbdemonte commented 7 years ago

The "then" function after the marker get a marker in parameter

Have a look on http://gmap3.net/api-chaining.html