generate layers for maps (Google or OpenLayers) - google-maps

I'm trying to develop a software that gets data from a text file and generates a map layer. The map later on is going to be cut into tiles and used as overlay for Google Maps API or OpenLayers.
The data stored in the text file is weather data. The file has data about 1 x 1 squares. For example: there is .9 chance of rain for lat 1-2 and lon 5-6. I have to use the data provided in the data file and can't use pre-generated layers.
I generate the map by dividing a background white PNG into 360 horizontal boxes and 180 vertical ones and color each one based on the data available in the text file.
My problem is the fact that there are 180 latitudes and 360 longitudes but the base map for OpenLayers and Google Maps is a square. In other words, number of latitudes equals the number of longitudes in OpenLayers and Google Maps. Moreover when I take a world map and stretch it vertically the lines do not align at all.
Example:
OpenLayer base map (256px x 256px):
Generated layers (256px x 256px):
When I add the layer on top of the base map. Continents don't match. I don't have this problem when i use a non-square(256px x 128px) base map.
My question is how should I generate my layover so it works with a square world map that is being used by Google and OpenLayers?

Related

Google Maps draw area / shape / region and export as latitude longitude

I need a Google Map with marked up areas with different colors.
GADM data
The first article I came across was this one:
https://ourcodeworld.com/articles/read/830/how-to-highlight-an-area-city-state-or-country-in-google-maps-with-javascript
It links to this service for getting coordinates:
https://gadm.org/download_country_v3.html
The problem is that there are too many points so it would end up with 3MB for an embedded map.
Google Maps draw
Then I tried Google Maps service to draw a shape. While it works, I could not find any export function to get the longitude and latitude.
https://www.google.com/maps/d/u/0/viewer?mid=1IlydZDXB-tkN8K8pAR57BRFqBOTv3c8z&ll=59.681023024095936%2C18.40997752499993&z=9
Question
How can I draw an area on a map and then get longitude and latitude for the points? On Google Maps, a tool or something else does not matter.
I solved my problem very differently. I simply used an svg file of just the country and highlighted areas there.
I used this site:
https://simplemaps.com/custom/country

How do I plot a vector (with a magnetic heading and magnitude) in Google Maps?

I have a table with a year's worth of wind data for a specific latitude longitude. I want to plot this as an arrow in Google Maps. Each data point has a timestamp, heading (true), and magnitude (knots), but it is just contained in a spreadsheet.
I was thinking the easiest way is to just create a new layer using geoJSON data, but I've never used geoJSON before.
How can I plot this in Google Map api v3? Thanks!
EDIT:
I did some research, and I think the best way is to just place a marker over the lat long point, and generate a ton of arrow images (probably in 5 degree and .5 knot increments, so I don't have a million images). Then just title each arrow based on its parameters (something like 01030.png, where 010 is the direction and 30 stands for 3.0 knots) and when the script calls for the marker image, just include those attributes when it calls for the image name.
I'll post the code when I make it, so other people can see.

Adding the marker to Google Maps external link

I have website that uses Google maps to plot the location of registered businesses. This uses javascript and shows the orange marker to pinpoint the exact location. I'm trying to build a link to the actual google maps page and my code is doing what I want it to except the marker doesn't show up. Is there another peice of code I can add to this to make it show up?
Full Sized Map
To add a pin you need the q parameter. It holds q=latitude+longitude+(url-encoded-text)
Here is an example of hybrid map with weather - pin at Embassy Suites, map centered on Horseshoe Falls
https://maps.google.com/maps?hl=en&ll=43.076,-79.074&spn=0.0212,0.0496&t=h&z=16&q=43.0795N+79.0818W+(Nice%20Hotel)&lci=weather
hl= two letter language code
ll= the map center using coma
separated +/- values
spn= the viewport span in degrees, works with
the z parameter
t= map type {m|k|h|p}
z= is the zoom factor
q= latitude+longitude+(url-encoded-text), the lat/lon in q have to be
followed by a letter - N/S or E/W instead of using +/-
lci= special codes, coma separated - i know of weather, transit_comp, com.panoramio.all
layer= additional layers, e.g. t for traffic
Google is changing things with the new Google Maps and a lot of functionality has been removed/replaced. You can check the new Maps Engine here http://mapsengine.google.com/map/

How to translate mercator map coordinates to relative screen coordinates?

I have a database with various map locations (latitude, longitude).
I've been using a map api (e.g. google maps) to plot these locations.
I am now experimenting to see if I can totally remove dependency of map apis and simply replace the map control with an image (an .png image).
Question:
How can I translate the map locations to be displayed properly onto this map image?
More details:
Basically, the map will be a rectangular area (i.e. Div element), where the top-left corner of the rectangle is obviously (0, 0). So basically the map locations will be displayed with respect to this top-left corner.
First off, where are you getting your geocodes from? If they are from Bing or Google Maps then you can only use those coordinates with those map controls. Using this coordinates without the map controls is against the terms of use of these API's. Assuming that these coordinates come from somewhere else you can overlay them on an image by first knowing some information about the image. At a minimium you will need to know two coordinates on the image and their relative pixel locations. From that you can then determine the scale and top left coordinate of the image. With this you can then fairly accurately position coordinates on the image using a lot of math. You can find a lot of useful math for this here: http://msdn.microsoft.com/en-us/library/bb259689.aspx I've writing a few blog posts on this a while back which you can find here: http://rbrundritt.wordpress.com/2008/10/25/ve-imagery-service-and-custom-icons/
If these coordinates come from Bing Maps you can easily display them on a map image using the Bing Maps Imagery Service: http://msdn.microsoft.com/en-us/library/ff701724.aspx

KML coordinates are off in a custom Google Map?

EDIT: Turns out it was all because the coordinate translation functions in the javascript were written wrong. The author of the program has apparently fixed it.
I'm trying to use KML files to display placemarks on a custom Google Maps map. The map was generated by a Minecraft mapping program called Unmined.
My problem lies with the positioning of placemarks. They are placed on the map in a position that doesn't seem to correlate with either the pixel or latitude/longitude coordinates of the map itself.
Here is an image showing my problem.
I loaded a KML with five placemarks defined. One in the middle (0,0), one in the top-left corner (-170,80), one in the top-right corner (170,80), one in the bottom-left corner (-170,-80), and one in the bottom-right corner (170,-80). The set of markers seems to be duplicated horizontally but from my experience that's standard with Google Maps. As far as I know, the range of valid coordinates in a KML file are from -180 to 180 longitude and -90 to 90 latitude, which means that any valid placemark would have to fall somewhere inside that rectangle. Except that rectangle barely intersects the map at all.
If you need access to the code I'm using, everything can be found in the source of http://tonyfox.ws/dt/kantomap/ (URL may not exist forever)
So am I just doing something catastrophically wrong or what?
On a related note, how does Google Maps decide where to place the map in the coordinate system when the map isn't an actual Earth map (like this Minecraft world map)? My map seems to range from about 14.5 to 19.5 longitude, and 25.5 to 28 latitude. Why such weird numbers?