Question

I am new in phonegap. I want to show left leg library and I can see this in my phone. But I send lat and long from android side to JavaScript side. and I want show a console log from JavaScript but I can't :( and I dont konw, my lat and long send to my method or not becuase I dont know good JavaScript.

JavaScript side in html file:

<script>
$(function () {
    $("#my-map").kmap({
        mapLayer: 'GoogleMap.RoadMap',
        contentRoot: "Content/Images/Markers/"
    });

    $("#my-map").kmap("addMarkers", [{
        lat: 35.677336572709514,
        lng: 51.41564316503603,
        id: 0,
        console.log("start map")
    }]);
    var l = 51.41564316503603;

    var animate = function () {
        l += 0.00001;
        $("#my-map").kmap("repositionMarker", 0, [35.677336572709514, l]);
        setTimeout(animate, 500);
    };
    animate();
});
</script>

Java class for send to JavaScript:

public class GPScls extends DroidGap{
    public void GPS(double lat,double lng){
        this.sendJavascript("javascript:$("+lat+","+lng+")");
    }
}

I trace and I see the program go to this line (this.sendJavascript("javascript:$("+lat+","+lng+")");)

Why does console.log(----start-----) not show in logcat from Eclipse?

Do I correctly send my lat and long from android to my JavaScript function? I dont know if my function in JavaScript declare like that, I should call like this!

And another question, sometimes I cant see tile map in my screen. Why?

Was it helpful?

Solution

Aren't you getting any compiler errors?

This here:

$("#my-map").kmap("addMarkers", [{
    lat: 35.677336572709514,
    lng: 51.41564316503603,
    id: 0,
    console.log("start map")
}]);

Is not valid JavaScript. You can't call console.log in a object, like that. Move the log out of the object:

$("#my-map").kmap("addMarkers", [{
    lat: 35.677336572709514,
    lng: 51.41564316503603,
    id: 0
}]);
console.log("start map");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top