I have an app written in Cordova (Phonegap) 2.3.0.
I use Jquery 1.8.2 and jquerymobile 1.2.0 and google maps v3.
XCode version 4.6
On one page I load a bunch of coordinates and creates different polylines added to the map.
There are 37 polylines added to the map and each polyline contains from 20 to 200 coordinates. About 1700 coordinates total on the map.
I also have like 20 markers.
The app works fine from start, I can zoom in and out and the map responds well, but if I reload the map I sometimes start to get messages like "Received memory warning" in XCode and the map wont update any more and sometimes the app crasch.
This is my clear routine that I call before adding the updated data:
function clearOverlays() {
try {
if (polyLinesArray != null) {
for (var i = 0; i < polyLinesArray.length; i++) {
polyLinesArray[i].setMap(null);
polyLinesArray[i] = null;
}
polyLinesArray.length = 0;
}
}
catch(e) {
handleError(e, "clearOverlays");
}
}
polyLinesArray is an array to which I push all polylines after they are added to the map.
So the question is, how can I clear the map in a good way the prevents memory warning (and leaks?)?
I have mouse click listeners too on the polylines, do I need to clear them as well before updating?
The same can occur when I navigate to another html-page in the app. After a few times forward and backward the map wont update any more. Before I navigate to other pages I call my clear routines first.
Another simple test done:
I just load the map, add my polylines and some other markers. Zoom in and out a few times and then the "Received memory warning" appears. I have not done anything else, just let google maps handle the zooming and panning around.
Regards
Henrik
I had the same issue and found out that it had to do with the way the Google Maps API draws overlays. For some reason this became too memory intensive from API 3.7 and up. Luckily in 3.12 (current experimental version) this seems to be resolved again. At least in my case.
If you call the maps api with &v=3.exp in the URL, your issue might be resolved as well.
Related
Note: problem appears when using MapsInitializer.Renderer.LATEST
Goal: I am using several tile overlays in order to switch the data user sees above the map. Several overlays needed to avoid flickering that user sees when we clear the overlay tile cache if using single overlay. For example: showing different weather data depending on the selected time moment.
Steps: When I add a TileOverlay I make it invisible with TileOverlay.isVisible=false right after map.addTileOverlay. Also added some logs to see when the TileProvider actually requests the tiles.
Problem: In the logs I see that overlay requests tiles when I move the map or change a zoom level. Previously the TileOverlay was not requesting tiles if one is set to invisible.
Demo app source code is here https://github.com/olkazmin/googlemaps-tileoverlay-sample.git
Pixel 3a, Android 12
Google Play Services client library version: com.google.android.gms:play-services-maps:18.0.2
Google Play Services version on the device: 22.06.15
compileSdkVersion 31
buildToolsVersion 31.0.0
All was working ok in com.google.android.gms:play-services-maps:17.0.0. Everything works as expected when using MapsInitializer.Renderer.LEGACY
There is one problem: I made it using maperitive tiles with the required scale of 12-15 (so that the map is available offline), then the task was to connect the resulting offline map to this project: https://github.com/ds4es/real-time-units- gps-tracking (the project is based on transferring data using kafka from a csv file, which contains latitude ,longitude time, to a map with the leaflet plugin, to display the real-time movement of markers on the map), however, this did not work, apparently some are required - something http requests, not just a link to tiles. I want to note that a similar way of writing: file:///home/jonh/openstreetmap/{z}/{x}/{y}.png worked in another project, but unfortunately not in this situation. Attached images below
The 1st figure shows the state of affairs when adding an offline map ( line: MAP_URL_TEMPLATE=' Tiles/{z}/{x}/{y}.png) and, as we can see, only moving labels are displayed, and the map itself is not displayed;
2nd figure Shows the state of affairs when the online map is used, i.e. constantly need internet to display it;
The 3rd picture shows the console, where, before the red line, an offline map was used (Tiles/{z}/{x}/{y}.png). And after the red line, I changed the address to the online map again: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' and the map started showing up all over again.
How can I connect an offline map? Thanks for answers :)
I have a Bing map with pins and clusters.
I noticed performance issues and bugs in this combination. I have setup a demo using code from the official docs.
1st issue: Pins click handler are not clickable anymore after zooming
Steps to reproduce:
Load the above demo
Hover over a single pink pin => its clickable (cursor is hand/pointer)
Click on the + button to zoom in
Some of the single pink pins are not clickable anymore (cursor is default)
2nd issue: Really bad performance when the map is initialised
It looks like this is caused to many, many _initiateRequest, _setImage or downloadImage calls within the Bing Maps JavaScript. See this perf screenshot taken with Firefox Performance tool:
This performance hog drops to about the half if no icon param is passed, that is, in the demo this is commented out so that just the default Bing Maps icons are used:
cluster.setOptions({
// commenting this out improves performance
// icon: svg.join(''),
anchor: new Microsoft.Maps.Point(radius, radius),
textOffset: new Microsoft.Maps.Point(0, radius - 8)
});
N.B. in the demo only the cluster has a custom icon setting. The performance gets much, much worse if also all the pins get a custom icon setting. It does not matter whether the icon is SVG or PNG, both are really bad performance and the Bing Maps seems to trigger DOM events and old browsers like IE11 even hang for several seconds.
Try using the experimental branch. There has been a ton of updates added to it which address these issues. You can try it by adding "&branch=experimental" to the map script URL. The main release branch will be updated with the updates in the experimental branch in the next 2 weeks.
I created a really basic app that just shows an MKMapView and the UserLocation. I'm having problems drawing this base map sometimes (it only shows pieces of the map), and whenever I pinch zoom the map, it fails to redraw, and just shows the blank gray tiles. The console shows this whenever it needs to get a new map tile:
/SourceCache/GoogleMobileMaps/GoogleMobileMaps-263.5/googlenav/mac/Loader.mm:231 server returned error: 502
This looks like a gateway error, but that doesn't make any sense, since I'm using open WiFi for testing. I haven't implemented any region zooming code, I just want to display and zoom the basic map first. I'm using iOS 4.2.1 (8C148), so I'm wondering if this is a problem with the newer iOS versions? Any ideas?
Edit: Works fine now, must just be a problem with Google's servers.
Just started getting the same error. I've searched online and can't see anyone else having the issue (yet). Thought it was something I did, but suspect its at Google's end.
I think that the problem is solved now. It had to be a momentary Google Maps problem.
I've tried to open Google Map application on iphone & android. From iPhone developer reference website I am able to open the native google map from link.
http://maps.google.com/maps?ll=11.5558762589,104.921697935&z=15
However, I have trouble with adding a marker into the map. As in google static map, we can add markers into map. I wonder if we can do the same to google map link.
Hey Borey
You can add markers. But it has to be google's own preset marker.
Try this link :
http://maps.google.com/?q=5.352135,100.299683&z=17
Use q instead of ll and I think it will work.
Problems I saw:
1) Cannot choose your own marker
2) Cannot remove that 'additional marker' that tells you what's around that area.
I guess, that's the next best thing for you? For your info, I am using it too as I lack other choices.
The only way I am aware of for doing this is to use the My Maps feature of google maps. You can create a public map in My Maps. Add a marker using the toolbar in the map, then use the link button on the top right to get the URL of your public map.
Not sure how this looks on a mobile device, but I assume that it works.
Edit
Ok. So my assumption was incorrect. I tried this out on Android and iPhone and got the following results:
iPhone - Switches out to the maps application (no option to view in the browser), displays the correct region, but no markers.
Android - Gives you the option of viewing the URL in the browser or in maps. If you view in the browser, you get the correct region, but no markers.
Android - If you view on the maps application, you get the correct region and the markers.
So basically not very useful to you. When I have done this in my mobile web apps (not native), I have used static maps. You give up the dynamic functionality, but you get lots of flexibility with what gets rendered on the map.