gmaps4rails - position from map - ruby-on-rails-3

I am wondering how to get latitude & longitude information from a map using gmaps4rails and then store it in my db/model.
Any ideas?
Thanks
Adam

I wrote about it in the wiki
Look at Drop a marker and update fields attribute in a form and take some inspiration.

Related

Retrieve shapefile from ESRI ArcServer (proxy.ashx)

Alberta has an ESRI map about the Oil Sands (OSIP): Link.
When you save the webpage you will get an proxy.ashx file which seems to contain the whole geometry:
dojo.io.script.jsonp_dojoIoScript9._jsonpCallback({"displayFieldName":"Operator_Name","fieldAliases":{"OBJECTID":"OBJECTID","OSP_NO":"Project
Number","Project_Name":"Project Name","OS_Area":"Oil Sands
Area","Industry_Type":"Industry Type","Project_Status":"Project
Status","Year":"Year","Shape.STArea()":"Shape.STArea()","Shape.STLength()":"Shape.STLength()","Operator_Name":"Operator
Name"},"geometryType":"esriGeometryPolygon","spatialReference":{"wkid":102100,"latestWkid":3857},"fields":[{"name":"OBJECTID","type":"esriFieldTypeOID","alias":"OBJECTID"},{"name":"OSP_NO","type":"esriFieldTypeSmallInteger","alias":"Project
Number"},{"name":"Project_Name","type":"esriFieldTypeString","alias":"Project
Name","length":255},{"name":"OS_Area","type":"esriFieldTypeString","alias":"Oil
Sands
Area","length":5},{"name":"Industry_Type","type":"esriFieldTypeString","alias":"Industry
Type","length":3},{"name":"Project_Status","type":"esriFieldTypeString","alias":"Project
Status","length":3},{"name":"Year","type":"esriFieldTypeSmallInteger","alias":"Year"},{"name":"Shape.STArea()","type":"esriFieldTypeDouble","alias":"Shape.STArea()"},{"name":"Shape.STLength()","type":"esriFieldTypeDouble","alias":"Shape.STLength()"},{"name":"Operator_Name","type":"esriFieldTypeString","alias":"Operator
Name","length":75}],"features":[{"attributes":{"OBJECTID":1,"OSP_NO":1,"Project_Name":"Cold
Lake
Operations","OS_Area":"CL","Industry_Type":"02","Project_Status":"01","Year":2015,"Shape.STArea()":688184465.74006724,"Shape.STLength()":193203.94833874877,"Operator_Name":"Imperial
Oil
Resources"},"geometry":{"rings":[[[-12282289.675502496,7273922.0817552721],[-12282396.117050292,7273922.0677068951],
...CONTENT...
]]]}}]});
(Full paste available here)
Is there any way to export this as a shapefile?
PS: Would be great, if the proxy file could be used to circumvent ESRIs strategy to hide the geometry in SVG paths.
You may use AGStoShapefile from TannerGeo for this task.
I think this Link could solve your Problem to convert GeoJson to Shape.
https://community.esri.com/thread/105193
It matches your Question perfectly.
Regards, Miriam

gridx pagination summary description - how to change format

Is there any way to the change the summary description that is displayed when Pagination is enabled on the gridx control?
It says 'Total 100' Whereas on the enhanced grid it would say 1-20 of 100 items
Can this description be tailored?
The docs say that "the user can specify the string to use to display", but it's not shown how to do this. Maybe poking around the source can help you out.
Also here's a similar question.

Rails 3 - how to make a crossing? (routing)

I created a controller names. I have a model that contains a names of boys and girls (gender=0 for boys, 1 for girls).
If I set to URL the address localhost:3000/names, so will be rendered the view index.html.erb. In this view is an overview of data that are stored in database.
I am trying to edit it - I want to have on the address localhost:3000/names a crossing - here will be 2 links - BOYS and GIRLS. And after click on one of these links I would like to go on the address localhost:3000/names/girls (or boys) and here I would like to have an overview of data from database...
I am newbie still and I don't know, how to realize it... mainly how to edit my routes.rb - I would like to ask you about a help, how to do it...
Thank you in advance
So you want a names_controller with actions boys and girls, and you want routes to those?
How about something like this:
resources(:names) do
collection do
get :boys
get :girls
end
end
Routes collection is documented here.

