Skip to content

Commit

Permalink
refactor JS functions for simplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjtimmons committed Dec 13, 2016
1 parent 0c20386 commit 4601513
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var map;
$(document).ready(function () {
var initialLocation;
var siberia = new google.maps.LatLng(60, 105);
var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
var newyork = new google.maps.LatLng(40.773637, -73.970350);
var browserSupportFlag = new Boolean();
var InfoWindowCount = 0

Expand All @@ -32,7 +32,8 @@ $(document).ready(function () {
// }

function initialize() {
//turn off points of interest (POI) markers so people can only look at the info boxes generated by this app
//this function builds the map
//remove google points of interest markers
var myStyles =[
{
featureType: "poi",
Expand All @@ -42,24 +43,23 @@ $(document).ready(function () {
]
}
];

//set map types
mapOptions = {
//center: new google.maps.LatLng(40.710926,-73.95885700000001),
zoom:16,
mapTypeId: google.maps.MapTypeId.ROADMAP,
styles: myStyles,
disableDefaultUI: true
};

map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
infoWidth = 350

if ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
infoWidth = 500
}
var lat, lng = map.getCenter()

// Try W3C Geolocation (Preferred)
//varlat , lng = map.getCenter()

// Try geolocation
if(navigator.geolocation) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function(position) {
Expand All @@ -77,7 +77,7 @@ $(document).ready(function () {

function handleNoGeolocation(errorFlag) {
if (errorFlag == true) {
alert("Geolocation service failed.");
alert("Geolocation didn't work on your browser. We are starting you in NYC");
initialLocation = newyork;
} else {
alert("Your browser doesn't support geolocation. We've placed you in Siberia.");
Expand All @@ -92,14 +92,12 @@ $(document).ready(function () {
}

function writeMarker() {
//set map center

c = map.getCenter();
var lat = c.k;
var lng = c.B;
var url = 'http://api.geonames.org/findNearbyWikipedia?lat='+ lat +'&lng='+ lng +'&maxRows=10&username=andyjt';
//get the data
$.get(url, function (data) {
//iterate through the data
$(data).find("entry").each(function(){
//check to see if the marker was already made
//if (checkMarkers($(this).find("title").text()) === false) {
Expand Down

0 comments on commit 4601513

Please sign in to comment.