BREAKING NEWS

Blogger Security

Css

Javascript

Friday, May 9, 2014

Making Maps from Google Maps API


Vacation time to develop themselves, curious to mengexplore back on the map or a location on the website eventually I fell in love with Google Maps, definitely. I will try to make a simple tutorial How to display a Location Map Website: 

Previously there are things that must be understood in advance of the Google Maps API Key I just do not explain the details here. Key Sederhanaya it is necessary so that we can use the API of Google Maps API under my life as an example, but if you want to actually create their own applications, I suggest you to register and create your own Google Maps Key.

Very Simple and Easy script Understood :
<scriptsrc="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
</script>
Among <head> you call a script that you can use APIs from Google Maps. So make sure you write it. Key contains data that I described above. While the sensor for this application describes using examples such as sensors or GPS.
<div id="googleMap" style="width:500px;height:380px;"> </ div> 
It is a Div with id google simple folder that will be a place to display a map that we will create.

Here it takes considerable understanding of javascript:
<script>
function initialize()
{
var mapProp = {
center:new google.maps.LatLng(-6.194912, 106.822823),
zoom:5,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap")
,mapProp);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
We first create a function with the name [instance] initialize () inside the function that we devinisikan 2 variables.


  • mapProp This variable contains data or configuration settings for the map to be our show. There are 3 examples of the type of config 


  1. center: here we define the coordinates of the location code into the middle of the map. I demonstrated above coordinates HI Roundabout, Jakarta 
  2. Zoom: Zoom us define the magnitude of the map, the greater the value that our map view Details show 


  • This variable we run the folder object from Goolge maps API, which contains 2 parameters 


  1. document.getElementById ("googlemap") is to select the div element that we have made above with id GoogleMap 
  2. mapProp This is the name of the variable that you created above. 
  3. mapTypeId is the kind of maps that we want to show, there are options beberpa: ROADMAP, SATELLITE, HYBRID, TERRAIN google.maps.event.addDomListener(window, ‘load’, initialize);

it is a command used to add a listener that essentially When the page reloads he would perform the function initialize () 

Perhaps such a simple explanation. 

Sample script:
<!DOCTYPE html>
<html>
<head>
<scriptsrc="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
</script>

<script>
function initialize()
{
var mapProp = {
center:new google.maps.LatLng(-6.194912, 106.822823),
zoom:5,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap")
,mapProp);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>

<body>
<div id="googleMap"></div>

</body>
</html>

Post a Comment

 
Copyright © 2013 Tips & Trik Blog
Powered byBlogger