facebook

Google Map & Polylines: CLOSED

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #336656 Reply

    Yann
    Member

    Hello,
    i need help to remove polylines on my map
    i made a sqlite database with coordonates, i get this by this function:

    function viewtracing()
    {
    db.transaction(function (tx) {
      tx.executeSql('SELECT * FROM tracker', [], function (tx, results) {
       var len = results.rows.length, i;
       
        var str=""
        var point;
        var flightPlanCoordinates=new Array();
        var map = $('[id$=map1]').gmap();
        
       for (i = 0; i < len; i++){
       
        //str += results.rows.item(i).latitude + ","+results.rows.item(i).longitude+"/";
        point = new google.maps.LatLng(
        parseFloat(results.rows.item(i).latitude),
        parseFloat(results.rows.item(i).longitude));
        flightPlanCoordinates[i]=point;
                
       }
        var flightPath = new google.maps.Polyline({
        path: flightPlanCoordinates,
        strokeColor: "#FF0000",
        strokeOpacity: 1.0,
        strokeWeight: 2
      });
      
        flightPath.setMap(map);
    
     }, null);
    
    });
    
    }

    i have also a button “Remove” who’s calling clear function
    I tried this and many other things without success

    function clearroute() {
        var map = $('[id$=map1]').gmap();
       var flightPath = new google.maps.Polyline({
        path: []
         });
        flightPath.setMap(null);
          }

    i’m not familiar with google map v3 api 🙁
    if anyone can help me
    thanks
    Yann

    #336678 Reply

    Brandon
    Member

    Just a though, but if you use the var inside I function I believe it is scoped to that function. So I think in your clear route you are creating a new flightpath, then clearing it instead of clearing an existing one. I could be wrong though.

    #336681 Reply

    Yann
    Member

    hello CincyPlanet
    i tried to clear sql database and recall viewtracing() function without success
    i don’t understand
    thanks for your suggestion
    Yann

    #336683 Reply

    Yann
    Member

    Thanks again
    with yours suggestions i found solution 🙂
    i put my function inside viewtracing()

    clearroute=function () {
            if (flightPath){
          flightPath.setMap(null);
       }

    cool

    #336684 Reply

    Brandon
    Member

    Glad you got it.

    #346073 Reply

    PaulLeBlanc
    Participant

    Yann,
    I knowit has been a long time, but could you post your code for “function viewtracing();{}”, so I can see exactly where you put “clearroute”

    I’m having porblems removing flightpath too. Thank you very much.
    Paul

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Google Map & Polylines: CLOSED

You must be logged in to post in the forum log in