Discussion Forums  >  Maps, Device Location, Tracking

Replies: 17    Views: 154

chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
04/04/13 08:40 AM (11 years ago)

default zoom on Android map

I'm positive this has been answered before, but I'm having problems finding it. How can I change the default zoom on the Map plugin for Android? Currently it shows the map zoomed out to the highest level, forcing users to pinch to zoom into any helpful level. I tried the "singleLocationDefaultZoom" setting, changing it to both low and high levels, but it didn't do anything. Looking at the code in the BT_screen_map.java, it looks like that value is loaded into a String and then ignored. Thanks
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
04/04/13 09:50 AM (11 years ago)
I could be wrong but I think it maybe phone dependent, some phones use the zoom that is set some ignore it the first time maps are loaded till zoomed in manually. At least that is my experiences.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
04/04/13 10:01 AM (11 years ago)
It also depends on the spacing of your pins on the map. It generally defaults to a view that will show all the pins you have.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/04/13 10:03 AM (11 years ago)
I have a single pin. It doesn't zoom at all - just shows the fully-zoomed out view. The pin is set correctly, though, so it shouldn't be an issue with the key I obtained, right?
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
04/04/13 12:15 PM (11 years ago)
Comes down to devices, I test on 3 android devices lg ally- will not default zoom, htc one v will zoom at proper settings, samsung s2 zooms. Simulator with the device I use doesnt zoom.
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
04/04/13 12:16 PM (11 years ago)
These are all single locations btw. Also once I manually zoom in and go to a different map with a single location it seems to default to my last zoom on application.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
04/04/13 02:38 PM (11 years ago)
It may not apply, but I used a webview rather than a mapview and it looks perfect. One pin, perfectly centered and no need for the API Key. Shouldn't take too long to swap and check, if your up for it. Cheers! -- Smug
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/05/13 12:16 PM (11 years ago)
just thought I'd follow up - I ended up figuring out a solution. I replaced the first part of the method "setMapBoundsToPois" to the following: public void setMapBoundsToPois(List<GeoPoint> items, double hpadding, double vpadding){ BT_debugger.showIt(activityName + ":showMapPins"); //reference to map controller.. MapController mapController = mapView.getController(); //if there is only on one location directly animate to that location if(items.size() == 1){ mapController.setZoom(15); mapController.setCenter(items.get(0)); //mapController.animateTo(items.get(0)); }
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/05/13 12:17 PM (11 years ago)
it doesn't animate the zoom, but it at least starts off zoomed in to an appropriate level.
 
Mr stuck
Android Fan
Profile
Posts: 974
Reg: Apr 09, 2012
Fife, Scotland
15,740
like
04/11/13 02:52 PM (11 years ago)
@Chris1 do you think that code be adjusted to zoom into the users location rather than a pin. This would allow a world map with multiple pins to show just the pins around the user rather than zooming out to squeeze all the pins in. Cheers
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/11/13 03:03 PM (11 years ago)
absolutely - I don't know off the top of my head what the code would be to get the user's location, but once you have that you would do the following: replace: mapController.setCenter(items.get(0)); with: mapController.setCenter(USERLOCATION);
 
Mr stuck
Android Fan
Profile
Posts: 974
Reg: Apr 09, 2012
Fife, Scotland
15,740
like
04/11/13 04:10 PM (11 years ago)
Thanks buddy! Will that code not work as is? Its in control panel to show users location so it should automatically be in the map anyway. I will try it out. Thanks ;-)
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
05/02/13 12:32 AM (11 years ago)
Hi Chris FOR IOS: I'm not sure if this is what you mean but around line 360 of the bt_screens_map.m file you have the code: if([[self.screenData.jsonVars objectForKey:@"singleLocationDefaultZoom"] length] > 0){ //zoom will depend on what version in control panel (older version used decimals) //zoom values are between 1 - 28 (one being the furthest away, 28 super close) double tmpZoom = [[self.screenData.jsonVars objectForKey:@"singleLocationDefaultZoom"] doubleValue]; if(tmpZoom < 1){ tmpZoom = 13; } FOR ANDROID: at around line 780 of the map screen java file you have the below code. just add the line I've shown with comments: public void setMapBoundsToPois(List<GeoPoint> items, double hpadding, double vpadding){ BT_debugger.showIt(activityName + ":showMapPins"); //reference to map controller.. MapController mapController = mapView.getController(); //if there is only on one location directly animate to that location if(items.size() == 1){ mapController.animateTo(items.get(0)); //WEBNEVEES:to set zoom in android mapController.setZoom(13); }else{ I hope I was right in understanding the problem. let me know.
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
05/02/13 12:35 AM (11 years ago)
@SmugWimp: That's a neat idea for the map, at least for now! Any details, sample url you use. I mean how can you put up your own pin? Thanks
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
05/02/13 01:57 PM (11 years ago)
WebNeeves, The basic code would be like this: myMap = (WebView) findViewById(R.id.smugMapView); myMap.getSettings().setJavaScriptEnabled(true); myMap.loadUrl("http://maps.google.com/maps?hl=en&f=d&q=" + smuglat + "," + smuglng); And the map will pop up with a map in the location determined by (smuglat + "," + smuglng) Let me know if this doesn't make sense... Cheers! -- Smug
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
05/03/13 01:52 AM (11 years ago)
@Smug, So this is going to be the same as a customurl screen with the url set at "http://maps.google.com/maps?hl=en&f=d&q=[smuglat],[smuglng]" ? Or not?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
05/03/13 01:57 AM (11 years ago)
basically, yes. It displays a map with a marker at the lat/lng location you specify. But it's inside 'your' webview, either iOS or Android. Not a MapView, so no API keys needed either. It's pretty much the same as doing it 'in a browser', but your browser is the webview of your BT_Screen... Cheers! -- Smug PS. In the above code I may have called the item 'MapView', but that was me fooling around with many different things before a final revision was done. So, despite the fact that I am calling it 'smugMapView' it is actually a 'WebView'.
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
05/03/13 02:40 AM (11 years ago)
Thanks got it. There is just one big problem with this usage. I set up a new topic to ask your help on this as we were drifting away from Chris's main idea here. Please check: https://www.buzztouch.com/forum/thread.php?tid=A9C0EE7616FACF0641A3FF3&fid=0B19EC7C02CBDD92F12FD08&sortColumn=FT.id&sortUpDown=DESC&currentPage=1
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.