How to disable streetview using gwt? - google-maps

There is a "person" icon which allows user to view "Street View". I don't want this functionality on my map, is there a way to remove it or disable it? And I am not using JavaScript I am doing it using GWT.
Google-Maps v3 am using.
private void initMap() {
mapVp.setSize(String.valueOf(BodyPanel.bodyWidth - 505),
String.valueOf(BodyPanel.bodyHeight + 5));
LatLng myLatLng = LatLng.create(24.440099, 46.843498);
final MapOptions myOptions = MapOptions.create();
myOptions.setZoom(5);
myOptions.setCenter(myLatLng);
setStreetViewControl(myOptions.getJso(), false); //Added now
myOptions.setMapTypeId(MapTypeId.ROADMAP);
myOptions.setMapTypeControl(true);
Timer load = new Timer() {
#Override
public void run() {
map = GoogleMap.create(mapVp.getElement(), myOptions);
hPanel.add(LoginDashboardModule
.mapLegends(map, "Live Tracking"));
}
};
load.schedule(1000);
}
This is my code
I am getting error after adding this line setStreetViewControl(myOptions.getJso(), false);

I just used the line below and got the output.
myOptions.setStreetViewControl(false);

You can do this with JSNI.
public static MapWidget createMapWidget(double lat, double lng,
final String width, final String height, int zoomLevel) {
// Set the options of the map widget.
MapOptions options = new MapOptions();
options.setZoom(zoomLevel);
options.setMapTypeId(new MapTypeId().getRoadmap());
setStreetViewControl(options.getJso(), false);
options.setCenter(new LatLng(lat, lng));
/* The map widget */
final MapWidget mapWidget = new MapWidget(options);
mapWidget.setWidth(width);
mapWidget.setHeight(height);
return mapWidget;
}
public static native void setStreetViewControl(JavaScriptObject obj,
boolean control) /*-{
if (obj)
obj.streetViewControl = control;
}-*/;

You can do so in the JavaScript API by setting streetViewControl to false. So I assume the GWT wrapper does provide a similar option.

Related

Could not allocate dup blob fd : IconGenerator with thousand markers causes exception

My app have 1,5 thousand markers, showed throught marker clustering.
Actually it works fine with default markers, but i want do use vector bitmap and render markers with text (price of gas station), like this:
Before finishing rendering markers, occurs this exception: "Could not allocate dup blob fd."
I think it's some kind of memory overflow, but I do not know how to solve it.
Does anyone have any idea how to solve this problem or have another suggestion of how to manage so many markers?
Note: I am already using marker clustering.
Note: This problem occurs only on some Motorola and LG devices. In most devices works fine.
Some code:
public class OwnRendring extends DefaultClusterRenderer<MyItem> {
public OwnRendring(Context context, GoogleMap map, ClusterManager<MyItem> clusterManager) {
super(context, map, clusterManager);
}
protected void onBeforeClusterItemRendered(MyItem item, MarkerOptions markerOptions) {
markerOptions.snippet(item.getSnippet());
markerOptions.title(item.getTitle());
markerOptions.anchor(0.33f, 1f);
markerOptions.infoWindowAnchor(0.33f,0f);
int cor;
if (item.getPublico()) {
cor=cfgCorPostoPublico;
} else {
cor=cfgCorPostoPrivado;
}
String preço = item.getTitle().substring(item.getTitle().length() - 5);
if (Objects.equals(preço, "0,000")) { preço=""; }
Bitmap bitmap = createStoreMarker(preço, cor);
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(bitmap));
super.onBeforeClusterItemRendered(item, markerOptions);
}
protected boolean shouldRenderAsCluster(Cluster cluster) {
// if markers < cfgClusterMin then not clustering
return cfgCluster && cluster.getSize() >= cfgClusterMin;
}
}
private Bitmap createStoreMarker(String text, int color) {
View markerLayout = getLayoutInflater().inflate(R.layout.custom_marker, null);
ImageView markerImage = (ImageView) markerLayout.findViewById(R.id.marker_image);
TextView markerRating = (TextView) markerLayout.findViewById(R.id.marker_text);
markerImage.setImageResource(R.drawable.pin_shadow);
markerImage.clearColorFilter();
markerImage.getDrawable().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY );
markerRating.setText(text);
markerLayout.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
markerLayout.layout(0, 0, markerLayout.getMeasuredWidth(), markerLayout.getMeasuredHeight());
final Bitmap bitmap = Bitmap.createBitmap(markerLayout.getMeasuredWidth(), markerLayout.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
markerLayout.draw(canvas);
return bitmap;
}

How to increase the grid size of Marker Cluster in android?

