Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't access to camera.target #112

Closed
wroquet opened this issue Jun 19, 2014 · 5 comments
Closed

can't access to camera.target #112

wroquet opened this issue Jun 19, 2014 · 5 comments
Milestone

Comments

@wroquet
Copy link

wroquet commented Jun 19, 2014

map.on(plugin.google.maps.event.CAMERA_CHANGE, function(pos){

    var data = JSON.stringify(pos);
    console.log(pos);
    if(pos.zoom >= 7){

        var lat = pos.target.lat;

        var lng = pos.target.lng;

        console.log(lat); //undefined
        console.log(lng); //undefined

        getSitesVTTJSONByDistance(lat, lng)
    }else{
        // map.clear();
    }
});

I can't access to the lat lng position when CAMERA_CHANGE, any idea ? thanks in advance

@TheMassassian
Copy link

What do you get from

console.log(pos.target)

?

@TheMassassian
Copy link

I recreated your case and found out that it perfectly works on iOS, but not on Android

//TEST
map.on(plugin.google.maps.event.CAMERA_CHANGE, function(pos){

    var data = JSON.stringify(pos);
    alert(pos);
    alert(data);
    //if(pos.zoom >= 7){

        var lat = pos.target.lat;

        var lng = pos.target.lng;

        alert(lat); //undefined
        alert(lng); //undefined

        //getSitesVTTJSONByDistance(lat, lng)
    //}else{
        // map.clear();
    //}
});



  //TEST

The problem is that the Json is different, for Android the keyvalue pair is lat/lang: (cord, cord)

A different solution could be to call the getCameraPosition function after the Camera_change Event triggers.

map.getCameraPosition(function(camera) {
  var buff = ["Current camera position:\n",
      "latitude:" + camera.target.lat,
      "longitude:" + camera.target.lng,
      "zoom:" + camera.zoom,
      "tilt:" + camera.tilt,
      "bearing:" + camera.bearing].join("\n");
  alert(buff);
});

@wf9a5m75
Copy link
Member

Sorry, it seems like a bug.
I can not fix it currently, because I'm on a trip, so please wait until the last of this month or send me a patch.

@wf9a5m75
Copy link
Member

wf9a5m75 commented Jul 4, 2014

This bug will be fixed in the next release

@ibadrehman90
Copy link

I am still not able to use

map.getCameraPosition(function(camera) {
var buff = ["Current camera position:\n",
"latitude:" + camera.target.lat,
"longitude:" + camera.target.lng,
"zoom:" + camera.zoom,
"tilt:" + camera.tilt,
"bearing:" + camera.bearing].join("\n");
alert(buff);
});

I am using your latest version. Please help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants