With the API version 3, How to change the size of an icon (created with MarkerImage) according to the zoom factor of the map ?
I suppose I must use scaledSize and map.getZoom() ?
This is code cut and free hand written from the api documentation but it might give you an idea where to start
google.maps.event.addListener(map, 'zoom_changed', function() {
yourMarker.setIcon("path to your icon here");
});
If you need to change all the icons on the map I would suggest putting them in an array and loop over them doing setIcon()
Related
Using this example: https://developer.here.com/api-explorer/maps-js/infoBubbles/open-infobubble . I have a new map with two points.If I change the div of map adding width:100%;height:100% and position:absolute. I have a full screen map, but in this versión if i load the first time the page without full screen and a click a full screen windows i have a grey backgroud color. The same issue with a movile browswer when change the screen orientation. In the other API it didnt happened, all time the map is in full screen. ¿How can i fix it?
And the other question in this api, how i can close a infobubbles ??.
Regards and sorry for my english.
If I understand you correctly...
When you change the size of the map's container you need to call a refresh to the map.
For example - create your map:
var map = new H.Map(
document.getElementById(map_div),
defaultLayers.normal.map,
{
zoom: 4,
center: { lat: 45.3367, lng: -95.4492 },
});
Then add a listener for a window resize:
window.addEventListener('resize', function () {
map.getViewPort().resize();
});
Or call the resize method whenever you change the size of your div map container.
As for dealing with closing info bubbles, I am assuming you already have your HERE Maps UI object setup for adding/showing info bubbles.
To close the open one use the HERE Maps UI object:
ui.removeBubble(bubble);
if your issue is keeping track of what is currently open, trying assigning it to a script wide variable anytime you add a bubble:
//show info bubble
ui.addBubble(bubble);
openInfoBubble = bubble;
Then when you need to close the open InfoBubble:
if (openInfoBubble != null)
ui.removeBubble(openInfoBubble);
Hopefully, that answers your questions... good luck.
Have a huge problem, searching for weeks now. I have many markers and big InfoWindows per marker that most of time don't show up completely in my map-bounds. How to move the map automaticly and show these big InfoWindow exactly in the center? Further I think of showing it not only in the center (because the InfoWindows are more long than broad) but, say, in a lower position of center (centered, but near to bottom on the map-bounds). I hope you understand, what I mean.
Further, my InfowWindow even changed in size after I click on a link in it and get even bigger (o my god ;-), so I also have to handle this also.
You probably know that InfoWindow has an option disableAutoPan, but it's defaulted to false so that you should automatically see it whenever it's opened. If you want it in the center, then your best bet is in the click event before opening the InfoWindow, to center the map on the marker first. The autopan from opening should handle automatically and adjust the viewport to fit the InfoWindow from there as necessary.
//marker and map defined somewhere already
var iw = new google.maps.InfoWindow();
google.maps.event.addListener(marker, 'click', function(){
map.setCenter(marker.getPosition());
iw.setContent('your content');
iw.open(map,marker);
});
I'm using OpenSeaDragon for the first time and I'm trying to display to the console zoom level and Viewport center.
Now I found out how to display coordinates on click (Openseadragon image cordinates), but I'm having trouble w/ zoom and center. From looking at the API doc, I'm thinking that I need to use getCenter and getZoom of method Viewport, but syntactically I'm lost. Any help would be much appreciated. Thanks!
So after some help, here's the code I ended up using to get click coordinates as well as zoom and center (in image coordinates):
viewer.addHandler('canvas-click', function(target, info) {
var viewportPoint = viewer.viewport.pointFromPixel(info.position);
var imagePoint = viewer.viewport.viewportToImageCoordinates(viewportPoint.x, viewportPoint.y);
console.log(imagePoint.x, imagePoint.y);
console.log(viewer.viewport.getZoom());
var viewportCenter = viewer.viewport.getCenter();
var imageCenter = viewer.viewport.viewportToImageCoordinates(viewportCenter.x, viewportCenter.y);
console.log(imageCenter.x, imageCenter.y);
});
You're on the right track. If your viewer is called viewer, you would do viewer.viewport.getZoom() for instance.
The viewport has a number of other coordinate conversion methods:
http://openseadragon.github.io/docs/symbols/OpenSeadragon.Viewport.html
...and there's also a plugin that provides even more, if you need:
https://github.com/msalsbery/openseadragonimaginghelper
i'm looking for some info about Google Map V3. I want change the color of the zoom control , i want it red...
How can i change the color simply ?
Thank you for response !
They're images, so you can't simply "change" the color. What you can do, however, is create a map WITHOUT the zoom controls and then just use the API and your own DOM elements as zoom controls.
This will give you a very rough idea:
var map = new google.maps.Map();
//zoom out
map.setZoom(map.getZoom()-1);
//zoom in
map.setZoom(map.getZoom()+1);
I have the following code which is a custom icon on Google Maps V3. I want to rotate it using the jQuery.Rotate plugin.
var image = new google.maps.MarkerImage(
"markers/test.png",
new google.maps.Size(52, 52), // size
new google.maps.Point(0, 0), // origin
new google.maps.Point(20, 0) // anchor
);
marker = new google.maps.Marker(
{
map: map,
draggable: false,
position: markerData[i].latLng,
visible: true,
icon: image,
optimized: false
});
The problem is jQuery.Rotate is wanting the DOM id to identify the element to rotate.. Markerimage doesn't have one and I can't specify it.
Eg.
<img src="img" id="image">
$("#image").rotate(15);
Can anyone show me some sample code that will allow me to either assign an id to the MarkerImage so that jQuery.Rotate can use it eg. #image assuming the id is id="image", or is there another way of telling jQuery.Rotate to use the MarkerImage rather than point to a DOM element?
Any help would be appreciated.. If I can't find an answer to this I'll need to create 360 versions of the same icon for every icon I use of which there are many. I prefer to use this particular plugin though. Hopefully there's an easy answer.
I can't provide an 'answer', just a hint and observation.
Assuming that your map is a DOM object called 'map', have a look at the DOM object map.l.innerContainer.outerHtml. (thats a lower case "l" - map.l)
In outerHtml, amongst many other divs, you should be able to find a div that contains the img file for your icon.
I've wanted to do the same thing as you, rotate icons on the fly, but I haven't yet found the time to see if I can organise a way to put an id on these divs to facilitate using jquery to rotate them. The divs are created by the api.
There are some DOM mutation events (like DOMNodeInsertedIntoDocument) described in the literature but evidently their implementation is unreliable / uneven and it sounds like they have been removed from the W3C spec. I haven't tried any of these yet so can't comment from personal experience.
In my case I just decided to create icon files for each cardinal direction, N NNE NE ENE etc. For my application that seems to get the icons aligned well enough to look ok.
If you succeed in your quest please share your solution here for others.