question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GetDataUrl without loading map on view

See original GitHub issue

Hi, Thanks for this plugin, it’s helpful a much;

Unfortunately, I got one problem, hope you can help;

I know it’s not recommended to save map as base64-coded image, but in my case I need load it later without internet connection. So I tried to convert it with .toDataURL(), but it breaks app like on issue #388.

I tested it on: Samsung Galaxy Tab A Android v5.0.2 Cordova v6.2

My code looks like:

var map = plugin.google.maps.Map.getMap(DOMelement);
map.setOptions(mapOptions);
map.setCenter(centerLatLng);
map.addEventListener(plugin.google.maps.event.MAP_READY, function onMapInit(map) {
    map.addMarker({
        'position': {
            lat: lat,
            lng: lng
        },
        'title': 'msg'
    }, function (marker) {
        DOMelement.class = DOMelement.class === undefined ? " mapField " : DOMelement.class + " mapField ";
        map.toDataURL(function (dataUrl) {
            DOMelement.src = dataUrl;
        });
    });
});

Probably it’s out of memory problem, like you suggest on issue #388;

To avoid memory usage I want to load map 64base-coded image without loading it on the view. Is it possible there? Or could it be done soon?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Waniuszacommented, Sep 15, 2016

Hi,

I solved problem.

Your answers was very successfully, Problem was I tried to put map into element:

<div id="test">
</div>

I missed style=“width: something; heigth: something”.

Now I know it’s so important 😃

Not sure I missed something in documentation, but it will be great to focus that size styles should be defined BEFORE define map.

Thanks for your work!

0reactions
wf9a5m75commented, Sep 14, 2016

E/AndroidRuntime( 4208): java.lang.IllegalArgumentException: width and height must be > 0

I guess the DOMelement is not under the <body>.

Read more comments on GitHub >

github_iconTop Results From Across the Web

canvas.toDataURL for Google map ground overlays
None of the Google map API's support the ability to rotate a map overlay. For an application I am writing, I need to...
Read more >
Problem to generate the image of map (Google Maps) #345
Using html2canvas, but the image create doesn't show the map: ... is sudenly downloading loads of tiles to server without viewing webpage.
Read more >
HTMLCanvasElement.toDataURL() - Web APIs | MDN
toDataURL () method returns a data URL containing a representation of the image in the format specified by the type parameter.
Read more >
react-map-gl | default (Map) - GitHub Pages
No camera transitions are in progress; All currently requested tiles have loaded; All fade/transition animations have completed. onRemove : (event: MapboxEvent) ...
Read more >
How did OpenLayers 3 managed to export map from other ...
How did OL3 managed to use toDataURL() in this case? I tried monitoring network traffic and it seems no proxy are being used...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found