Plotting data on maps using d3.js but without lat/long - javascript

I'm experimenting with d3.js and plotting data on maps.
My data only has general city/state information. It doesn't have lat/long.
Looking at the tutorials online, all the data they have is already in a geojson format.
Questions:
Is there a way to plot on a map without lat/long info? i.e. the map
is able to intelligently intrepret something like "Chicago, IL"
If not, What is the current best practice to map general arbitrary
location data like i have into a geojson format? I'm wondering if
there is a better way than just manually trying to map it using some
random source i find online.

Related

Search within a Google map area outline (neighbourhood)

this community has been really helpful so far!
Does anyone know if there is a possibility of getting the region outline from Google Maps and getting an array of elements within that area? For example, if I type "Brooklyn", I would like to get an array of the properties advertised in my website. I can't find documentation on the API docs...
Thanks,
Eric
This is not possible in mysql.
You need to store that data in some graph database like neo4j. Mysql is not meant to store such points / graph data. You can only store tabular data in mysql.

Point inside polygon -- json or kml?

I'm trying to decide if I want to use json or kml to store polygons in a file on a server. I have to read in this file and check which polygon a given point is within. I am attracted to kml because I can render an entire kml file in two lines with the Google Maps Javascript API :
var importedKml = new google.maps.KmlLayer('mykml.kml');
importedKml.setMap(map);
However, I can't find a built-in function for checking if a point is inside all the polygons in a kml file. I know I can check to see if a point is in a polygon using the code below:
google.maps.geometry.poly.containsLocation(latlngPoint, polygon);
but it looks as though I'd have to parse the kml and turn every
<Placemark><Polygon>
feature into a google.maps.polygon object first.
I've thought about going back to json, since json objects are extremely customizable and I could directly call something like
//json object polygonFile from server
google.maps.geometry.poly.containsLocation(latlngPoint, polygonFile.polygons[0].polygon);
with a structure I have built myself. There's no quick and easy way to render json to the map without first converting it to google maps objects and then rendeing those, though, it appears.
Is there a way to check if a point is within a polygon in a kml file without converting each feature to google maps objects first? If not, converting a json object to google maps objects sounds like the way to go.
what about GEarthExtensions . There is a function "containsPoint" for an Polygon object
here is an example:
http://code.google.com/p/earth-api-utility-library/source/browse/trunk/extensions/examples/point-in-poly.html

Get the elevation from a point without viewing Google Maps

I have readed the API for elevation for Google Maps and what I can understands I must have the map visible to get the elevation for a point (coordinates). But almost nothing is impossible with JavaScript so I wonder now, is it possible to get the elevation from a point without viewing the map?
Thanks in advance.
Do you know what the co-ordinates are for the point? If so, the API for elevation will return the elevation, in both JSON and XML formats. I use the following URL (albeit in PHP, it should work the same for Javascript):
http://maps.googleapis.com/maps/api/elevation/xml?sensor=false&locations=1.111,1.111.
You'll need to parse the results in JS. Switch XML out for JSON in the URL to change the result type.
Edit: If you use this service, you need to use it in conjunction with a Google Map as per their terms and conditions.

Looking for examples of polyline with google maps V 3

I am looking for examlpes of how to use polylines in V3 of Google maps, I have read the help at Google but must admit I don't fully understand. I feel if I could see a good example I might understand it better. What I have is a site that I track my vehicle I have it plotting the points on the map what I want is to draw the line between the points. I am using a mysql database and a XML file with PHP to display the point on the map.
Any help would make my day. I have found this site very helpful and I wish to thank all.
Take care, all the best
It's a matter of creating a KML xml file, using data from your database, and feed google api with that. You can use this tool to interactively see how the kml file changes while adding points to the polyline.
EDIT:
Create a script in your preferred scripting language which retrieves the points from database, and generates a kml file format as in the third link above.
In your javascript script, you need to add a kml layer to the map, loading the kml you generate on the fly in your script at point 1. :
[...]
var map = new google.maps.Map(document.getElementById('map'), options);
[...]
kmlFiles = new google.maps.KmlLayer("http://yourdomain.com/generatekml.php");
kmlFiles.setMap(map);
and that's it.

Getting the longitude and latitude of a region from a webservice

I am building a JS application which uses google maps and needs the ability to have polygons over the states (the same shape as the state) to which colors can be applied. Something like this:
http://econym.org.uk/gmap/example_states4.htm
I can get something set up similar to that, but I don't have XML or data for any other regions.
What I'd really like is to be able to call a webservice with a given state, country, region, etc. and retrieve a series of lat/long coordinates laying out the given region. I've done some initial research but haven't found anything that seems to be up to task.
Can anyone recommend a solution?
Here is a KML of all US states and capitals. You can extract the states boundaries from that file or just use the KML itself. USA States KML

Categories

Resources