-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the map container #432
Comments
Is there any error message in Logcat or Xcode? |
I tested a simple code, but there was no error at all. <!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
<meta charset="utf-8" />
<title>Google Maps Plugin for Cordova</title>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener('deviceready', function() {
var divs = [];
divs[0] = document.getElementById("map_canvas1");
divs[1] = document.getElementById("map_canvas2");
var map = plugin.google.maps.Map.getMap(divs[0]);
map.on(plugin.google.maps.event.MAP_READY, function() {
var idx = 0;
var button = document.getElementById("button");
button.addEventListener("click", function() {
var divIdx = ++idx % 2;
map.setDiv(divs[divIdx]);
});
});
});
</script>
<style type="text/css">
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#map_canvas1 {
margin: 5%;
width: 90%;
height: 40%;
padding: 0;
border: 1px solid red;
}
#map_canvas2 {
margin: 5%;
width: 90%;
height: 40%;
padding: 0;
border: 1px solid green;
}
</style>
</head>
<body>
<div id="map_canvas1" ></div>
<button id="button">↑ Swap ↓</button>
<div id="map_canvas2" ></div>
</body>
</html> |
@iDams Any updates? |
Hi, Yes, this is what I'm trying to do when I need map2:
But apparently, the image is the reason why I don't see map2. If I don't put an image for map1, map2 is working fine. Do you see a reason why it's not working with the image? In your example, when you switch, if you put an image of the map, is it working? |
… developer forgot to call setDiv(null)
All right, the problem was the encoded strings include the break line characters. <!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
<meta charset="utf-8" />
<title>Google Maps Plugin for Cordova</title>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
document.addEventListener('deviceready', function() {
var divs = [];
divs[0] = document.getElementById("map_canvas1");
divs[1] = document.getElementById("map_canvas2");
var map = plugin.google.maps.Map.getMap(divs[0]);
map.on(plugin.google.maps.event.MAP_READY, function() {
var idx = 0;
var button = document.getElementById("button");
button.addEventListener("click", function() {
var divIdx = idx % 2;
map.toDataURL(function(imageData) {
divs[divIdx].style.backgroundImage = "url(" + imageData + ")";
map.setDiv(divs[++idx % 2]);
});
});
});
});
</script>
<style type="text/css">
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#map_canvas1 {
margin: 5%;
width: 90%;
height: 40%;
padding: 0;
border: 1px solid red;
}
#map_canvas2 {
margin: 5%;
width: 90%;
height: 40%;
padding: 0;
border: 1px solid green;
}
</style>
</head>
<body>
<div id="map_canvas1" ></div>
<button id="button">↑ Swap ↓</button>
<div id="map_canvas2" ></div>
</body>
</html> |
Ok thanks! |
@wf9a5m75 Hmm... Are you sure the test branch is working? I had these three errors:
I corrected all of these but it's still not working for me... When I use the image for map1, map2 is still not there :/ |
"NSData-Base64/NSData+Base64.h" is this file. |
Yeah but when I build, there is an error saying it can't find the file. |
No. |
Regarding of 'isHTMLColorString', thanks for good pointing.
|
And also I already fixed the code of the googlemaps-cdv-plugin.js file in the test branch. |
Ok thanks. I'm trying to figure out why #import "NSData-Base64/NSData+Base64.h" is not working for me. fatal error: 'NSData-Base64/NSData+Base64.h' file not found |
ok, I'll check it too. |
I tested buiding from command line, but I didn't face any error. Is there If no, download from here |
I just checked platforms/ios/(my app)/plugins/plugin.google.maps/ and I do have the NSData+Base64.* files but they are not in a folder, they are at the root with all the other files of the plugin. I used the PhoneGap Usage to install your plugin, maybe it makes a difference? So if I use #import "NSData+Base64.h", Xcode is going to use Cordova file not yours? |
Ah, I just remember that the plugman (that is used Cordova and Phonegap internally) does not make directory since Cordova 3.3 or 3.4. |
Hi, It's still not working. The weird part is if manually I remove the image of map1 in the JavaScript console like this: |
Did you try my example code? |
Hi, Your example is working. This is the modified version of your example:
Basically, I added position absolute for map2 and put it on top of map1. This is looking more like my application. And it's not working for me with this example. Map2 is not showing. |
What do you mean by it's incorrect?
When these informations appears, this is when I need to put an image on the main map et display a mini map with these informations. |
Do you understand how this plugin display the map? The CSS you modified my example is that the #map_canvas1 covers almost full cover. When you set the background image to #map_canvas1, it is not transparent anymore. You can use |
Hmm ok I get it. It's not possible to do what I want then. |
👍 |
Hi,
I'm having some issue to change the map container.
I have one main map which is working fine. But at some point I want to display a map thumbnail.
I do this:
this.map.setDiv(container);
this.map.clear();
this.map.refreshLayout();
But the map is not showing. Is there something I forgot?
Also, the container seems to be right because the parent elements of the new container become transparent. I tried to do a setBackgroundColor('white') but it's still transparent.
The text was updated successfully, but these errors were encountered: