Eric Binnion
a8cgm Austin automattic bowen island cloudfest development do_action git github harley davidson hero instagram iOS javascript jetpack kareless latergram lonestardrift meetup mercury officetoday photo101 photos php phptek pistol pokemongo Programming react rome scm ted travelmattic vancouver video wcbos wcdfw wcokc wcus whistler wichita falls woocommerce wooconf wordcamp WordPress
-
-
-
-
-
-
-
-
-
How to Add a Google Map to your Website with Geocoding
Inserting Google Maps into a website is CRAZY easy! Usually what I would advise someone to do is to:
- Go to Google Maps
- Search for the address that you want to show on your map
- Grab the embed code
- Insert embed code in your website
Could it get any easier? Well, that really depends on what your development needs are. I recently completed a project for a client that owned a mobile BBQ restaurant. This client wanted a map on his website that he could easily update with the location of his mobile smoking pit. I didn’t think it made much sense to make the client do the 4 steps above just to update his map… So I decided to look into Geocoding a google map. This way, all my client had to do to update his map was to login and change the address.
For those that do not know, geocoding is essentially the process of taking an address and turning that into latitude and longitude coordinates. Google maps has geocoding baked in – FOR FREE!
Without further ado, below is some code on using geocoding with Google Maps.
This code goes in the head.
[code]
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
[/code]This code can go anywhere in the body.
[code]
<div id="map" style="width: 413px; height: 300px;"></div><script type="text/javascript">// <![CDATA[
var mapOptions = {
zoom: 16,
center: new google.maps.LatLng(54.00, -3.00),
mapTypeId: google.maps.MapTypeId.ROADMAP
};var geocoder = new google.maps.Geocoder();
var address = ‘3410 Taft Blvd Wichita Falls, TX 76308’;
geocoder.geocode( { ‘address’: address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});var map = new google.maps.Map(document.getElementById("map"), mapOptions);
// ]]></script>
[/code]You can update the size of the map by changing the width and height values of the
#mapdiv. To change the starting zoom level, change zoom. You can change the type of map by changing mapTypeId. And most importantly, you can change the address by changing the value in var address.You should be able to plug this code in to your website and be good to go. This code will take the address in var address, Geocode it using Google, and then center the map with a marker at the address specified.
This is a fairly simple example of Geocoding, but you could take this code and make a map that will dynamically update with user input. In a future post, I will discuss how to integrate Geocoding into WordPress so that you can easily create and edit maps without having to get latitude and longitude coordinates.
-
Youtube UIWebView with Storyboards
While working on the iMustangs project, we decided that it would be a good idea to include the school fight song. I’m sure we could have found a way to play a .mp3 file, but we decided that it would be best to create a video so that we could display our university logo. What follows is the result of our work in using UIWebView on iOS.
First Attempt
Our first attempt was very light on code and pretty simple. I’d like to show this to you by running through a test project. In Xcode, go ahead and start a new single-view application.
Navigate to the Storyboard in your project. Once you are here, add a web view on top of the current view. Go ahead and stretch the web view to fill the view below. Now, let’s go ahead and connect the web view.
I like to use the assistant editor when I connect UIWebViews and other objects to outlets and actions. Click the assistant editor button near the top right of Xcode (I am currently using 4.3.1). The assistant editor will show the storyboard beside your class, so that you can easily connect an object to a specific line of code in your .h file.
Once you’re in assistant editor mode, click the UIWebView and drag it to just below @interface. Let go.
At this point another dialog should’ve popped that is asking you to name your UIWebView. Go ahead and name it webView (be sure to use correct case).
Now, navigate to your ViewController.m file and paste the following code within the viewDidLoad function. You may replace the url with one of your own.
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"<a href="http://www.youtube.com/embed/XeIKnBDN4To">http://www.youtube.com/embed/XeIKnBDN4To</a>"]]];At this point, you should be able to run this project in a simulator and see an MSU youtube video, or whatever URL you substituted. This worked fine for us, until we put it on an actual iPhone… (more…)
-
-
-
-


















