Brandon Golway

Greenhorn
+ Follow
since Oct 19, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Brandon Golway

This is what I followed to implement the map: Google Maps Javascript API V3 Tutorial. Once I understood it, it was pretty easy to implement the map and it's features. I need to Statically Geocode Locations which have been previously scraped by a PHP scraper (along with job title and a link to the job), then placed on the map with a marker and info bubble that will open when clicked containing the company name, the title of the job, and possibly a link to the job.

The output of the geocoder is either JSON or XML and Google recommends JSON since the code is more concise and its easier to pick stuff out that you want.
I'm pretty bad with javascript and I need help with overlaying the data I get back from Google's static geocoding API. Here's the API link already formed to convert New York,NY to 40.78343450, -73.96624950 http://maps.googleapis.com/maps/api/geocode/json?address=%22New%20York,NY%22&sensor=false but after a few hours of messing with it, I can't figure out what to do with it and where to put it. Should it go in my html source where my map is? Should it go in my PHP file since the locations for geocoding will come from the PHP file? Should it go in it's own external file?

I tried using jQuery.parseJSON in my main html page but couldn't figure out how to get any output from it. Google also says that you can easily parse out the location coordinates by using this script, but I have no idea what to do with it either.



Could someone please write an example on how to take the JSON data, parse it so there's only location data, and make it available to the Google Maps API so that I can place a marker? I can't find anything that gives implementation examples or details, just how to do it if you already know what you're doing, which I obviously don't. I based my stuff off of Google's HTML example files but they don't have one for static geocoding, only dynamic geocoding (which is apparently built into the maps API).

Here's a basic road map of what I'm trying to do:

1. use scraper.php to scrape city and state from a job listing site into an array (done)
2. strip the 25 locations out of the array one at a time using a for loop (done)
3. feed those individual strings into the geocoding API url (done)
4. Parse the JSON output from the geocoding API URL and grab the coordinates from the location field, then overlay them on the map (this is what I need help with)
got it to work all i was missing was _all from preg_match

12 years ago
PHP
I got it to output "West Orange, NJ" using this expression: $regex_location= '/<td class=\"location\">(.+?)<\/td>/';

There's more data in there since I get array(2) { [0]=> string(41) "West Orange, NJ" [1]=> string(15) "West Orange, NJ" } when I do var_dump($scraped_location_data) but I don't know how to access it.
12 years ago
PHP
I'm trying to extract the text inside of the <td> tags (such as: "West Orange, NJ", "Saint Barnabas Health Care System", and "Manager Field Services North") and the contents of the href attribute from data scraped by a php script. The script itself works, I just don't know how to formulate the expressions.
Here's a sample of HTML that contains the job info:




This is what I've tried $location= '/location (.+?)/'; but it just gives back array(2) { [0]=> string(10) "location j" [1]=> string(1) "j" } j


Here's the scraper too in case you need to see that: curl_scraper.php
Thanks.
12 years ago
PHP
First off, I dont mean I want the program to end. What I have setup is a simple game that shows pop-up windows that are either Info or Input windows and I would like to know how to close a child's window when it's child window closes.

So far its like this: Main Input Window launches Attack Input Window which launches an Information window. I want to know how to close the Attack Input window when "ok" is clicked on the Info window.

Heres the code related to it
13 years ago
I found one way to do it by passing default values to the Person constructor from the Soldier constructor while also calling my functions in the Soldier class to override the default values. It's probably the wrong way to do it, but it does what I need lol
13 years ago
I do understand the basics of extending classes since I had a problem with this earlier and some of the members explained it to me, the problem that I had was I was redefining the values when all I needed was a constructor. How can I pass the random values that are created in Soldier to the superclass Person? I tried it a few different ways before and it wouldn't accept them.

I removed the variable declarations in Solder but these are the errors that I'm getting now
when I create the constructor in Soldier and use super() it tells me that the variables that are contained in super() Cannot be refered to an instance field height while explicitly invoking a constructor
when I comment out super() it tells me Implicit super constructor Person() is undefined. Must explicitly invoke another constructor
13 years ago
Yea I was thinking about that, after looking at it some more I figured it was easier to not extend it and just copied the methods from person to the Soldier class. The way my partner did it doesn't really make sense to me since you'll most likely have more than one Blacksmith and one Farmer, and every time a new object is created from one of them all the values have to be defined by hand, where as mine are created and set automatically.
13 years ago
In my Java college class we have to combine our game classes that we created for our mid-term with other class members classes to make a full game. I successfully merged two out of the three characters/objects but I'm having problems with the third since it uses random values. The superclass Person contains all the shared functions between the people Farmer, Blacksmith, King, Queen and Soldier. The first two weren't written by me and have additional functions, King and Queen just contain a constructor that sets variables since there will only be one king and one queen. I set up Soldier to generate random values for some of the properties such as Height, Weight, Strength, and Age since you will usually have multiple soldiers. The problem that I'm having it that my partner set up his Person class using functions that I'm not familiar with such as super(), so I can't figure it out. Essentially what I need to do is figure out how to pass the values that are generated in the Soldier class to the Person class so that each time a Soldier gets created it's stats will be filled in by the randomly generated values.

tl;dr I need to know how to pass randomly generated values from Soldier() to Person() so that each time a soldier gets created its stats are filled in by the random values.

Soldier.java
Main.java
Person.java
13 years ago
Thanks for the help guys. Steve sent me a PM suggesting that I may need to use constructors for my classes and that was exactly what i needed and i was trying to accomplish it by resetting the variables since I had forgotten about constructors. Now everything works the way I want it to.

@Alex
thanks for the explanation about inheritance, as for the re-structuring of the classes I should rename the superclass to Person or something like that I just couldnt think of a good name for it. Besides the Soldier class, I have two more classes called King and Queen which have all the same methods as Soldier but with slight modifcations (Soldier is really the one thats different since age/height/weight/etc.. are all dynamic [given random values] and there can be multiple Soldiers, but usually only one King and Queen whos properties are static), we had also just learned about inheritance in class and this is my mid-term project so I figured it would be better (for my grade and to make the code easier) to inherit stuff. I cant really make this too complex since I have to combine my code with other peoples code later on to make a full game.

@Gary
I have been messing around with debugging in another game I'm creating which is a lot more complex than this and I must say its a hell of a lot easier to debug stuff in java than it was when I was doing C++ and python coding.

13 years ago
Yes I meant the warnings that Eclipse was telling me about, as for setter methods and whatever ever else you said I have no idea what you mean. Im a noob when it comes to java.
13 years ago
Hey Steve, Im assuming you mean the variable identifiers (correct term?).

I messed around with those a little while before posting this and nothing seemed to work, I originally tried private but that didnt work so I tried protected since I was told its pretty much the same as public but can only be used in the scope of sub/super classes and that didn't work either. After reading your post I changed them all to public and that got rid of the warnings that the variables are never read, yet they still return either a 0 int the case of an int or null in the case of a string.
13 years ago
Qualities.java


Soldier.java


Main.java


Even though the values of the variables are defined in Solder.java and I create a soldier object, the values that get returned are from Qualities.java.
13 years ago