Ng2-map/Ng2-ui - Angular2 difference in plotting geo codes - javascript

Here I have plotted a circle with
center="59.82352331557955,-43.59219821635634" & radius ="567.6796059859073"
I am giving two links , one is plotted using ngui-map and second one is the the marker point set as the same circles center in google map.
Link1: Plunker
Link2: Google map
There is a huge difference between them. Can anyone help? Is this my mistake or bug in the module?

AFAIK(I have been using ng2-ui/map for some while), the marker's position accept array which contains lat, lng, and circle's center accept object which contains properties of lat/lng, ng2-ui/map will call geocode to search for result if they are binded with string(your current plunker).
refer code, and fixed plunker.

Related

Capture window Lat, Longs with Leaflet

I am trying to figure out how to capture the four corners of a Leaflet window, so that I might load points based on where a user is zoomed in geographically. For example, have a look here.
Now, how would I capture the four corners of that view so that I could load only the points that are geometrically bounded to that general location - downtown London?
I have not been able to find any example for Leaflet specifically. Any assistance will be appreciated.
The term you should be searching with is called "bounds". Leaflet's L.Map has a method called getBounds which will return the bounds of the current mapview:
http://leafletjs.com/reference.html#map-getbounds
Returns the LatLngBounds of the current map view.
It returns a LatLngBounds object which consist of a southwest and a northeast LatLng object:
http://leafletjs.com/reference.html#latlngbounds
Represents a rectangular geographical area on a map.
How you use those bounds to query your points of interest from your server depends on the platform you are working with.
If you already have a dataset loaded and you want filter that based on the current bounds you could use contains method of the LatLngBounds object. You can use that to check if a point is contained within the current bounds:
http://leafletjs.com/reference.html#latlngbounds-contains
Returns true if the rectangle contains the given point.

Getting proper map boundaries

I use the simple:
var ne = gMap.getBounds().getNorthEast(),sw = gMap.getBounds().getSouthWest();
to get the lat long of the boundaries of a map
It works fine when the map is like this:
But when the map is like this:
The North-East lat long comes as something like 63.821287740550275, -179.73632762500006. Which creates a problem because this lat long is almost same as the South-West resulting in no-area between them.
Is there a way to get the desired values, something like a maximum value if it crosses the line.
If you refer to this question: Get non-wrapping map bounds in Google Maps API V3
You'll see that as you have stated the map obviously wraps on the date line, so that as you zoom out you don't end up with blank areas at the edges and so that you scroll off the edge of china and hit America etc.
If you examine the answers you will see that you need to check for this wrap and go from there. And interesting question that I had never really considered!

Get center coordinates of map

I am using VEMap API. I have the latitude and longitude of the top left point and the bottom right point (bounding box) of a map. I want to get the center point. What is an easy way to do that? I couldn't find a solution by searching on Google.
What I was thinking is that if I can define the map using the two points mentioned above, then I can get the center very easily:
// JavaScript code snippet
var center = map.GetCenter();
var lat = center.Latitude;
var lng = center.Longitude;
Is there a way to call the constructor of map object and pass the two coordinates I have?
Thanks.
The simple answer would be add the latitudes and divide by two, and do the same for longitudes. They are straight lines.
Is there any reason you can't use the VEMap.GetCenter method after the map has been constructed? This way regardless of the viewpoint it will be correct. If you're using the default constructor you can pass in your bounding box, and then call getmap after the object is instantiated.
http://msdn.microsoft.com/en-us/library/bb412539.aspx

plotting google map markers using an array

i need some help with google map api v3 markers.
I got an array which contains coordinates i retrieve from a file. I am trying to traverse the array, and plot them using the markers.
Traversing the array to retrieve the coordinates is not a problem, however, when i start using the coordinates to plot on google map. i realise that i am getting (NaN, NaN) as the coordinates.. Because of this, i am not able to do the plotting.. any idea why isit? Thanksss
my codes so far:
var temp = new google.maps.LatLng(myObject[o]);
retrieverouteMarker(temp);
The constructor for LatLng takes two arguments (the latitude and longitude of the point), so this line is clearly wrong:
var temp = new google.maps.LatLng(myObject[o]);
Of course, since we have to idea what myObject is, or what the function retrieverouteMarker does, there isn't much more we can do to help.

how to get co-ordinates of vector layer line points from openlayers?

I am not able to find out how to get lat-lon values of all the points in the drawn line in the openlayer vector layer, like this openlayer-example.
please help me where to search...?
http://dev.openlayers.org/releases/OpenLayers-2.9/doc/apidocs/files/OpenLayers-js.html
Get layer instance(OpenLayers.Layer.Vector) from map.layers array. Iterate over features(OpenLayers.Feature.Vector) in layer.features. Access geometry(OpenLayers.Geometry) of feature using feature.geometry. This can be any type of geometry. For line the type is OpenLayers.Geometry.LineString. Use getVertices function to get array of all points(OpenLayer.Geometry.Point) in teh line.
you can get by using feature.getGeometry().getCoordinates()

Categories

Resources