Google maps api,Postgis,Multipolygon

PostGis WKT format of Multipolygon is:
MULTIPOLYGON(
((20.229 39.409,20.2241 39.401,20.220 39.410,20.229 39.409)),
((20.209 39.407,20.223 39.400,20.211 39.402,20.209 39.4076))
)
Google Maps api v3 Polygon is:
var triangleCoords = [
new google.maps.LatLng(25.774252, -80.190262),
new google.maps.LatLng(18.466465, -66.118292),
new google.maps.LatLng(32.321384, -64.75737)
];
The question is:
Can i create a multipolygon in google maps?
PostGIS supports a number of output formats directly:
http://postgis.refractions.net/documentation/manual-1.5/ch08.html
See the ST_As() funcs.
The Google Maps API supports a number of these as well (SVG, KML, etc.). You should try using a format that both speak. Now I'm not sure if Google Maps accepts multipolygons in any of these formats. But you could always use the ST_Simplify() func.
var multipolygon=[
[new google.maps.LatLng(x1,y1),new google.maps.LatLng(x2,y2),new google.maps.LatLng(x3,y3)],
.
.
.
[new google.maps.LatLng(x4,y4),new google.maps.LatLng(x5,y5),new google.maps.LatLng(x6,y6)]
];
This is a little old, but I was just working on the same thing, trying to create MultiPolygons from GeoJSON files in Google Maps, so thought I would share.
Basically, no, you can't. But you can create a workaround.
First create something to manage the individual sub-polygons (object, array, etc). Then populate that object with each portion of the multipolygon. Then you can treat the sub-polygons as a group, via custom methods or iteration through them.
See http://www.alecbennett.com/projects/loadgeojson for a quick demo of "MultiPolygon" highlighting on hover in Google Maps v3. Data is loaded from a GeoJSON file, so would be a similar approach to the WKT version.

How to display two series via Google Chart API?

I can't get the two series of numbers to scale together.
Here is sample code that you can paste into...
http://code.google.com/intl/en/apis/chart/docs/chart_playground.html
cht=lxy
chs=400x300
chd=t:20,30,40|1,4,2|24,34,44|3,7,1
chds=20,40,1,4,24,44,1,7
chxr=0,20,54,2|1,0,7,1
chxt=x,y
chxs=0,ff0000,12,0,lt
1,0000ff,10,1,lt
chco=FF0000,00FF00
chdl=Apples
Oranges
chtt=Some+Values
chts=0000ff,24
Translated:
chd=t:s,e,r,i,e,s,1|s,e,r,i,e,s,2|...ors:series1,series2,...ore:series1,series2,...
chds=<series_1_min>,<series_1_max>,...
chxr=<axis_index>,<start_val>,<end_val>,<step>|...
The three varying parameters in question are:
chd=t:20,30,40|1,4,2|24,34,44|3,7,1
chds=20,40,1,4,24,44,1,7
chxr=0,20,54,2|1,0,7,1
Can anyone get this simple example working?
The chart supports multiple series but for some reason I can't scale it so that the values are displayed within scale.
Any help appreciated,
Chris
After some practice I think I needed to make the chds values the same for both sets of data. I need to play with it more but I thought I would post a working example for posterity.
cht=lxy
chs=400x300
chd=t:20,30,40|1,4,2|24,34,44,48|3,7,1,2
chds=10,50,0,10,10,50,0,10
chxr=0,10,50|1,0,10,1
chxt=x,y
chxs=0,ff0000,12,0,lt
1,0000ff,10,1,lt
chco=FF0000,00FF00
chdl=Apples
Oranges
chtt=Some+Values
chts=0000ff,24
chm=o,0000FF,0,-1,5,0|o,ff0000,1,-1,5,0
chg=10,10
Scaling can be tricky to get right.
Try using chds='a' for automatic scaling at first.