Android GoogleMaps v2: error when adding multiple markers using 'for' loop -


i need add given number of markers map using for loop. log messages tell me function add each marker called, 1 marker (two @ most) displayed on map. 2 functions following:

private void paintinmap(string description){     map.clear(); // erase previous markers     string[] zones = getresources().getstringarray(r.array.zonas); // array of place names     string[] coord = getresources().getstringarray(r.array.coordinates); // array of place coordinates (placed in same order)     string[] route = description.split(", "); // split different places of route description      for(int i=0; i<route.length; i++){         for(int j=0; j<zones.length; j++{             if(route[i].equals(zones[j])){                 latlng latlng = getcoordinates(coord[j]); // call function coordinates string                 placemarker(latlng, zones[j]);             }         }     } } 

and:

private void placemarker(latlng coordinates, string name){     map.addmarker(new markeroptions()         .title(name)         .icon(bitmapdescriptorfactory.fromresource(r.drawable.gpsmap))         .position(coordinates)         .flat(true)         .rotation(90));     log.d("place", name+" added map"); } 

apparently code correct, on runtime displays 1 (or two) markers. have checked log messages , function being called, markers no appear. moreover, 1 of markers appears in unspecified location (which corresponds first value of coordinates array way)

is runtime bug in eclipse? how can solve this?

    map.clear(); // erase previous markers     new asynctask<string, markeroptions, void>() {          private void placemarker(latlng coordinates, string name) {             publishprogress(new markeroptions()                 .title(name)                 .icon(bitmapdescriptorfactory.fromresource(r.drawable.gpsmap))                 .position(coordinates)                 .flat(true)                 .rotation(90));             log.d("place", name + " added map");         }          @override         protected void doinbackground(string... params) {              string[] zones = getresources().getstringarray(r.array.zonas); // array of place names             string[] coord = getresources().getstringarray(r.array.coordinates); // array of place coordinates (placed in same order)             string[] route = params[0].split(", "); // split different places of route description              (int i=0; i<route.length; i++) {                 (int j=0; j<zones.length; j++) {                     if (route[i].equals(zones[j])) {                         latlng latlng = getcoordinates(coord[j]); // call function coordinates string                         placemarker(latlng, zones[j]);                     }                 }             }             return null;         }          @override         protected void onprogressupdate(markeroptions... markers) {             map.addmarker(markers[0]);         }     }.execute(description); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -