just like the title say, I know how to add marker on specific lat,lon. Now I want to add marker and put it on top left or top right of the map. How to accomplish this using javascript api v3 ?
http://code.google.com/apis/maps/documentation/javascript/reference.html#MapCanvasProjection
fromDivPixelToLatLng(pixel:Point)
Computes the geographical coordinates from pixel coordinates in the
div that holds the draggable map.
Related
I want to achieve the following: "Place an array of markers that may be distributed across a large range of lat, lng into a fitbounds method that places the fitbounds inside a custom rectangle."
The image below should clarify what I'm trying to achieve. Basically I have an array of markers that I want to make sure always fits within a small box on the right hand side of my page.
The white box contains some information pertaining to the markers, which will always be present, so I don't want any markers hidden behind the white box, and I'd love if I could define that they live within the black box. (Note the black box is just a visual reference for this question).
You can use the containsLocation to ensure a point is inside of a polygon. See here.
As you go through each coordinate pair in your array, verify the location is within the polygon area, then add to the map accordingly. You can also set an attribute to those points to "define" what extent they are in.
var latlng = new google.maps.latLng(array[n]);
if (google.maps.geometry.poly.containsLocation(latlng, polygon)){
marker = new google.maps.Marker({
position: latlng,
map: map
});
marker.dataset.box = 'blackbox';
} else {
alert('Not inside black box');
}
If you're using HTML5, you can add a dataset attribute to markers that are within the polygon.
marker.dataset.box = 'blackbox';
If not, you can use setAttribute.
marker.setAttribute('data-box', 'blackbox');
Is it possible with "Google Maps Api" to obtain a marker composed of a line and ends with a picture?
I tried to use a marker consists of a single image (eg, line and circle) and if there are 2 adjacent markers will be covered from the first second.
For example I have marker like this:
--0
and the second it's close the result is:
--0-0
I must rotate so the result is:
--0
\
0
how I can make this?
Take a look to MarkerOptions the attribute anchorPoint.
Using the Marker position you can detect a possible overlap between images, and change that value and image to do what you need.
I need to count and list the markers that are within a figure either a sirculo or a rectangle.
The operation would be that when you insert a figure on the map I list and count how many markers inside it.
The Circle and Rectangle classes have a getBounds() function, which returns a LatLngBounds object. Add your circle/rectangle and get its bounds. Loop over your markers, calling the contains() function on each marker to see if it is contained in that latlng bounds.
You may need to be slightly cleverer with the circle, as its bounds will be for the bounding box that surrounds it, so you might have markers that fall outside the circle but still within that box. In which case you'd need to work something out based on the radius of the circle.
I need to do a search for markers that are within a circle using as parameters the radius and position of the center of the circle. Someone can help me on how serious this search.
Concept:
make an array of the markers you want to search
iterate through the array of markers calculating the distance between each marker and the center point using the geometry library computeDistanceBetween()
function
compare that distance to the radius of the circle, if it is less than the radius, the marker is inside the circle, otherwise it is outside the circle.
example (with center point from geocoded address)
I need to draw a circle in google Maps V3 but I have 2 coordinates, the center and the outter position. Problem is the API expects center and "radius".
For example:
var myCirclePath = [];
myCirclePath.push(new google.maps.LatLng(18.111111,66.111111));
myCirclePath.push(new google.maps.LatLng(18.223344,66.222222));
var myCircle = new google.maps.Circle({
center: myCirclePath[0],
radius: // what do I put here????
map: map
});
I searched around the web and find a lot of stuff about radians, degrees, sin, atan, and what not... however, I'm not good at math and I'm totally lost.
So, the questions are:
a) What should I put in the "radius:" option?
b) How can I center the zoom around the circle? "Bounds.Extend" will not do it
So, the questions are:
a) What should I put in the "radius:" option?
Use the geometry library computeDistanceBetween() to find the radius (passing in your two points)
b) How can I center the zoom around the circle? "Bounds.Extend" will not do it
Once you have created the circle, you can call the getBounds() method on it to get its bounds
Correct me if I am wrong but isn't the radius the distance between center point and outer point of a circle? I would go with this.