eclipse - Could not find class 'com.google.maps.android.heatmaps.HeatmapTileProvider$Builder' -
i'm following google instructions on building map in android , far i've been sucessful.
however, when i've tried add heatmap few lat lng's app fails , following error message
could not find class 'com.google.maps.android.heatmaps.heatmaptileprovider$builder', referenced method com.example.heatmap.mainactivity.addheatmap
i've searched everywhere , can't find solution this. utils lib added correctly google play services, per online instructions. can tell me i'm doing wrong here.
for clarity, map works fine, when call heatmap method app fails.
package com.example.heatmap; import java.util.arraylist; import java.util.list; import org.json.jsonobject; import android.os.bundle; import android.support.v4.app.fragmentactivity; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.supportmapfragment; import com.google.android.gms.maps.uisettings; import com.google.android.gms.maps.model.latlng; import com.google.android.gms.maps.model.marker; import com.google.android.gms.maps.model.markeroptions; import com.google.android.gms.maps.model.tileoverlay; import com.google.android.gms.maps.model.tileoverlayoptions; import com.google.maps.android.heatmaps.heatmaptileprovider; /** * shows how create simple activity map , marker on map. * <p> * notice how deal possibility google play services apk not * installed/enabled/updated on user's device. */ public class mainactivity extends fragmentactivity { /** * note may null if google play services apk not available. */ private googlemap mmap; static final latlng ireland = new latlng(53.5056, -7.8289); static final latlng irelandcenter = new latlng(53.4026137,-7.969749234); private uisettings settings; private jsonobject testjson = new jsonobject(); private static string file = "sample_locations.json"; private heatmaptileprovider mprovider; private tileoverlay moverlay; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); supportmapfragment mapfragment = (supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map); if (savedinstancestate == null) { // first incarnation of activity. mapfragment.setretaininstance(true); } else { // reincarnated activity. obtained map same map instance in previous // activity life cycle. there no need reinitialize it. mmap = mapfragment.getmap(); } setupmapifneeded(); } @override protected void onresume() { super.onresume(); setupmapifneeded(); } private void setupmapifneeded() { // null check confirm have not instantiated map. if (mmap == null) { // try obtain map supportmapfragment. mmap = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map)) .getmap(); // check if successful in obtaining map. if (mmap != null) { setupmap(); locatemapireland(); createmarker(); addheatmap(); } } } /** * can add markers or lines, add listeners or move camera. in case, * add marker near africa. * <p> * should called once , when sure {@link #mmap} not null. */ private void setupmap() { mmap.setmylocationenabled(true); mmap.setmaptype(googlemap.map_type_normal); settings = mmap.getuisettings(); settings.setrotategesturesenabled(false); settings.setzoomgesturesenabled(true); settings.setcompassenabled(true); } private void locatemapireland(){ mmap.animatecamera(cameraupdatefactory.newlatlngzoom(irelandcenter,7)); } private void createmarker(){ marker testmarker = mmap.addmarker(new markeroptions() .position(ireland) .draggable(true) .title("title text") .snippet("snippet text") .flat(false)); testmarker.showinfowindow(); } private void addheatmap() { list<latlng> list = new arraylist<latlng>(); latlng 1 = new latlng(53.998,-8.624); list.add(one); latlng 2 = new latlng(52.443,-8.988); list.add(two); latlng 3 = new latlng(52.286,-8.319); list.add(three); latlng 4 = new latlng(54.162,-8.253); list.add(four); latlng 5 = new latlng(53.364,-6.453); list.add(five); list <latlng> listtwo = null; // data: latitude/longitude positions of police stations. // create heat map tile provider, passing latlngs of police stations. mprovider = new heatmaptileprovider.builder() .data(list) .build(); // add tile overlay map, using heat map tile provider. moverlay = mmap.addtileoverlay(new tileoverlayoptions().tileprovider(mprovider)); } }
turns out, need make sure you've added both google play services , google util libraries libs project, under properties tab. tutorials don't show , show how add play services lib utils
Comments
Post a Comment