I am using Marker clusters in my application. I want to increase the grid size. I have customize the DefaultClusterRenderer class, but I didn't find any thing in it to increase the size.Please help me out how to increase it.
following is the code of customized clusterRenderer
public class MyClusterRenderer extends DefaultClusterRenderer<MyItem> {
public MyClusterRenderer(Context context, GoogleMap map, ClusterManager clusterManager) {
super(context, map, clusterManager);
}
#Override
protected boolean shouldRenderAsCluster(Cluster<MyItem> cluster) {
//start clustering if at least 2 items overlap
return cluster.getSize() > 4;
}
#Override
protected void onBeforeClusterItemRendered(MyItem item,MarkerOptions markerOptions){
if(item.isRegister()==true)
{
BitmapDescriptor markerDescriptor = BitmapDescriptorFactory.defaultMarker(340);
markerOptions.icon(markerDescriptor);
//markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.x));
}
else if(item.isRegister()==false)
{
BitmapDescriptor markerDescriptor = BitmapDescriptorFactory.defaultMarker(60);
markerOptions.icon(markerDescriptor).title("false");
}
}
}
A simple solution is use the NonHierarchicalDistanceBasedAlgorithm. Create a new calss and extends it with NonHierarchicalDistanceBasedAlgorithm, then override the method getClusters(double zoom). In this method you will be able to set the grid size, by changing the value of zoomSpecificSpan, In my i change the first value to 200.0D, and it works for me.
public Set<? extends Cluster<T>> getClusters(double zoom) {
int discreteZoom = (int)zoom;
double zoomSpecificSpan = 200.0D / Math.pow(2.0D, (double)discreteZoom) / 256.0D;
HashSet visitedCandidates = new HashSet();
HashSet results = new HashSet();
HashMap distanceToCluster = new HashMap();
HashMap itemToCluster = new HashMap();
PointQuadTree var10 = this.mQuadTree;

android maps api v2 adding multiple circles

I'm trying to add a circle to the map every second with an update from the gps. How would I pass the Location location = locationmanager.getLastKnownLocation(provider); to make a new circle every second? Here is what I have so far.
public class MainActivity extends Activity implements LocationListener{
Location myLocation;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GoogleMap mMap;
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMyLocationEnabled(true);
Location myLocation;
LocationManager locationmanager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria cr = new Criteria();
String provider = locationmanager.getBestProvider(cr, true);
Location location = locationmanager.getLastKnownLocation(provider);
locationmanager.requestLocationUpdates(provider, 1000, 0, (LocationListener) this);
CircleOptions circleOptions = new CircleOptions()
.center(new LatLng( , ))
.radius(3.048); // In meters
Circle circle = mMap.addCircle(circleOptions);
}
}
Instead of using getLastKnownLocation, you are better of using LocationListener's callback: onLocationChange for that, which you seem to implement and request already.
To convert Location to LatLng use:
new LatLng(location.getLatitude(), location.getLongitude())

Android google map v2 auto update

Hi i need marker update at time i try do it
ArrayList<LatLng> markerList = new ArrayList<LatLng>();
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_soc_map);
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
markerList.add(new LatLng(48.8742, 2.3470));
markerList.add(new LatLng(0, 0));
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask(){
GetDataFromWeb GDFW = new GetDataFromWeb();
public void run() {
for (LatLng latLon : markerList) {
mMap.addMarker(new MarkerOptions().position(latLon).title("Another marker"));
}
//GDFW.execute();
}
}, 12000, 12000);
}
so.. i take from database Lat and Lng but i just test with
markerList.add(new LatLng(48.8742, 2.3470));
markerList.add(new LatLng(0, 0));
so.. i need after 12s take Lat and Lag and update map marker
I have not found anywhere answer so maybe you can help me:)
Hey I have just got the same problem and solved it.
public class Livebus extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.googlemaps);
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mTask = (GetDataFromWeb) new GetDataFromWeb().execute(); //This is an AsyncTaskClass
}
class GetDataFromWeb extends AsyncTask<String, String, String> {
protected String doInBackground(String... param) {
while(true)
{
//HERE You should collect your data from the Web
latitude=...
longitude=...
//You have to update the markers in the Main thread which is also called UI thread.
//AsyncTask classes create theit own thread so you need to run the marker
//update on the UI thread. Which you can see below now.
runOnUiThread(new Runnable() {
public void run() {
mMap.addMarker(new MarkerOptions()
.position(new LatLng(latitude, longitude))
.title("Hello"));
}
});
}
}
}
This is my first answer here I hope it helps you :)
If something doesn't work pls contact me I will get it working.
Details on AsyncTasks: http://developer.android.com/reference/android/os/AsyncTask.html
Details on the threads: http://developer.android.com/guide/components/processes-and-threads.html
Read that I also learnt my lesson today.

Problem in Google Visualization Chart Api

I am using GWT
If You look at my code , When I click on Hide button it clear the pieFlowPanel Panel but when I click on Show button it does not show my PieChart
final Panel panel = RootPanel.get();
final FlowPanel pieFlowPanel = new FlowPanel();
final Runnable onLoadCallback = new Runnable() {
public void run() {
PieChart pie;
// Create a pie chart visualization.
pie = new PieChart(createTable(), createOptions());
pie.addOnMouseOverHandler(createSelectHandler(pie));
// pie.addSelectHandler(createSelectHandler(pie));
pieFlowPanel.add(pie);
panel.add(pieFlowPanel);
}
};
VisualizationUtils.loadVisualizationApi(onLoadCallback, PieChart.PACKAGE);
Button button = new Button("Hide");
Button button2 = new Button("Show");
button.addClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
pieFlowPanel.clear();
}
});
button2.addClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
final Runnable onLoadCallback1 = new Runnable() {
public void run() {
Window.alert("RUN");
PieChart pie;
pie = new PieChart(createTable(), createOptions());
pie.addOnMouseOverHandler(createSelectHandler(pie));
pieFlowPanel.add(pie);
panel.add(pieFlowPanel);
}
};
VisualizationUtils.loadVisualizationApi(onLoadCallback1, PieChart.PACKAGE);
}
});
panel.add(button);
panel.add(button2);
Please suggest me solution ...
Thanks
I had this problem earlier. All my applications that use a customized component based on Visualization API suddenly stop working, even older versions and local deployments.
Then I replace this line:
VisualizationUtils.loadVisualizationApi(onLoadCallback, Blabla.PACKAGE);
with:
VisualizationUtils.loadVisualizationApi(onLoadCallback);
and it works. Still have no idea on what has happened though.