Permalink
Browse files

added anothe js

  • Loading branch information...
archithamarri committed Nov 25, 2012
1 parent 968f64e commit 6ec9c2419fd070fc0d23fcbc7b4952d83e077a72
Showing with 96 additions and 93 deletions.
  1. +7 −92 app/assets/javascripts/map.js
  2. +88 −0 app/assets/javascripts/mashup.js
  3. +1 −1 app/views/pages/home.html.erb
@@ -1,7 +1,3 @@
-var map;
-var parkLayer, openspaceLayer, publicartLayer, bikepathLayer, citylimitLayer, transitroutesLayer, neighborhoodLayer, policebeatLayer , femaexemptionLayer;
-var park, openspace, publicart, bikepaths, citylimits, transitroutes, neighborhoods, policebeats , femaexemptions;
-//$(document).ready(function () {
function initialize() {
var contentString = 'Hello';
var infowindow = new google.maps.InfoWindow({
@@ -20,11 +16,13 @@ function initialize() {
position: google.maps.ControlPosition.TOP_RIGHT
}
};
+ map = new google.maps.Map(document.getElementById('map'), options);
+ mashup();
// ************************** Markers init on Log in ****************//
/*
Pass a GET request to the index function in Locations model to get the locations marked by the user.
*/
-$.ajax({
+ $.ajax({
type: "GET",
dataType: "json",
url: "/locations",
@@ -42,9 +40,10 @@ $.ajax({
});
}
}
- });
+ });
+
/* This particular sends an Ajax request to the controller to add the latitude and longitude of the points where there is a double click */
-google.maps.event.addListener(map, 'dblclick', function(event) {
+ google.maps.event.addListener(map, 'dblclick', function(event) {
var marker = new google.maps.Marker({position: event.latLng, draggable: true, map: map});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
@@ -60,95 +59,11 @@ google.maps.event.addListener(map, 'dblclick', function(event) {
});
});
- map = new google.maps.Map(document.getElementById('map'), options);
- parkLayer = new google.maps.KmlLayer('http://data.cabq.gov/community/parksandrec/parks/CityParks.kmz');
- openspaceLayer = new google.maps.KmlLayer('http://data.cabq.gov/community/openspace/CityOpenSpace.kmz');
- publicartLayer = new google.maps.KmlLayer('http://data.cabq.gov/community/art/publicart/PublicArt.kmz');
- bikepathLayer = new google.maps.KmlLayer('http://data.cabq.gov/community/bikepaths/BikePaths.kmz');
- citylimitLayer = new google.maps.KmlLayer('http://data.cabq.gov/government/citylimits/abqcitylimits.kmz');
- transitroutesLayer = new google.maps.KmlLayer('http://data.cabq.gov/transit/routesandstops/transitroutes.kmz');
- neighborhoodLayer = new google.maps.KmlLayer('http://data.cabq.gov/community/neighborhoods/NeighborhoodAssociations.kmz');
- policebeatLayer = new google.maps.KmlLayer('http://data.cabq.gov/publicsafety/policebeats/APD_BCSO_Beats.kmz');
- femaexemptionLayer = new google.maps.KmlLayer('http://data.cabq.gov/FEMA/FEMA_exemptions_CABQ.kmz');
- $('#park').attr('checked',false);
- $('#openspace').attr('checked',false);
- $('#publicart').attr('checked',false);
- $('#bikepaths').attr('checked',false);
- $('#citylimits').attr('checked',false);
- $('#transitroutes').attr('checked',false);
- $('#neighborhoods').attr('checked',false);
- $('#policebeats').attr('checked',false);
- $('#femaexemptions').attr('checked',false);
+
// ***************** End of markers functions ************ ///
// ***************** Start of Info Boxes ***************//
/* var infowindow = new google.maps.InfoWindow({
content: 'Hello world'
});infowindow.open(map, marker);
*/
}
-function show() {
- park = $('#park').is(":checked");
- openspace = $('#openspace').is(":checked");
- publicart = $('#publicart').is(":checked");
- bikepaths = $('#bikepaths').is(":checked");
- citylimits = $('#citylimits').is(":checked");
- transitroutes = $('#transitroutes').is(":checked");
- neighborhoods = $('#neighborhoods').is(":checked");
- policebeats = $('#policebeats').is(":checked");
- femaexemptions = $('#femaexemptions').is(":checked");
- if(park){
- parkLayer.setMap(map);
- }
- else{
- parkLayer.setMap(null);
- }
- if (openspace) {
- openspaceLayer.setMap(map);
- }
- else{
- openspaceLayer.setMap(null);
- }
- if(publicart) {
- publicartLayer.setMap(map);
- }
- else{
- publicartLayer.setMap(null);
- }
- if(bikepaths) {
- bikepathLayer.setMap(map);
- }
- else{
- bikepathLayer.setMap(null);
- }
- if(citylimits) {
- citylimitLayer.setMap(map);
- }
- else{
- citylimitLayer.setMap(null);
- }
- if(transitroutes) {
- transitroutesLayer.setMap(map);
- }
- else{
- transitroutesLayer.setMap(null);
- }
- if(neighborhoods){
- neighborhoodLayer.setMap(map);
- }
- else{
- neighborhoodLayer.setMap(null);
- }
- if(policebeats){
- policebeatLayer.setMap(map);
- }
- else{
- policebeatLayer.setMap(null);
- }
- if(femaexemptions){
- femaexemptionLayer.setMap(map);
- }
- else{
- femaexemptionLayer.setMap(null);
- }
- //$(":checkbox").attr("autocomplete", "off");
- }
@@ -0,0 +1,88 @@
+var map;
+var parkLayer, openspaceLayer, publicartLayer, bikepathLayer, citylimitLayer, transitroutesLayer, neighborhoodLayer, policebeatLayer , femaexemptionLayer;
+var park, openspace, publicart, bikepaths, citylimits, transitroutes, neighborhoods, policebeats , femaexemptions;
+function mashup(){
+ parkLayer = new google.maps.KmlLayer('http://data.cabq.gov/community/parksandrec/parks/CityParks.kmz');
+ openspaceLayer = new google.maps.KmlLayer('http://data.cabq.gov/community/openspace/CityOpenSpace.kmz');
+ publicartLayer = new google.maps.KmlLayer('http://data.cabq.gov/community/art/publicart/PublicArt.kmz');
+ bikepathLayer = new google.maps.KmlLayer('http://data.cabq.gov/community/bikepaths/BikePaths.kmz');
+ citylimitLayer = new google.maps.KmlLayer('http://data.cabq.gov/government/citylimits/abqcitylimits.kmz');
+ transitroutesLayer = new google.maps.KmlLayer('http://data.cabq.gov/transit/routesandstops/transitroutes.kmz');
+ neighborhoodLayer = new google.maps.KmlLayer('http://data.cabq.gov/community/neighborhoods/NeighborhoodAssociations.kmz');
+ policebeatLayer = new google.maps.KmlLayer('http://data.cabq.gov/publicsafety/policebeats/APD_BCSO_Beats.kmz');
+ femaexemptionLayer = new google.maps.KmlLayer('http://data.cabq.gov/FEMA/FEMA_exemptions_CABQ.kmz');
+ $('#park').attr('checked',false);
+ $('#openspace').attr('checked',false);
+ $('#publicart').attr('checked',false);
+ $('#bikepaths').attr('checked',false);
+ $('#citylimits').attr('checked',false);
+ $('#transitroutes').attr('checked',false);
+ $('#neighborhoods').attr('checked',false);
+ $('#policebeats').attr('checked',false);
+ $('#femaexemptions').attr('checked',false);
+ }
+function show() {
+ park = $('#park').is(":checked");
+ openspace = $('#openspace').is(":checked");
+ publicart = $('#publicart').is(":checked");
+ bikepaths = $('#bikepaths').is(":checked");
+ citylimits = $('#citylimits').is(":checked");
+ transitroutes = $('#transitroutes').is(":checked");
+ neighborhoods = $('#neighborhoods').is(":checked");
+ policebeats = $('#policebeats').is(":checked");
+ femaexemptions = $('#femaexemptions').is(":checked");
+ if(park){
+ parkLayer.setMap(map);
+ }
+ else{
+ parkLayer.setMap(null);
+ }
+ if (openspace) {
+ openspaceLayer.setMap(map);
+ }
+ else{
+ openspaceLayer.setMap(null);
+ }
+ if(publicart) {
+ publicartLayer.setMap(map);
+ }
+ else{
+ publicartLayer.setMap(null);
+ }
+ if(bikepaths) {
+ bikepathLayer.setMap(map);
+ }
+ else{
+ bikepathLayer.setMap(null);
+ }
+ if(citylimits) {
+ citylimitLayer.setMap(map);
+ }
+ else{
+ citylimitLayer.setMap(null);
+ }
+ if(transitroutes) {
+ transitroutesLayer.setMap(map);
+ }
+ else{
+ transitroutesLayer.setMap(null);
+ }
+ if(neighborhoods){
+ neighborhoodLayer.setMap(map);
+ }
+ else{
+ neighborhoodLayer.setMap(null);
+ }
+ if(policebeats){
+ policebeatLayer.setMap(map);
+ }
+ else{
+ policebeatLayer.setMap(null);
+ }
+ if(femaexemptions){
+ femaexemptionLayer.setMap(map);
+ }
+ else{
+ femaexemptionLayer.setMap(null);
+ }
+ }
@@ -10,7 +10,7 @@
<% if user_signed_in? %>
<div id="map" onload="initialize();">
</div>
-<div id="formalign" onload="uncheck();">
+<div id="formalign" >
<!--h4>Datasets:</h4-->
<br><br><br>
<%= check_box_tag 'park', 'park', false %> Park

0 comments on commit 6ec9c24

Please sign in to comment.