I am an experienced GIS guy, but new to the Google map API. I can see from reading back in this forum that there is a way to overlay an ESRI shapefile into the GMap. Can someone give me a quick jumpstart please. What other data formats are supported. It looks as if you can render a polyline as a series of LAT/LON points in decimal degrees if need be. Is this the only way? JTF
I tried ESRI Ungenerate, but found MapInfo MIF format to be easier to deal with -- still had to do a little manipulating in Excel to get it into the proper format.
I've written a PHP script that reads any .mif files in the same directory as the PHP script and converts all the points to polylines then plots it on a Gmap.
It's at work, I'm at home :) I promise to post it in the morning. (are you comfortable editing PHP code to fit your needs?)
That will be extremely helpful (to me and others I am sure). I am very much a neophyte re: PHP, but this will give me some real incentive to learn something.
> I've written a PHP script that reads any .mif files in the same > directory as the PHP script and converts all the points to polylines > then plots it on a Gmap.
> It's at work, I'm at home :) I promise to post it in the morning. > (are you comfortable editing PHP code to fit your needs?)
I am plotting polylines and have converted the lines to nodes (points) with start/stop coordinates, and was thinking to generate polylines between them, but WOW is that a lot of coding for 2,000 nodes.
Thats funny that you are working on fightthebite because I am consulting for the vector agency on water quality issues! And I goto the website daily to get updates and have been impressed with the Gmap use - very nice.
What a coincidence! I'm the webmaster and in-house IT Admin for the agency. I get calls at midnight to update the spraying status on the website! argg!
> You'll need to edit index.php and change the $key variable.
> Other than that, just put any .mif files in the MIFs folder, and it > looks in there and automatically reads and plots the data.
> Note that this script should work with any text files containing a list > lat/long points.
Tried it, for some reason it is not reading the .mif file It returns the following error.
<b>Warning</b>: file(MIFS/mellette.mif): failed to open stream: No such file or directory in <b>/srv/www/mywebsite/index.php</b> on line <b>82</b><br /> <br /> <b>Warning</b>: Invalid argument supplied for foreach() in <b>/srv/www/mywebsite/scripture/satmap_gpx.php</b> on line <b>84</b><br />
MattPF wrote: > Awesome Bill.. I admit the code may be sloppy, it was something I threw > together for test purposes only, but good to hear it suits you well.
Thanks everyone - it looks like my path of least resistence at this point will be ESRI Shp > MIF > Bill's script > GMap poly. I am interested in looking into WMS & WFS as well and look forward to joining into the discussion. Joel
Selects all the polygons in the database where the planned column is set to "Past" then plots them live. It's easier to store, manage, and query a library of polygons inside a spatial database such as PostgreSQL/PostGIS instead of a bunch of MIF files.
One example I've used is a query of all zip code "polygons" overlapping sacramento county "polygon" -> which plots all zip codes in sac county.
MattPF wrote:
> One example I've used is a query of all zip code "polygons" overlapping
> sacramento county "polygon" -> which plots all zip codes in sac
> county.
> -Matt
If anyone comes up with a PHP/MySQL solution to do that, I'd be
interested. I need to plot zip codes, and I also need to plot city
boundaries (although not at the same time).
I use PHP/PostgreSQL which isn't too far from what you're looking for. This is my first venture with Postgre and it's not much different than MySQL at this level.
If you're not going to be running spatial queries (searching for points within polygons, or polygons overlapping other polygons) then you can just store the outlines/boundaries as a series of lat/longs in a normal MySQL table.
You could use them to translate the shapefiles to MapInfo mid/mif
format which is a simple readable ASCII format. The command would be
something
like:
ogr2ogr -f "MapInfo File" out.mif in.shp
Are the input shapefiles already in lat/long coordinates or are they in
a projected coordinate system? If they are in a projected coordinate
system, and you want to convert them to geographic (lat/long)
coordinates then you can use a slightly more complex command:
I got a method to work (finally) to add polygons to Google Maps. I am by no stretch of the imagination a programmer. Keeping that in mind, the basic process is:
1. Link to xmaps.1b.js at http://xmaps.busmonster.com/ (its an uber useful extension for the Google API) 2. Create (or use existing) polygon in ArcMap. Be sure to set the data frame coordinate system to WGS 84 (View --> Data Fram Properties --> Coordinate System --> Predefined --> Geographic Coordinate Systems --> World --> WGS 84) 3. Convert Verticies to Points (AcrToolbox --> Data Management Tools --> Features --> Feature Verticies to Points) 4. Add XY Coords - there are scripts to do this in 8.x (check out www.ian-ko.com) and a built in funcion (ArcToolbox --> Data Management Tools --> Features --> Add XY Coordinates) in 9.x. 5. In ArcCatalog, create a new empty personal geodatabase 6. Back in ArcMap, export the TABLE of the verticies to the geodatabase, not the shapfile. 7. Upload the geodatabase to your web server. 8. Use an asp file to create xml. For this example, Polytable is the name of the geodatabase I created in step 4. Harris is the name of the table I exported into it. Copy and paste this section and save as an *.asp. Upload to your web server. It creates a file in the format that Goolge expects a la http://www.google.com/apis/maps/documentation/#Using_XML_and_Asynchro.... I got hints and tips from http://www.w3schools.com/xml/xml_server.asp
<% response.ContentType = "text/xml" set conn=Server.CreateObject("ADODB.Connection") conn.provider="Microsoft.Jet.OLEDB.4.0;" conn.open server.mappath("/maps/polytable.mdb") sql="select POINT_X, POINT_Y from harris" set rs=Conn.Execute(sql)
Back to the point about me not being a programmer. I was having issues in Firefox creating the proper xml (something partially about not closing the <marker> tag and partially someting about having an '='. To circumvent these types of errors I just have it write 'quote' where there needs to be a ", 'equalsign' where there should be a =, 'space' where there needs to be a " " to take care of punctuation. I copied the output from Firefox into a text editor and did a Find-Replace to find and replace (creatively enough) the writtin out punctuation with the symbol version. I then saved the xml.
If you check out the source of maps.danielbally.com/harris2.html you'll see where you can refer to asp instead of xml in the request.open portion. It works exactly the same and, this way, you can skip the last part of #8. Good times.
Another update. This is still a work in progress, so please bear with me. Skip step 6. Exporting the shapefile works just fine. A dbf is a dbf anyway it gets in the geodatabase. Thanks.