Add text area in google map rectangle - javascript

How we add a text area in google map polygon triangle?
We can draw polygon by drawing tools or by onclick event on map but how we show something in rectangle?
And when we move rectangle then our textarea must be moved, Means this textarea must be related to polygon.
I know we draw triangle by this example:-
https://developers.google.com/maps/documentation/javascript/examples/rectangle-event

Related

FabricJS How to make exact Circle Boundary

I want to create exact Circle Boundary in order to create drag & drop quiz. By dragging and dropping the red circle to purple or blue circle or both areas as shown in the image below:
The quiz
The problem is the purple or blue circle has rectangle boundary when I used red circle to drag and drop and detect that within circle area by isContainedWithinObject function, as shown below:
The rectangle boundary
How to create exact circle boundary like this:
The exact boundary

Draw circle subscribed to a polygon

We have a polygon with an irregular form (in example, a city boundaries polygon).
We need to draw a "circle" with a defined radius (ie, 4km) bound to this polygon, in other words, if point at 4km fall outside the polygon, we need to keep the polygon point as point.
I've attached a sample image, the red border is our polygon, the blue circle is what we need to get. As you can see, the blu circle doesn't exceed the polygon boundaries.
Any help?
Use floodfill algorithm to make a set of points inside the shape, then paint points form the set which are not further form center of circle than its radius.

Leaflet :- Different size circle on different locations on map

I am using leaflet.js for creating a fix sized circle around marker on mouseover event and removing the same circle on mouseout event. I am providing a fixed radius i.e (10000) to create a same size circle around every marker but the circles are getting created with different sizes.
On mouse over I wrote the following :--
cir = L.circle([ lat, lng ], 1000000); /*Where lat,lng are the position of currently drawn marker*/
cir.addTo(map);
Is there any formula or approach to calculate the radius by using lat,lng so that I can draw a same sized circle around my markers anywhere in map???

Leaflet JavaScript Bounding Box Example?

I am totally new to Leaflet JavaScript. Basically I need to program something that:
Allow drawing a bounding box over a map
Get the coordinate of the box
Later on draw the box based on the coordinates
Clear the box
Anya ideas or examples how to do this? Or where to find them?
Thanks
There's a plugin called Leaflet.draw that adds support for drawing and editing vectors and markers onto Leaflet maps. On this link you will find enough information to implement a simple rectangle that will be your bounding box.
With this piece of code you can get the position of the mouse pointer on the map (you just need to create one handler for the mouse down, and the other on mouse up)
map.on('click', onMapClick);
function onMapClick(e) {
alert("You clicked the map at " + e.latlng);
}
3.Draw the box based on coordinates:
var bounds = [[X, Y], [X, Y]];
// create an orange rectangle
var boundingBox = L.rectangle(bounds, {color: "#ff7800", weight: 1});
map.addLayer(boundingBox);
4. Clear the box:
map.removeLayer(boundingBox);

How to write on polygons that are in turn drawn in svg element?

I have a "map" that is a set of polygons drawn by JavaScript on svg element. Is there any way to draw text inside (on top of) polygon that is drawn inside of svg element?
Should I try to draw text on the svg element on the same coordinates were polygon is drawn?
Thank you!
P.S. either clean JavaScript or jquery both will help.
Yes. The way of doing that is to simply add a <text> element using its x and y attributes to position it where you want on a given polygon (using whichever same JS way that you're using to add polygons, just creating a text element instead of a polygon element).
Be sure to put the text element after the polygon in the tree so that it paints on top of it.
Second option is to draw polygons and texts:
a) at 0,0 for top left corner
b) -x,-y for center
And then translate each polygon/text where you want them to be.

Categories

Resources